Skip to content

Commit

Permalink
enh(bookmarks folder selection): Select sub folder in Vivaldi
Browse files Browse the repository at this point in the history
fixes #1524

Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Jan 27, 2024
1 parent 5657862 commit bf20689
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/lib/browser/BrowserDetection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import browser from '../browser-api'

export const isVivaldi = async() => {
const tabs = await browser.tabs.query({ active: true, currentWindow: true });
return Boolean(tabs?.[0]?.['vivExtData'])
}
4 changes: 3 additions & 1 deletion src/lib/browser/BrowserTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Ordering from '../interfaces/Ordering'
import url from 'url'
import random from 'random'
import seedrandom from 'seedrandom'
import { isVivaldi } from './BrowserDetection'

let absoluteRoot: {id: string}

Expand All @@ -29,6 +30,7 @@ export default class BrowserTree implements IResource {
}

async getBookmarksTree():Promise<Folder> {
const isVivaldiBrowser = await isVivaldi()
const [tree] = await browser.bookmarks.getSubTree(this.rootId)
await this.absoluteRootPromise
const allAccounts = await (await Account.getAccountClass()).getAllAccounts()
Expand All @@ -43,7 +45,7 @@ export default class BrowserTree implements IResource {
return
}
let overrideTitle, isRoot
if (node.parentId === this.absoluteRoot.id) {
if (node.parentId === this.absoluteRoot.id && !isVivaldiBrowser) {
switch (node.id) {
case '1': // Chrome
case 'toolbar_____': // Firefox
Expand Down
4 changes: 3 additions & 1 deletion src/ui/components/OptionSyncFolder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
</template>

<script>
import { isVivaldi } from '../../lib/browser/BrowserDetection'
export default {
name: 'OptionSyncFolder',
props: { value: { type: String, default: undefined } },
Expand Down Expand Up @@ -137,7 +139,7 @@ export default {
const browser = (await import('../../lib/browser-api')).default
this.selectedLocalRoot = this.value
this.finder = true
this.folders = this.filterOutBookmarks(await browser.bookmarks.getTree())
this.folders = this.filterOutBookmarks(await isVivaldi() ? await browser.bookmarks.getSubTree('1') : await browser.bookmarks.getTree())
},
filterOutBookmarks(children) {
return children.filter(item => {
Expand Down

0 comments on commit bf20689

Please sign in to comment.