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.
This commit is contained in:
John Cowen 2020-05-19 16:20:27 +01:00 committed by GitHub
parent 55e05b39e2
commit 511343d2aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View File

@ -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;
}
},

View File

@ -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,
});
},
},
});