Skip to content

Commit

Permalink
Revert "Call callback function after storage.set"
Browse files Browse the repository at this point in the history
This reverts commit ced3ac5.
  • Loading branch information
pavelstudeny committed Oct 11, 2020
1 parent 546296d commit 5496f14
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/Framework/Sources/JavaScript/Background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ function manageRequest(payload) {
}

if (payload.eventName === 'storage.set') {
chrome.storage[payload.message.area].set(payload.message.items, sendResponse);
chrome.storage[payload.message.area].set(payload.message.items);
sendResponse();
}

if (payload.eventName === 'storage.remove') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function storage(storageArea) {
}
callbackFunc(result);
},
set(items, callbackFunc) {
set(items) {
const changes = {};
for (const key of Object.keys(items)) {
const oldValue = localStorage.getItem(key);
Expand Down Expand Up @@ -100,7 +100,6 @@ function storage(storageArea) {
});
});
});
callbackFunc && callbackFunc();
},
remove,
/**
Expand Down
10 changes: 8 additions & 2 deletions src/Framework/Sources/JavaScript/Content/chrome/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,22 @@ function storage(storageArea) {
);
},
set(items,callback) {
if (callback) {
chrome.storage.onChanged.addListener(notify);
}
background.dispatchRequest(
{
eventName: 'storage.set',
message: {
area: storageArea,
items
}
},
() => callback()
}
);
function notify() {
callback();
chrome.storage.onChanged.removeListener(notify);
}
},
remove(keys, callback) {
background.dispatchRequest(
Expand Down
6 changes: 3 additions & 3 deletions src/Framework/Sources/JavaScript/Popup/chrome/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function storage(storageArea) {
(resp) => callback(resp)
);
},
set(items, callback) {
set(items) {
window.topee.dispatchRequest(
0,
{
Expand All @@ -33,8 +33,8 @@ function storage(storageArea) {
area: storageArea,
items
}
},
() => callback()
}
// (resp) => callback(resp)
);
},
remove(keys, callback) {
Expand Down

0 comments on commit 5496f14

Please sign in to comment.