-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Factor out storage calls to new Storage module. Update ranges when mo…
…dified by other tabs (#51)
- Loading branch information
1 parent
4e69fa1
commit 5c04666
Showing
3 changed files
with
72 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict'; | ||
|
||
export const AREA_NAME = 'local'; | ||
|
||
//IDEA: best is to have a framework where we bind a runtime variable to a storage key | ||
//Storage.bind(localVar, storageKey); | ||
//bindMap[key] = Array() | ||
//bindMap['rangeMin'] = [''] | ||
// for(const i of bindMap){ | ||
// for(const j in bindMap[i]) | ||
// } | ||
|
||
|
||
export function saveTrack(trackId, min, max) { | ||
let trackValues = { | ||
min: min, | ||
max: max | ||
}; | ||
console.log("DEBUG SAVE TRACK! " + trackId + " " + min + " " + max); | ||
let item = {}; | ||
item[trackId] = trackValues; | ||
chrome.storage.local.set(item, function () { | ||
console.log('SAVE TRACK Value for ' + trackId + ' is set to ' + trackValues.min + " " + trackValues.max); | ||
}); | ||
} | ||
|
||
export function getTrack(trackId) { | ||
return new Promise((resolve, reject) => { | ||
chrome.storage.local.get(trackId, function (trackValues) { | ||
if (chrome.runtime.lastError === undefined) { | ||
console.log("DEBUG GOT VALUES " + trackId + " trackValues[trackId]=" + trackValues[trackId]); | ||
resolve(trackValues[trackId]); | ||
} else { | ||
reject(); | ||
} | ||
}); | ||
}); | ||
} |