Skip to content

Commit

Permalink
TAB-484 savepoint
Browse files Browse the repository at this point in the history
  • Loading branch information
evandor committed Feb 7, 2024
1 parent 43c96c1 commit a2dcf89
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
22 changes: 9 additions & 13 deletions src/components/helper/SidePanelWindowMarkupTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<!-- v-model="windowsToOpen" :options="windowsToOpenOptions" label="Open..."/>-->
<span class="text-grey-8 cursor-pointer"><q-icon name="open_in_new" color="primary" class="q-mr-xs"/>Open Window </span>
<q-menu :offset="[0, 7]" fit>
<q-list dense>
<q-list dense style="min-width: 250px">
<q-item clickable v-close-popup v-for="w in windowsToOpenOptions">
<q-item-section @click="openNewWindow(w)">{{ w['label' as keyof object] }}</q-item-section>
</q-item>
Expand All @@ -40,16 +40,12 @@
@dblclick.stop="openRenameWindowDialog(row['id' as keyof object], row['name' as keyof object], row['index' as keyof object])"
@click.prevent.stop="openWindow(row['id' as keyof object])">
<q-icon v-if="rows.length > 1" name="drag_indicator" class="q-mr-sm" style="cursor:move">
<q-tooltip>{{ row['index' as keyof object]}}</q-tooltip>
<q-tooltip class="tooltip-small" v-if="useSettingsStore().isEnabled('dev')">{{ row['index' as keyof object]}}</q-tooltip>
</q-icon>
<span class="cursor-pointer" :data-testid="'windowDataColumn_name_' + row['id' as keyof object]">{{ row['name' as keyof object] }}</span>
<!-- <q-popup-edit v-model="row['name' as keyof object]"-->
<!-- @save="(val:string, initial:string) => setWindowName(row, val)"-->
<!-- v-slot="scope">-->
<!-- <q-input v-model="scope.value"-->
<!-- dense autofocus counter-->
<!-- @keyup.enter="scope.set"/>-->
<!-- </q-popup-edit>-->
<span class="cursor-pointer" :data-testid="'windowDataColumn_name_' + row['id' as keyof object]">
{{ row['name' as keyof object] }}
<q-tooltip class="tooltip-small" v-if="useSettingsStore().isEnabled('dev')">{{ row['id' as keyof object]}}</q-tooltip>
</span>

</td>
<td :data-testid="'windowDataColumn_tabsCount_' + row['id' as keyof object]">
Expand Down Expand Up @@ -128,6 +124,7 @@ import AppService from "src/services/AppService";
import {useNotificationHandler} from "src/services/ErrorHandler";
import ExportDialog from "components/dialogues/ExportDialog.vue";
import RenameWindowDialog from "components/dialogues/RenameWindowDialog.vue";
import {useSettingsStore} from "stores/settingsStore";
const {handleError} = useNotificationHandler()
const {sendMsg} = useUtils()
Expand All @@ -144,10 +141,9 @@ const hoveredWindow = ref<number | undefined>(undefined)
const windowsUpdatedListener = (message: any, sender: chrome.runtime.MessageSender, sendResponse: any) => {
if (message.name === 'window-updated') {
console.log("got message 'window-updated'", message.data.initiated, message)
// useWindowsStore().setup('got window-updated message')
// .then(() => rows.value = calcWindowRows())
useWindowsStore().setup('got window-updated message', true)
.then(() => rows.value = calcWindowRows())
//useUiStore().windowsChanged = message
rows.value = calcWindowRows()
}
return true
}
Expand Down
4 changes: 2 additions & 2 deletions src/services/IndexedDbPersistenceService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ class IndexedDbPersistenceService implements PersistenceService {
}

async updateWindow(window: Window): Promise<void> {
console.log(`updating window id=${window.id}, title=${window.title}, index=${window.index}, #hostList=${window.hostList.length}`)
console.debug(`updating window id=${window.id}, title=${window.title}, index=${window.index}, #hostList=${window.hostList.length}`)
if (!window.id) {
return Promise.reject("window.id not set")
}
Expand All @@ -616,7 +616,7 @@ class IndexedDbPersistenceService implements PersistenceService {
asJson['hostList'] = Array.from(window.hostList)

delete asJson['tabs']
console.log("saving window json as ", asJson)
console.debug("saving window json as ", asJson)
await this.db.put('windows', asJson, window.id)
}

Expand Down
14 changes: 8 additions & 6 deletions src/stores/windowsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const useWindowsStore = defineStore('windows', () => {
await setup("initialization")
}

async function setup(trigger: string = "") {
async function setup(trigger: string = "", keepWindowsFromStorage = false) {
if (!inBexMode()) {
return
}
Expand All @@ -91,11 +91,13 @@ export const useWindowsStore = defineStore('windows', () => {
currentChromeWindows.value = browserWindows
console.debug(` initializing current chrome windows with ${currentChromeWindows.value.length} window(s)`)

// adding potentially new windows to storage - adding windows will not do anything if the key already exists
for (const browserWindow of browserWindows) {
const hostList = calcHostList(browserWindow.tabs || [])
const newWindow = new Window(browserWindow.id || 0, browserWindow, undefined, 0, false, hostList)
await storage.addWindow(newWindow)
if (!keepWindowsFromStorage) {
// adding potentially new windows to storage
for (const browserWindow of browserWindows) {
const hostList = calcHostList(browserWindow.tabs || [])
const newWindow = new Window(browserWindow.id || 0, browserWindow, undefined, 0, false, hostList)
await storage.addWindow(newWindow)
}
}

// setting all (new and older) windows to 'allWindows':
Expand Down

0 comments on commit a2dcf89

Please sign in to comment.