fix: adjust left bar's width when changing graph
This commit is contained in:
parent
97ee47707e
commit
181a307bcb
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "logseq-plugin-favorite-tree",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"main": "dist/index.html",
|
||||
"logseq": {
|
||||
"id": "_sethyuan-logseq-favorite-tree",
|
||||
|
||||
@ -79,16 +79,10 @@ async function main() {
|
||||
|
||||
const transactionOff = logseq.DB.onChanged(onTransaction)
|
||||
|
||||
await processFavorites()
|
||||
const graphOff = logseq.App.onCurrentGraphChanged(adjustLeftBarWidth)
|
||||
|
||||
const graph = (await logseq.App.getCurrentGraph())!
|
||||
const storedWidth = parent.localStorage.getItem(`kef-ft-lsw-${graph.name}`)
|
||||
if (storedWidth) {
|
||||
parent.document.documentElement.style.setProperty(
|
||||
"--ls-left-sidebar-width",
|
||||
`${+storedWidth}px`,
|
||||
)
|
||||
}
|
||||
await processFavorites()
|
||||
await adjustLeftBarWidth()
|
||||
|
||||
logseq.provideUI({
|
||||
key: "kef-ft-drag-handle",
|
||||
@ -103,6 +97,7 @@ async function main() {
|
||||
}, 0)
|
||||
|
||||
logseq.beforeunload(async () => {
|
||||
graphOff()
|
||||
transactionOff()
|
||||
favoritesObserver.disconnect()
|
||||
dragHandle?.removeEventListener("pointerdown", onPointerDown)
|
||||
@ -233,6 +228,17 @@ async function onTransaction({ blocks, txData, txMeta }: any) {
|
||||
}
|
||||
}
|
||||
|
||||
async function adjustLeftBarWidth() {
|
||||
const graph = (await logseq.App.getCurrentGraph())!
|
||||
const storedWidth = parent.localStorage.getItem(`kef-ft-lsw-${graph.name}`)
|
||||
if (storedWidth) {
|
||||
parent.document.documentElement.style.setProperty(
|
||||
"--ls-left-sidebar-width",
|
||||
`${+storedWidth}px`,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function needsProcessing(txData: any[]) {
|
||||
const hierarchyProperty = logseq.settings?.hierarchyProperty ?? "tags"
|
||||
let oldProperty, newProperty
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user