From b55d5a0ef9817f103b495cb58da7a8da9807be9b Mon Sep 17 00:00:00 2001 From: John Cowen Date: Tue, 19 May 2020 16:20:27 +0100 Subject: [PATCH] ui: Only save the setting that you've changed (#7918) Originally we assumed all settings would be editable in the settings page, but over time we've added thigns to localStorage that aren't user settable settings. This means we shouldn't save all you localStorage settings everything time only a single setting has been saved. This change only changes the setting you've changed via the settings page, meaning it will never update non-user-settable settings. --- ui-v2/app/controllers/settings.js | 4 ++-- ui-v2/app/routes/settings.js | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ui-v2/app/controllers/settings.js b/ui-v2/app/controllers/settings.js index 4f01883001..0533a52c51 100644 --- a/ui-v2/app/controllers/settings.js +++ b/ui-v2/app/controllers/settings.js @@ -35,14 +35,14 @@ export default Controller.extend({ switch (target.name) { case 'client[blocking]': set(this, 'item.client.blocking', !blocking); - this.send('update', this.item); + this.send('update', 'client', this.item.client); break; case 'urls[service]': if (typeof get(this, 'item.urls') === 'undefined') { set(this, 'item.urls', {}); } set(this, 'item.urls.service', target.value); - this.send('update', this.item); + this.send('update', 'urls', this.item.urls); break; } }, diff --git a/ui-v2/app/routes/settings.js b/ui-v2/app/routes/settings.js index b168b8c677..22770105c1 100644 --- a/ui-v2/app/routes/settings.js +++ b/ui-v2/app/routes/settings.js @@ -25,11 +25,17 @@ export default Route.extend({ controller.setProperties(model); }, actions: { - update: function(item) { - if (!get(item, 'client.blocking')) { - this.client.abort(); + update: function(slug, item) { + switch (slug) { + case 'client': + if (!get(item, 'client.blocking')) { + this.client.abort(); + } + break; } - this.repo.persist(item); + this.repo.persist({ + [slug]: item, + }); }, }, });