fix: graph changing
This commit is contained in:
parent
a09596c24d
commit
20dea0661c
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "logseq-plugin-favorite-tree",
|
||||
"version": "1.1.1",
|
||||
"version": "1.1.2",
|
||||
"main": "dist/index.html",
|
||||
"logseq": {
|
||||
"id": "_sethyuan-logseq-favorite-tree",
|
||||
|
||||
6
src/global.d.ts
vendored
6
src/global.d.ts
vendored
@ -1,3 +1,7 @@
|
||||
declare global {}
|
||||
import type { IAsyncStorage } from "@logseq/libs/dist/modules/LSPlugin.Storage"
|
||||
|
||||
declare global {
|
||||
const storage: IAsyncStorage
|
||||
}
|
||||
|
||||
export {}
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
const storage = logseq.Assets.makeSandboxStorage()
|
||||
|
||||
export async function readExpansionState(key: string, readKeys?: Set<string>) {
|
||||
const graphKey = await getGraphKey(key)
|
||||
readKeys?.add(graphKey)
|
||||
@ -40,6 +38,7 @@ export async function writeExpansionState(
|
||||
|
||||
export async function allExpansionKeys() {
|
||||
const keys = await storage.allKeys()
|
||||
if (keys == null) return []
|
||||
return keys
|
||||
.filter((key) => key.startsWith("expansion-"))
|
||||
.map((key) =>
|
||||
|
||||
@ -68,7 +68,10 @@ async function main() {
|
||||
if (mutation?.target == null) return
|
||||
const target = mutation.target as HTMLElement
|
||||
|
||||
if (target.classList?.contains("nav-content-item-inner")) {
|
||||
if (
|
||||
target.classList?.contains("nav-content-item-inner") ||
|
||||
target.classList?.contains("favorites")
|
||||
) {
|
||||
await processFavorites()
|
||||
}
|
||||
})
|
||||
@ -79,9 +82,13 @@ async function main() {
|
||||
|
||||
const transactionOff = logseq.DB.onChanged(onTransaction)
|
||||
|
||||
const graphOff = logseq.App.onCurrentGraphChanged(adjustLeftBarWidth)
|
||||
const graphOff = logseq.App.onCurrentGraphChanged(async () => {
|
||||
;(window as any).storage = logseq.Assets.makeSandboxStorage()
|
||||
await adjustLeftBarWidth()
|
||||
})
|
||||
|
||||
await waitForEl("#left-sidebar .favorite-item", 1000)
|
||||
;(window as any).storage = logseq.Assets.makeSandboxStorage()
|
||||
|
||||
const readKeys = new Set<string>()
|
||||
await processFavorites(readKeys)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user