diff --git a/src/App.vue b/src/App.vue index bbbaa8fe..761a4e0f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -15,14 +15,10 @@ import {useAppStore} from "stores/appStore"; const $q = useQuasar() const router = useRouter() -const route = useRoute() - -const {handleError} = useNotificationHandler() const settingsStore = useSettingsStore() settingsStore.initialize($q.localStorage) -//const localMode = settingsStore.isEnabled('localMode') -//console.log(` ...config: localMode=${localMode}`) +console.log("") useAppStore().init() diff --git a/src/app/AppService.ts b/src/app/AppService.ts index aae67382..0b5c2698 100644 --- a/src/app/AppService.ts +++ b/src/app/AppService.ts @@ -41,7 +41,7 @@ class AppService { async init(quasar: any, router: Router, forceRestart = false) { - console.log(`%cinitializing AppService: first start=${!this.initialized}, forceRestart=${forceRestart}, quasar set=${quasar !== undefined}, router set=${router !== undefined}`, forceRestart ? "font-weight:bold" : "") + console.log(`%cinitializing AppService: first start=${!this.initialized}, forceRestart=${forceRestart}, router set=${router !== undefined}`,"font-weight:bold") if (this.initialized && !forceRestart) { console.debug("stopping AppService initialization; already initialized and not forcing restart") @@ -61,20 +61,16 @@ class AppService { useAppStore().init() - // init of stores and some listeners - // await usePermissionsStore().initialize(useDB(quasar).localDb) - - await ChromeListeners.initListeners() + console.debug('') // Bookmarks ChromeBookmarkListeners.initListeners() - await useBookmarksStore().init() + + useBookmarksStore().init() await BookmarksService.init() console.debug('') - //settingsStore.initialize(quasar.localStorage); - // Snapshots await useSnapshotsStore().initialize(useDB().snapshotsDb) await useSnapshotsService().init() @@ -82,16 +78,22 @@ class AppService { // should be initialized before search submodule await useThumbnailsService().init(useDB().thumbnailsDb) + console.debug('') + await useContentService().init(IndexedDbContentPersistence) console.debug('') await useSearchStore().init().catch((err:any) => console.error(err)) + console.debug('') // init db await IndexedDbPersistenceService.init("db") + console.log("") // init services await useNotificationsStore().initialize(useDB(undefined).db) + console.log("") + await useSuggestionsStore().init() console.debug('') @@ -125,10 +127,11 @@ class AppService { console.log(`%cinitializing AppService: initCoreSerivces`, "font-weight:bold") - // if (useFeaturesStore().hasFeature(FeatureIdent.WINDOWS_MANAGEMENT)) { - await useWindowsStore().initialize() - useWindowsStore().initListeners() - // } + await useWindowsStore().initialize() + console.debug("") + + useWindowsStore().initListeners() + console.debug("") /** * features store: passing storage for better testing. @@ -136,6 +139,7 @@ class AppService { */ const featuresStorage = useDB(quasar).featuresDb await useFeaturesStore().initialize(featuresStorage) + console.debug("") await useNotesStore().initialize(useDB().notesDb) console.debug('') diff --git a/src/app/BrowserApi.ts b/src/app/BrowserApi.ts index a45147d9..650b9eb4 100644 --- a/src/app/BrowserApi.ts +++ b/src/app/BrowserApi.ts @@ -19,8 +19,6 @@ function runHousekeeping() { console.log("housekeeping now...") - persistenceService.cleanUpTabsets() - persistenceService.cleanUpRequests() persistenceService.cleanUpMetaLinks() @@ -104,10 +102,10 @@ class BrowserApi { return } if (chrome && chrome.contextMenus) { - console.log("chrome.contextMenus", chrome.contextMenus) + //console.log("chrome.contextMenus", chrome.contextMenus) chrome.contextMenus.removeAll( () => { - console.debug("creating contextmenu for tabset_extension") + console.debug(" ...creating contextmenu for tabset_extension") chrome.contextMenus.create({ id: 'tabset_extension', title: 'Tabsets Extension', @@ -140,7 +138,7 @@ class BrowserApi { // contexts: ['all'] // }) //} - console.debug(" > context menu: save_to_currentTS") + // console.debug(" > context menu: save_to_currentTS") chrome.contextMenus.create({ id: 'save_to_currentTS', parentId: 'tabset_extension', @@ -162,17 +160,17 @@ class BrowserApi { // rest of logic in windowsStore } - if (useFeaturesStore().hasFeature(FeatureIdent.ANNOTATIONS)) { - console.debug(" > context menu: annotate_website") - chrome.contextMenus.create({ - id: 'annotate_website', - parentId: 'tabset_extension', - title: 'Annotate', - documentUrlPatterns: ['https://*/*', 'https://*/'], - contexts: ['all'] - }) - } - console.debug(` > context menu: save_as_tabset for ${useTabsetsStore().tabsets.size} tabset(s)`) + // if (useFeaturesStore().hasFeature(FeatureIdent.ANNOTATIONS)) { + // console.debug(" > context menu: annotate_website") + // chrome.contextMenus.create({ + // id: 'annotate_website', + // parentId: 'tabset_extension', + // title: 'Annotate', + // documentUrlPatterns: ['https://*/*', 'https://*/'], + // contexts: ['all'] + // }) + // } + //console.debug(` > context menu: save_as_tabset for ${useTabsetsStore().tabsets.size} tabset(s)`) const allTabsets = [...useTabsetsStore().tabsets.values()] as Tabset[] if (allTabsets.length > 0) { diff --git a/src/bookmarks b/src/bookmarks index 1a3e7263..481342af 160000 --- a/src/bookmarks +++ b/src/bookmarks @@ -1 +1 @@ -Subproject commit 1a3e7263e689f1c2b3a6310b6edabb6f19022ecb +Subproject commit 481342afcdb242cf91e1a7c95cc419363e049407 diff --git a/src/core b/src/core index 8e492664..b2e0e8a6 160000 --- a/src/core +++ b/src/core @@ -1 +1 @@ -Subproject commit 8e4926648212e1d8553eeb99db4d251e2c80277a +Subproject commit b2e0e8a6cea567a5ba9971d3b76b8f4c93aab3b3 diff --git a/src/features b/src/features index 82617466..034c9d0d 160000 --- a/src/features +++ b/src/features @@ -1 +1 @@ -Subproject commit 82617466aeeb432e909c51177b1357d06e7d1b5e +Subproject commit 034c9d0d38a64dba22d1ca98140829e4c1eb5024 diff --git a/src/pages/helper/FeatureToggleSettings.vue b/src/pages/helper/FeatureToggleSettings.vue index de17c103..acb53267 100644 --- a/src/pages/helper/FeatureToggleSettings.vue +++ b/src/pages/helper/FeatureToggleSettings.vue @@ -61,9 +61,9 @@ import {ref, watchEffect} from "vue"; import {useSettingsStore} from "stores/settingsStore"; import {useCommandExecutor} from "src/core/services/CommandExecutor"; -import {ActivateFeatureCommand} from "src/features/commands/ActivateFeature"; +import {ActivateFeatureCommand} from "src/features/commands/ActivateFeatureCommand"; import {FeatureIdent} from "src/app/models/FeatureIdent"; -import {DeactivateFeatureCommand} from "src/features/commands/DeactivateFeature"; +import {DeactivateFeatureCommand} from "src/features/commands/DeactivateFeatureCommand"; import {useFeaturesStore} from "src/features/stores/featuresStore"; import {useNotificationHandler} from "src/core/services/ErrorHandler"; import { diff --git a/src/pages/sidepanel/WelcomePage.vue b/src/pages/sidepanel/WelcomePage.vue index 34c89b1c..cbadf226 100644 --- a/src/pages/sidepanel/WelcomePage.vue +++ b/src/pages/sidepanel/WelcomePage.vue @@ -88,8 +88,6 @@ const router = useRouter() const tabsetName = ref('') const tabsetNameRef = ref(null as unknown as HTMLInputElement) const windowLocation = ref('---') -const activateNotifications = ref(false) -const activateFullPageApp = ref(false) const login = ref(false) @@ -99,32 +97,20 @@ onMounted(() => { LocalStorage.set(TITLE_IDENT, 'Tabsets' + stageIdentifier()) }) -watchEffect(async () => { - const feature = new AppFeatures().getFeature(FeatureIdent.NOTIFICATIONS) - // if (activateNotifications.value && feature) { - // const res = await useCommandExecutor().execute(new GrantPermissionCommand('notifications')) - // if (!res.result) { - // activateNotifications.value = false - // } - // } else if (!activateNotifications.value && feature) { - // useFeaturesStore().deactivateFeature('notifications') - // } -}) - -function setFeature(featureIdent: FeatureIdent, val: UnwrapRef) { - const feature = new AppFeatures().getFeature(featureIdent) - if (val && feature) { - console.log("activating", featureIdent) - useFeaturesStore().activateFeature(featureIdent.toLowerCase()) - } else if (!val && feature) { - console.log("deactivateing", featureIdent) - useFeaturesStore().deactivateFeature(featureIdent.toLowerCase()) - } -} - -watchEffect(async () => { - setFeature(FeatureIdent.STANDALONE_APP, activateFullPageApp.value) -}) +// function setFeature(featureIdent: FeatureIdent, val: UnwrapRef) { +// const feature = new AppFeatures().getFeature(featureIdent) +// if (val && feature) { +// console.log("activating", featureIdent) +// useFeaturesStore().activateFeature(featureIdent.toLowerCase()) +// } else if (!val && feature) { +// console.log("deactivateing", featureIdent) +// useFeaturesStore().deactivateFeature(featureIdent.toLowerCase()) +// } +// } + +// watchEffect(async () => { +// setFeature(FeatureIdent.STANDALONE_APP, activateFullPageApp.value) +// }) watchEffect(() => { useUiStore().showLoginTable = login.value @@ -142,7 +128,7 @@ watchEffect(() => { const addFirstTabset = () => { useCommandExecutor() .executeFromUi(new CreateTabsetCommand(tabsetName.value, [])) - .then((res) => { + .then((res:any) => { useUiStore().sidePanelSetActiveView(SidePanelViews.MAIN) router.push("/sidepanel?first=true") }) diff --git a/src/services/ChromeBookmarkListeners.ts b/src/services/ChromeBookmarkListeners.ts index bc645f55..63a9a283 100644 --- a/src/services/ChromeBookmarkListeners.ts +++ b/src/services/ChromeBookmarkListeners.ts @@ -17,7 +17,8 @@ class ChromeBookmarkListeners { {permissions: ["bookmarks"]}, (res: boolean) => { if (res) { - console.debug(" ...init chrome bookmark listeners") + console.debug(" ...init chrome bookmark listeners (async)") + console.debug("") chrome.bookmarks.onCreated.addListener(this.onCreatedListener) chrome.bookmarks.onMoved.addListener(this.onMovedListener) chrome.bookmarks.onRemoved.addListener(this.onRemovedListener) diff --git a/src/services/IndexedDbPersistenceService.ts b/src/services/IndexedDbPersistenceService.ts index c19568a4..29d3a444 100644 --- a/src/services/IndexedDbPersistenceService.ts +++ b/src/services/IndexedDbPersistenceService.ts @@ -2,7 +2,6 @@ import {IDBPDatabase, openDB, deleteDB} from "idb"; import _ from "lodash"; import {EXPIRE_DATA_PERIOD_IN_MINUTES, INDEX_DB_VERSION} from "boot/constants"; import PersistenceService from "src/services/PersistenceService"; -import {Tabset, TabsetStatus} from "src/tabsets/models/Tabset"; import {MetaLink} from "src/models/MetaLink"; import {uid} from "quasar"; import {Notification, NotificationStatus} from "src/models/Notification"; @@ -12,6 +11,7 @@ import {RequestInfo} from "src/models/RequestInfo"; import {useSuggestionsStore} from "src/suggestions/stores/suggestionsStore"; import {useTabsetsStore} from "src/tabsets/stores/tabsetsStore"; +// Deprecated class IndexedDbPersistenceService implements PersistenceService { private db: IDBPDatabase = null as unknown as IDBPDatabase @@ -20,28 +20,29 @@ class IndexedDbPersistenceService implements PersistenceService { } async init(dbName: string) { - console.debug(" ...initializing indexeddb database", dbName) + // console.debug(" ...initializing indexeddb database", dbName) this.db = await this.initDatabase(dbName) useUiStore().dbReady = true } - async loadTabsets(): Promise { - console.debug(" ...loading tabsets indexeddb") - return await this.db.getAll('tabsets') - .then((res: any) => res.forEach((r: Tabset) => { - // make sure some fields are correctly initialized even for old(er) tabsets - if (!r.columns) { - r.columns = [] - } - delete r['groups' as keyof object] - //console.log("r", ['groups' as keyof object]) - useTabsetsStore().addTabset(r) - })) - } - - async saveTabset(tabset: Tabset): Promise { - return await this.db.put('tabsets', JSON.parse(JSON.stringify(tabset)), tabset.id); - } + // async loadTabsets(): Promise { + // debugger + // console.debug(" ...loading tabsets indexeddb") + // return await this.db.getAll('tabsets') + // .then((res: any) => res.forEach((r: Tabset) => { + // // make sure some fields are correctly initialized even for old(er) tabsets + // if (!r.columns) { + // r.columns = [] + // } + // delete r['groups' as keyof object] + // //console.log("r", ['groups' as keyof object]) + // useTabsetsStore().addTabset(r) + // })) + // } + // + // async saveTabset(tabset: Tabset): Promise { + // return await this.db.put('tabsets', JSON.parse(JSON.stringify(tabset)), tabset.id); + // } saveRequest(url: string, requestInfo: RequestInfo): Promise { const encodedTabUrl = btoa(url) @@ -124,17 +125,17 @@ class IndexedDbPersistenceService implements PersistenceService { return this.db.get('links', encodedUrl) } - async cleanUpTabsets(): Promise { - const objectStore = this.db.transaction("tabsets", "readwrite").objectStore("tabsets"); - let cursor = await objectStore.openCursor() - while (cursor) { - if (cursor.value.status === TabsetStatus.DELETED) { - console.log("cleanup: deleteing stale tabset", cursor.key) - objectStore.delete(cursor.key) - } - cursor = await cursor.continue(); - } - } + // async cleanUpTabsets(): Promise { + // const objectStore = this.db.transaction("tabsets", "readwrite").objectStore("tabsets"); + // let cursor = await objectStore.openCursor() + // while (cursor) { + // if (cursor.value.status === TabsetStatus.DELETED) { + // console.log("cleanup: deleteing stale tabset", cursor.key) + // objectStore.delete(cursor.key) + // } + // cursor = await cursor.continue(); + // } + // } async cleanUpRequests(): Promise { diff --git a/src/services/PersistenceService.ts b/src/services/PersistenceService.ts index b33183fc..0437565d 100644 --- a/src/services/PersistenceService.ts +++ b/src/services/PersistenceService.ts @@ -2,6 +2,7 @@ import {Notification} from "src/models/Notification"; import {MetaLink} from "src/models/MetaLink"; import {RequestInfo} from "src/models/RequestInfo"; +// Deprecated interface PersistenceService { getServiceName(): string diff --git a/src/stores/settingsStore.ts b/src/stores/settingsStore.ts index 581a6449..a82d45b1 100644 --- a/src/stores/settingsStore.ts +++ b/src/stores/settingsStore.ts @@ -27,7 +27,7 @@ export const useSettingsStore = defineStore('settings', () => { watch(thumbnailQuality, (val: Object) => localStorage.set("thumbnailQuality", val)) function initialize(localStorage: any) { - console.debug(" ...initializing settingsStore") + console.debug(" ...initializing settingsStore", '✅') const fts: string | undefined = localStorage.getItem("settings") if (fts) { console.debug(` ...determining activeToggles from '${fts}'`) diff --git a/src/tabsets b/src/tabsets index ad015663..4f6775ea 160000 --- a/src/tabsets +++ b/src/tabsets @@ -1 +1 @@ -Subproject commit ad015663169b6b07b5625f5797bc1b27c1872e3a +Subproject commit 4f6775eae90ab8c485d0c173e308cf43ead387ab diff --git a/test/vitest/__tests__/features/commands/ActivateFeature.test.ts b/test/vitest/__tests__/features/commands/ActivateFeature.test.ts index 3067d127..af5099db 100644 --- a/test/vitest/__tests__/features/commands/ActivateFeature.test.ts +++ b/test/vitest/__tests__/features/commands/ActivateFeature.test.ts @@ -4,7 +4,7 @@ import {createPinia, setActivePinia} from "pinia"; import IndexedDbPersistenceService from "src/services/IndexedDbPersistenceService"; import {useFeaturesStore} from "src/features/stores/featuresStore"; import InMemoryFeaturesPersistence from "src/features/persistence/InMemoryFeaturesPersistence"; -import {ActivateFeatureCommand} from "src/features/commands/ActivateFeature"; +import {ActivateFeatureCommand} from "src/features/commands/ActivateFeatureCommand"; import {AppFeatures} from "src/app/models/AppFeatures"; import {Feature} from "src/features/models/Feature"; import {FeatureIdent} from "src/app/models/FeatureIdent"; diff --git a/test/vitest/__tests__/features/commands/DeactivateFeature.test.ts b/test/vitest/__tests__/features/commands/DeactivateFeature.test.ts index 7e54abc4..dbc6deee 100644 --- a/test/vitest/__tests__/features/commands/DeactivateFeature.test.ts +++ b/test/vitest/__tests__/features/commands/DeactivateFeature.test.ts @@ -4,9 +4,9 @@ import {createPinia, setActivePinia} from "pinia"; import IndexedDbPersistenceService from "src/services/IndexedDbPersistenceService"; import {useFeaturesStore} from "src/features/stores/featuresStore"; import InMemoryFeaturesPersistence from "src/features/persistence/InMemoryFeaturesPersistence"; -import {ActivateFeatureCommand} from "src/features/commands/ActivateFeature"; +import {ActivateFeatureCommand} from "src/features/commands/ActivateFeatureCommand"; import {AppFeatures} from "src/app/models/AppFeatures"; -import {DeactivateFeatureCommand} from "src/features/commands/DeactivateFeature"; +import {DeactivateFeatureCommand} from "src/features/commands/DeactivateFeatureCommand"; import {Feature} from "src/features/models/Feature"; import {FeatureIdent} from "src/app/models/FeatureIdent";