Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3415 from matrix-org/travis/min-updates
Browse files Browse the repository at this point in the history
Only update m.accepted_terms if there were changes
  • Loading branch information
turt2live authored Sep 10, 2019
2 parents ccd4290 + b35d561 commit 7fcabd7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Terms.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export async function startTermsFlow(
}

// if there's anything left to agree to, prompt the user
const numAcceptedBeforeAgreement = agreedUrlSet.size;
if (unagreedPoliciesAndServicePairs.length > 0) {
const newlyAgreedUrls = await interactionCallback(unagreedPoliciesAndServicePairs, [...agreedUrlSet]);
console.log("User has agreed to URLs", newlyAgreedUrls);
Expand All @@ -125,8 +126,11 @@ export async function startTermsFlow(
console.log("User has already agreed to all required policies");
}

const newAcceptedTerms = { accepted: Array.from(agreedUrlSet) };
await MatrixClientPeg.get().setAccountData('m.accepted_terms', newAcceptedTerms);
// We only ever add to the set of URLs, so if anything has changed then we'd see a different length
if (agreedUrlSet.size !== numAcceptedBeforeAgreement) {
const newAcceptedTerms = {accepted: Array.from(agreedUrlSet)};
await MatrixClientPeg.get().setAccountData('m.accepted_terms', newAcceptedTerms);
}

const agreePromises = policiesAndServicePairs.map((policiesAndService) => {
// filter the agreed URL list for ones that are actually for this service
Expand Down

0 comments on commit 7fcabd7

Please sign in to comment.