From f2acabfabb31196e85b41863780b4480b144845e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20=C3=96dman?= Date: Fri, 22 Jan 2021 09:10:18 +0100 Subject: [PATCH] Fixed new install bug --- src/models/interfaces.ts | 1 - src/services/helpers.ts | 11 +++++++---- src/services/scrape-service.ts | 1 - src/thumbnails.ts | 4 ---- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/models/interfaces.ts b/src/models/interfaces.ts index dd71a2f..68842e7 100644 --- a/src/models/interfaces.ts +++ b/src/models/interfaces.ts @@ -31,7 +31,6 @@ export interface ThumbnailSettingsState { showVotes: boolean; infiniteScroll: boolean; isExtensionActive: boolean; - settingsInitiatedFromPopup: boolean; } export interface FilterOptions { diff --git a/src/services/helpers.ts b/src/services/helpers.ts index 8879ffc..61d83ff 100644 --- a/src/services/helpers.ts +++ b/src/services/helpers.ts @@ -10,12 +10,15 @@ export async function loadStorageSettings() { showVotes: false, sorting: SortingOrder.Standard, infiniteScroll: false, - isExtensionActive: false, - settingsInitiatedFromPopup: false, + isExtensionActive: true, }; const settings = await getThumbnailSettingsStateFromStorage(); + if (!settings) { + setThumbnailSettingsStateToStorage(initialSettings); + } + let updated = false; Object.keys(initialSettings).forEach((key) => { if (settings[key] == null) { @@ -24,8 +27,8 @@ export async function loadStorageSettings() { } }); - if (!settings || updated) { - setThumbnailSettingsStateToStorage(initialSettings); + if (updated) { + setThumbnailSettingsStateToStorage(settings); } } diff --git a/src/services/scrape-service.ts b/src/services/scrape-service.ts index c631600..bcdf5e6 100644 --- a/src/services/scrape-service.ts +++ b/src/services/scrape-service.ts @@ -3,7 +3,6 @@ import { getDayAfter, getDayBefore, insertAfter } from "./helpers"; import { getArticleStateFromStorage, getExtraArticleStateFromStorage, - getThumbnailSettingsStateFromStorage, setArticleStateToStorage, setExtraArticleStateToStorage, } from "./storage-service"; diff --git a/src/thumbnails.ts b/src/thumbnails.ts index fad5334..4349079 100644 --- a/src/thumbnails.ts +++ b/src/thumbnails.ts @@ -17,7 +17,6 @@ import { setArticleStateToStorage, setExtraArticleStateToStorage, setInitialHtmlState, - setThumbnailSettingsStateToStorage, } from "./services/storage-service"; import { ArticleState, FilterOptions } from "./models/interfaces"; import { SortingOrder } from "./models/enums"; @@ -36,9 +35,6 @@ import { getNextPage } from "./services/scrape-service"; await initializeThumbnailsPage(); })(); -// when button is clicked in plugin menu -chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {}); - async function changeBackToDisabledExtension() { const html = await getInitialHtmlState(); document.querySelector("body").innerHTML = html;