Skip to content

Commit

Permalink
#56 add: pagination settings storage
Browse files Browse the repository at this point in the history
  • Loading branch information
pbek committed Jan 29, 2024
1 parent 79a374c commit 9b8c8ad
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions src/pages/PopupPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
:columns="columns"
:loading="loadingBookmarks"
row-key="name"
v-model:pagination="pagination"
class="bookmark-list"
>
<template v-slot:body="props">
Expand Down Expand Up @@ -135,6 +136,13 @@ export default defineComponent({
let selectedNoteFolderIdWatchEnabled = true;
let addBookmarkDialog = ref(false);
const bookmarkEditDialog = ref(false);
const pagination = ref({
sortBy: 'name',
descending: false,
page: 1,
rowsPerPage: 10,
initialSetup: true
});
const editedBookmark = reactive({
name: '',
url: '',
Expand All @@ -145,9 +153,6 @@ export default defineComponent({
url: '',
description: ''
});
const tableOptions = reactive({
itemsPerPage: 10
});
let selectedTags = ref([]);
let webSocket = ref(new QWebSocket());
const snackbar = ref(false);
Expand Down Expand Up @@ -274,8 +279,10 @@ export default defineComponent({
chrome.storage.sync.get((data) => {
// console.log("after load");
// console.log(that.tableOptions.page);
// tableOptions.page = data.tableOptions.page;
console.log("data.pagination", data.pagination);
pagination.value = data.pagination;
pagination.value.page = 1;
let localSelectedTags = [];
const tags = allTags.value;
const dataSelectedTags = Object.values(data.selectedTags || []);
Expand Down Expand Up @@ -327,6 +334,19 @@ export default defineComponent({
});
});
watch(pagination, (newPagination, oldPagination) => {
// Ignore the first change of pagination, because it was done by the reference initialization
if (newPagination.initialSetup) {
newPagination.initialSetup = false;
return;
}
chrome.storage.sync.set({
pagination: newPagination
});
// console.log("newPagination", newPagination);
});
watch(search, (newSearch, oldSearch) => {
chrome.storage.sync.set({ search: newSearch });
});
Expand Down Expand Up @@ -364,7 +384,7 @@ export default defineComponent({
onBookmarkStored,
editedBookmark,
defaultBookmark,
tableOptions,
pagination,
selectedTags,
webSocket,
snackbar,
Expand Down

0 comments on commit 9b8c8ad

Please sign in to comment.