Skip to content

Commit

Permalink
#70 add: switch to hide bookmarks of current note
Browse files Browse the repository at this point in the history
Signed-off-by: Patrizio Bekerle <patrizio@bekerle.com>
  • Loading branch information
pbek committed Dec 27, 2024
1 parent 2f8e2f7 commit c6caba1
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
## 2024.12.0
- The private mode switch got moved to the drawer menu, so it doesn't take up space in the popup anymore
(for [#76](https://github.com/qownnotes/web-companion/issues/76))
- There now is a new switch in the drawer menu to **hide bookmarks from the current note**
(for [#70](https://github.com/qownnotes/web-companion/issues/70))
- Bookmarks can still contain the 'Current' tag, for example if the current note is a bookmark note
- This feature needs QOwnNotes 24.12.7 or higher

## 2024.8.0
- bookmarks can now be edited in the bookmarks list (for [#65](https://github.com/qownnotes/web-companion/issues/65))
Expand Down
6 changes: 6 additions & 0 deletions src-bex/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,11 @@
},
"PrivateModeTooltip": {
"message": "Open bookmarks in private browser window"
},
"HideCurrent": {
"message": "Hide bookmarks from current note"
},
"HideCurrentTooltip": {
"message": "Bookmarks can still contain the 'Current' tag, for example if the current note is a bookmark note"
}
}
21 changes: 21 additions & 0 deletions src/components/PopupDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@
</q-toggle></q-item-label>
</q-item-section>
</q-item>
<q-separator />
<q-item>
<q-item-section>
<q-item-label><q-toggle
v-model="hideCurrent"
:label="getLocale('HideCurrent')"
>
<q-tooltip class="bg-accent">{{ getLocale('HideCurrentTooltip') }}</q-tooltip>
</q-toggle></q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-drawer>
</template>
Expand Down Expand Up @@ -68,9 +79,12 @@ export default defineComponent({
setup(prop, { emit }) {
const leftDrawerOpen = ref(prop.model);
const privateMode = ref(false)
const hideCurrent = ref(false)
onMounted(() => {
chrome.storage.sync.get((data) => {
privateMode.value = data.privateMode || false;
hideCurrent.value = data.hideCurrent || false;
});
});
Expand All @@ -79,20 +93,27 @@ export default defineComponent({
emit('privateModeChanged', value);
});
watch(hideCurrent, (value) => {
chrome.storage.sync.set({ hideCurrent: value });
emit('hideCurrentChanged', value);
});
const importBrowserBookmarksClicked = () => {
emit('importBrowserBookmarksClicked');
};
// Return variables and methods that you want to expose to the template
return {
privateMode,
hideCurrent,
leftDrawerOpen,
linksList,
importBrowserBookmarksClicked
};
},
emits: [
'importBrowserBookmarksClicked',
'hideCurrentChanged',
'privateModeChanged'
]
})
Expand Down
16 changes: 12 additions & 4 deletions src/pages/PopupPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<PopupDrawer
v-model="leftDrawerOpen"
@importBrowserBookmarksClicked="importBrowserBookmarksDialog = true;"
@hideCurrentChanged="onHideCurrentChanged"
@privateModeChanged="onPrivateModeChanged"
/>
<q-page-container>
Expand Down Expand Up @@ -196,6 +197,7 @@ export default defineComponent({
const $q = useQuasar();
const leftDrawerOpen = ref(false)
const privateMode = ref(false)
const hideCurrent = ref(false)
let bookmarks = ref([]);
let loadingBookmarks = ref(false);
let search = ref('');
Expand Down Expand Up @@ -338,6 +340,10 @@ export default defineComponent({
loadBookmarks();
};
const onHideCurrentChanged = (value) => {
hideCurrent.value = value;
loadBookmarks();
}
const onPrivateModeChanged = (value) => {
privateMode.value = value;
Expand Down Expand Up @@ -384,6 +390,8 @@ export default defineComponent({
chrome.storage.sync.get((data) => {
search.value = data.search || '';
privateMode.value = data.privateMode || false;
hideCurrent.value = data.hideCurrent || false;
loadBookmarks();
// Select the text in the search input field after it was updated by the data from the storage
nextTick(() => searchInput.value.select());
Expand Down Expand Up @@ -445,8 +453,6 @@ export default defineComponent({
}
});
loadBookmarks();
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
defaultBookmark.name = tabs[0].title;
editedBookmark.name = tabs[0].title;
Expand All @@ -461,7 +467,7 @@ export default defineComponent({
}
loadingBookmarks.value = true;
const data = {type: "switchNoteFolder", data: newFolderId};
const data = {type: "switchNoteFolder", data: newFolderId, hideCurrent: hideCurrent.value};
webSocket.value.send(data, function () {
console.log("Switching to note folder:" + data);
});
Expand Down Expand Up @@ -493,7 +499,7 @@ export default defineComponent({
const loadBookmarks = () => {
loadingBookmarks.value = true;
const data = {type: "getBookmarks"};
const data = {type: "getBookmarks", hideCurrent: hideCurrent.value};
webSocket.value.send(data, function () {
console.log("Loading bookmarks:" + data);
});
Expand All @@ -511,6 +517,7 @@ export default defineComponent({
return {
leftDrawerOpen,
privateMode,
hideCurrent,
toggleLeftDrawer,
columns,
bookmarks,
Expand All @@ -527,6 +534,7 @@ export default defineComponent({
onBookmarkEdited,
onBookmarksStored,
onBookmarksImported,
onHideCurrentChanged,
onPrivateModeChanged,
editedBookmark,
editBookmarkMarkdown,
Expand Down

0 comments on commit c6caba1

Please sign in to comment.