From 953e0c3197d7e232484d9773580752a610648c81 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Tue, 25 Feb 2020 07:37:12 -0500 Subject: [PATCH] Use getItemAsync() instead of getItem Related commit: - https://github.com/gorhill/uBlock/commit/da0ef9454a9275aa453aa0e9c62521415a12c4d9 vAPI.localStorage.getItemAsync() was added after the above commit. --- platform/chromium/vapi-background.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/platform/chromium/vapi-background.js b/platform/chromium/vapi-background.js index c3ad46944..d25f7554a 100644 --- a/platform/chromium/vapi-background.js +++ b/platform/chromium/vapi-background.js @@ -1446,12 +1446,9 @@ vAPI.cloud = (( ) => { deviceName: undefined, }; - const getDeviceName = function() { - if ( options.deviceName === undefined ) { - options.deviceName = vAPI.localStorage.getItem('deviceName') || ''; - } - return options.deviceName; - }; + vAPI.localStorage.getItemAsync('deviceName').then(value => { + options.deviceName = value; + }); // This is used to find out a rough count of how many chunks exists: // We "poll" at specific index in order to get a rough idea of how @@ -1499,7 +1496,7 @@ vAPI.cloud = (( ) => { const push = async function(dataKey, data) { let bin = { - 'source': getDeviceName() || options.defaultDeviceName, + 'source': options.deviceName || options.defaultDeviceName, 'tstamp': Date.now(), 'data': data, 'size': 0 @@ -1585,7 +1582,6 @@ vAPI.cloud = (( ) => { const getOptions = function(callback) { if ( typeof callback !== 'function' ) { return; } - getDeviceName(); callback(options); };