+
{{ t('bookmarks', 'Share link') }}
diff --git a/src/components/ViewPrivate.vue b/src/components/ViewPrivate.vue
index e6878609a..b0de9612a 100644
--- a/src/components/ViewPrivate.vue
+++ b/src/components/ViewPrivate.vue
@@ -213,6 +213,7 @@ export default {
this.$store.dispatch(actions.COUNT_BOOKMARKS, -1),
this.$store.dispatch(actions.COUNT_UNAVAILABLE),
this.$store.dispatch(actions.COUNT_ARCHIVED),
+ this.$store.dispatch(actions.COUNT_DELETED),
this.$store.dispatch(actions.COUNT_DUPLICATED),
this.$store.dispatch(actions.COUNT_ALL_CLICKS),
this.$store.dispatch(actions.COUNT_WITH_CLICKS),
@@ -234,6 +235,9 @@ export default {
error: reject,
}),
)
+ if (typeof resDocument.data !== 'undefined') {
+ return resDocument.data
+ }
if (resDocument.querySelector('status').textContent !== 'ok') {
console.error('Failed request', resDocument)
return
diff --git a/src/store/actions.js b/src/store/actions.js
index 061d25caa..950c72681 100644
--- a/src/store/actions.js
+++ b/src/store/actions.js
@@ -90,6 +90,7 @@ export const actions = {
LOAD_SHARED_FOLDERS: 'LOAD_SHARED_FOLDERS',
EMPTY_TRASHBIN: 'EMPTY_TRASHBIN',
+ COUNT_DELETED: 'COUNT_DELETED',
}
export default {
@@ -165,6 +166,38 @@ export default {
throw err
}
},
+ async [actions.COUNT_DELETED]({ commit, dispatch, state }) {
+ if (state.archivedCount === null) {
+ try {
+ const count = loadState('bookmarks', 'deletedCount')
+ return commit(mutations.SET_DELETED_COUNT, count)
+ } catch (e) {
+ console.warn(
+ 'Could not load initial deleted bookmarks count state, continuing with HTTP request',
+ )
+ }
+ }
+ try {
+ const response = await axios.get(url(state, '/bookmark/deletedCount'))
+ const {
+ data: { item: count, data, status },
+ } = response
+ if (status !== 'success') {
+ throw new Error(data)
+ }
+ commit(mutations.SET_DELETED_COUNT, count)
+ } catch (err) {
+ console.error(err)
+ commit(
+ mutations.SET_ERROR,
+ AppGlobal.methods.t(
+ 'bookmarks',
+ 'Failed to count deleted bookmarks',
+ ),
+ )
+ throw err
+ }
+ },
async [actions.COUNT_DUPLICATED]({ commit, dispatch, state }) {
if (state.duplicatedCount === null) {
try {
@@ -1204,6 +1237,7 @@ export default {
dispatch(actions.LOAD_TAGS)
dispatch(actions.COUNT_BOOKMARKS, -1)
dispatch(actions.COUNT_UNAVAILABLE)
+ dispatch(actions.COUNT_DELETED)
dispatch(actions.COUNT_ARCHIVED)
},
diff --git a/src/store/index.js b/src/store/index.js
index 1f57afd10..de11a78d7 100644
--- a/src/store/index.js
+++ b/src/store/index.js
@@ -68,6 +68,7 @@ export default {
unavailableCount: null,
archivedCount: null,
duplicatedCount: null,
+ deletedCount: null,
allClicksCount: 0,
withClicksCount: 0,
selection: {
diff --git a/src/store/mutations.js b/src/store/mutations.js
index 2beba0f9a..56d1dc096 100644
--- a/src/store/mutations.js
+++ b/src/store/mutations.js
@@ -55,6 +55,7 @@ export const mutations = {
CLICK_BOOKMARK: 'CLICK_BOOKMARK',
SET_WITH_CLICKS_COUNT: 'SET_WITH_CLICKS_COUNT',
EMPTY_TRASHBIN: 'EMPTY_TRASHBIN',
+ SET_DELETED_COUNT: 'SET_DELETED_COUNT',
}
export default {
[mutations.SET_AUTH_TOKEN](state, authToken) {
@@ -90,18 +91,25 @@ export default {
},
[mutations.MOVE_FOLDER](state, { folder, target }) {
const currentFolder = this.getters.getFolder(folder)[0]
- const oldParent = this.getters.getFolder(currentFolder.parent_folder)[0]
+ const oldParent = this.getters.getFolder(
+ currentFolder.parent_folder,
+ )[0]
const index = oldParent.children.indexOf(currentFolder)
oldParent.children.splice(index, 1)
const newParent = this.getters.getFolder(target)[0]
newParent.children.push(currentFolder)
if (state.childrenByFolder[oldParent.id]) {
- const index = state.childrenByFolder[oldParent.id].findIndex(item => item.id === currentFolder.id)
+ const index = state.childrenByFolder[oldParent.id].findIndex(
+ (item) => item.id === currentFolder.id,
+ )
state.childrenByFolder[oldParent.id].splice(index, 1)
}
if (state.childrenByFolder[newParent.id]) {
- state.childrenByFolder[newParent.id].push({ type: 'folder', id: currentFolder.id })
+ state.childrenByFolder[newParent.id].push({
+ type: 'folder',
+ id: currentFolder.id,
+ })
}
},
[mutations.ADD_TAG](state, tag) {
@@ -112,17 +120,25 @@ export default {
},
[mutations.RENAME_TAG](state, { oldName, newName }) {
state.bookmarks.forEach((bookmark) => {
- Vue.set(bookmark, 'tags', bookmark.tags.map((tag) => {
- if (tag === oldName) return newName
- return tag
- }))
+ Vue.set(
+ bookmark,
+ 'tags',
+ bookmark.tags.map((tag) => {
+ if (tag === oldName) return newName
+ return tag
+ }),
+ )
})
},
[mutations.REMOVE_TAG](state, oldTag) {
state.bookmarks.forEach((bookmark) => {
- Vue.set(bookmark, 'tags', bookmark.tags.filter((tag) => {
- return tag !== oldTag
- }))
+ Vue.set(
+ bookmark,
+ 'tags',
+ bookmark.tags.filter((tag) => {
+ return tag !== oldTag
+ }),
+ )
})
},
[mutations.DISPLAY_NEW_BOOKMARK](state, display) {
@@ -149,7 +165,7 @@ export default {
state.selection = { folders: [], bookmarks: [] }
},
[mutations.ADD_SELECTION_BOOKMARK](state, item) {
- if (state.selection.bookmarks.find(b => item.id === b.id)) {
+ if (state.selection.bookmarks.find((b) => item.id === b.id)) {
return
}
state.selection.bookmarks.push(item)
@@ -158,7 +174,7 @@ export default {
Vue.set(
state.selection,
'bookmarks',
- state.selection.bookmarks.filter(s => !(s.id === item.id)),
+ state.selection.bookmarks.filter((s) => !(s.id === item.id)),
)
},
[mutations.ADD_SELECTION_FOLDER](state, item) {
@@ -168,7 +184,7 @@ export default {
Vue.set(
state.selection,
'folders',
- state.selection.folders.filter(s => !(s.id === item.id)),
+ state.selection.folders.filter((s) => !(s.id === item.id)),
)
},
@@ -186,14 +202,18 @@ export default {
}
},
[mutations.REMOVE_BOOKMARK](state, id) {
- const index = state.bookmarks.findIndex(bookmark => bookmark.id === id)
+ const index = state.bookmarks.findIndex(
+ (bookmark) => bookmark.id === id,
+ )
if (index !== -1) {
const bookmark = state.bookmarks[index]
- bookmark.folders.forEach(folderId => {
+ bookmark.folders.forEach((folderId) => {
if (!state.childrenByFolder[folderId]) {
return
}
- const index = state.childrenByFolder[folderId].findIndex(bookmark => bookmark.id === id)
+ const index = state.childrenByFolder[folderId].findIndex(
+ (bookmark) => bookmark.id === id,
+ )
if (index !== -1) {
return
}
@@ -219,6 +239,9 @@ export default {
[mutations.SET_ARCHIVED_COUNT](state, count) {
state.archivedCount = count
},
+ [mutations.SET_DELETED_COUNT](state, count) {
+ state.deletedCount = count
+ },
[mutations.SET_DUPLICATED_COUNT](state, count) {
state.duplicatedCount = count
},
diff --git a/tests/BackgroundJobTest.php b/tests/BackgroundJobTest.php
index 056c90e61..2253e96aa 100644
--- a/tests/BackgroundJobTest.php
+++ b/tests/BackgroundJobTest.php
@@ -129,7 +129,7 @@ public function testPreviewsJob() : void {
// generate cached previews
$this->previewsJob->setId(1);
$this->previewsJob->setLastRun(0);
- $this->previewsJob->execute($this->jobList);
+ $this->previewsJob->start($this->jobList);
$folder = $this->appData->getFolder('cache');
$newCacheSize = count($folder->getDirectoryListing());
@@ -151,7 +151,7 @@ public function testGCJob() : void {
// generate cached previews
$this->previewsJob->setId(1);
$this->previewsJob->setLastRun(0);
- $this->previewsJob->execute($this->jobList);
+ $this->previewsJob->start($this->jobList);
$folder = $this->appData->getFolder('cache');
$cacheSize = count($folder->getDirectoryListing());
@@ -169,7 +169,7 @@ public function testGCJob() : void {
// run GC job
$this->gcJob->setId(3);
$this->gcJob->setLastRun(0);
- $this->gcJob->execute($this->jobList);
+ $this->gcJob->start($this->jobList);
$newCacheSize = count($folder->getDirectoryListing());
// should have cleaned up the pending cache entries