Skip to content

Commit

Permalink
fix(sidebar): deletet outdated right sidebar toggler functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
yoyurec committed Oct 5, 2023
1 parent 0352f49 commit 5cf33d5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 48 deletions.
45 changes: 0 additions & 45 deletions src/modules/sidebars/sidebars.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,8 @@
import { doc, body } from '../globals/globals';

import './sidebars.css';

// Reposition right sidebar toggle button
export const rightSidebarLoad = () => {
const toggleRightSidebar = doc.querySelector('#right-sidebar .toggle-right-sidebar');
reorderRightSidebarToggleButton(toggleRightSidebar ? true : false);
// Listen sidebar update
logseq.App.onSidebarVisibleChanged(({visible}) => {
onSidebarVisibleChangedCallback(visible);
});
}

export const rightSidebarUnload = () => {
const hideRightSidebarButton = doc.querySelector('#head .hide-right-sidebar-button');
const rightToolbarPlaceholder = doc.querySelector('.cp__right-sidebar-topbar');
if (rightToolbarPlaceholder && hideRightSidebarButton) {
rightToolbarPlaceholder.insertAdjacentElement('beforeend', hideRightSidebarButton);
}}

export const reorderRightSidebarToggleButton = (visible: boolean) => {
if (visible) {
const hideRightSidebarButton = doc.querySelector('#right-sidebar .toggle-right-sidebar');
hideRightSidebarButton?.classList.add('hide-right-sidebar-button')
const headToolbar = doc.querySelector('#head .r');
if (headToolbar && hideRightSidebarButton) {
headToolbar.insertAdjacentElement('beforeend', hideRightSidebarButton);
}
} else {
doc.querySelector('#head .hide-right-sidebar-button')?.remove();
}
}

export const origRightSidebarToggleButton = (visible: boolean) => {
if (visible) {
const hideRightSidebarButton = doc.querySelector('#right-sidebar .toggle-right-sidebar');
const headToolbar = doc.querySelector('.cp__right-sidebar-topbar');
if (headToolbar && hideRightSidebarButton) {
headToolbar.insertAdjacentElement('beforeend', hideRightSidebarButton);
}
}// else {
// doc.querySelector('#head .hide-right-sidebar-button')?.remove();
// }
}

// Sidebar toggled
const onSidebarVisibleChangedCallback = (visible: boolean) => {
if (!body.classList.contains('is-awUi-enabled')) {
return;
}
reorderRightSidebarToggleButton(visible);
}
4 changes: 1 addition & 3 deletions src/plugin/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ const runStuff = () => {
tabsPositionToggle();
tabsStyleToggle();
vaultButtonToggle();
}, 2000);
setTimeout(() => {
rightSidebarLoad();
}, 3000)
}, 2000);
}

const stopStuff = () => {
Expand Down

0 comments on commit 5cf33d5

Please sign in to comment.