« get me outta code hell

Update rule list as soon as a new rule is added - interactive-bgm - Browser extension that adds background music based on the site you're browsing
about summary refs log tree commit diff
path: root/extension
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2019-03-24 08:49:43 -0300
committerFlorrie <towerofnix@gmail.com>2019-03-24 08:49:43 -0300
commit6f5e2d9b568504b681bcfaf3405d059b900bb4b1 (patch)
tree40186829d18e24a7a6c64ec2b53824e2641bd314 /extension
parenta55a4500ee8262d4c9c50d7c769ebc8cb742bb93 (diff)
Update rule list as soon as a new rule is added
I.e. by saving. Also reflect changes in the rule list when the rule's
scope is modified.
Diffstat (limited to 'extension')
-rw-r--r--extension/popup/main.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/extension/popup/main.js b/extension/popup/main.js
index c628447..1bf653a 100644
--- a/extension/popup/main.js
+++ b/extension/popup/main.js
@@ -33,6 +33,7 @@ function changeContentScreen(id) {
 function loadTrackList(opts) {
     const {tab, rule, saveRule, deleteRule} = opts;
     const {music} = rule;
+    saveRule();
     return browser.storage.sync.get('tracks').then(({tracks = []}) => {
         const ul = document.getElementById('track-list');
         while (ul.firstChild) {
@@ -385,7 +386,8 @@ Promise.all([
                             siteSettings.push(rule);
                         }
                         return browser.storage.sync.set({siteSettings})
-                            .then(() => browser.runtime.sendMessage({music: rule.music}));
+                            .then(() => browser.runtime.sendMessage({music: rule.music}))
+                            .then(() => reloadRuleList());
                     },
                     deleteRule: () => {
                         changeScreen('loading-screen');