diff --git a/src/components/app.jsx b/src/components/app.jsx index 6f6f938..793bc76 100644 --- a/src/components/app.jsx +++ b/src/components/app.jsx @@ -206,6 +206,9 @@ export default class App extends Component { // For web app environment we don't fetch item from localStorage, // because the item isn't stored in the localStorage. if (lastCode.id && window.IS_EXTENSION) { + // In case of already saved item (with id), we fetch it from + // its real key instead of using `code` for better reliability. + // because `code` sets only on shady unloadbefore. db.local.get(lastCode.id, itemResult => { if (itemResult[lastCode.id]) { log('Load item ', lastCode.id); @@ -466,6 +469,7 @@ export default class App extends Component { /** * Fetches all items from storage * @param {boolean} shouldSaveGlobally Whether to store the fetched items in global arr for later use. + * @param {boolean} shouldFetchLocally Intentionally get local items. Used when importing local items to account. * @return {promise} Promise. */ async fetchItems(shouldSaveGlobally, shouldFetchLocally) { diff --git a/src/itemService.js b/src/itemService.js index c8e0647..e657b7e 100644 --- a/src/itemService.js +++ b/src/itemService.js @@ -11,6 +11,11 @@ export const itemService = { return doc.data(); }); }, + + /** + * Fetches user's item id list. CURRENTLY RUNS ONLY + * FOR LOGGED IN USER!! + */ async getUserItemIds() { if (window.user) { return new Promise(resolve => { @@ -29,6 +34,10 @@ export const itemService = { }); }, + /** + * Fetches all items FROM REMOTE ONLY CURRENTLY!! + * TODO: make it work for local too. + */ async getAllItems() { var t = Date.now(); var d = deferred();