From 312143315bba2a8863cc9357858199a175ac62d5 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 10 Sep 2019 11:13:35 -0600 Subject: [PATCH 1/2] Only update m.accepted_terms if there were changes Fixes https://github.com/vector-im/riot-web/issues/10744 --- src/Terms.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Terms.js b/src/Terms.js index 594f15b522..a664d3f72e 100644 --- a/src/Terms.js +++ b/src/Terms.js @@ -116,6 +116,7 @@ export async function startTermsFlow( } // if there's anything left to agree to, prompt the user + let numAcceptedBeforeAgreement = agreedUrlSet.size; if (unagreedPoliciesAndServicePairs.length > 0) { const newlyAgreedUrls = await interactionCallback(unagreedPoliciesAndServicePairs, [...agreedUrlSet]); console.log("User has agreed to URLs", newlyAgreedUrls); @@ -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 From b35d56167e398ecc834df78d26f2ab580520f9f6 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 10 Sep 2019 11:16:45 -0600 Subject: [PATCH 2/2] const-antly annoying linter although it's a valid complaint here --- src/Terms.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Terms.js b/src/Terms.js index a664d3f72e..685a39709c 100644 --- a/src/Terms.js +++ b/src/Terms.js @@ -116,7 +116,7 @@ export async function startTermsFlow( } // if there's anything left to agree to, prompt the user - let numAcceptedBeforeAgreement = agreedUrlSet.size; + const numAcceptedBeforeAgreement = agreedUrlSet.size; if (unagreedPoliciesAndServicePairs.length > 0) { const newlyAgreedUrls = await interactionCallback(unagreedPoliciesAndServicePairs, [...agreedUrlSet]); console.log("User has agreed to URLs", newlyAgreedUrls);