Skip to content

Commit

Permalink
Add message when there are other page bookmarks with the same name
Browse files Browse the repository at this point in the history
  • Loading branch information
kommunarr committed Jun 11, 2024
1 parent e5b5b43 commit 094b2c2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ export default defineComponent({
isBookmarkBeingCreated: function () {
return this.pageBookmark == null
},
pageBookmarks: function () {
return this.$store.getters.getPageBookmarks
},
duplicateNameCount: function () {
const currentBookmarkAdjustment = this.name === this.pageBookmark?.name ? -1 : 0
return currentBookmarkAdjustment + this.pageBookmarks.filter((pageBookmark) => pageBookmark.name === this.name).length
},
duplicateNameMessage: function () {
return this.$tc('Page Bookmark["There is {count} other bookmark with the same name."]', this.duplicateNameCount, { count: this.duplicateNameCount })
},
pageBookmark: function () {
return this.$store.getters.getPageBookmarkWithRoute(this.$router.currentRoute.fullPath)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
@clear="e => name = ''"
@keydown.enter.native="save"
/>
<ft-flex-box v-if="duplicateNameCount > 0">
<p>{{ duplicateNameMessage }}</p>
</ft-flex-box>
</div>
<div class="actions-container">
<ft-flex-box>
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/store/modules/search-history.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const state = {
}

const getters = {
getPageBookmarks: (state) => () => {
getPageBookmarks: (state) => {
return state.pageBookmarks
},

Expand Down
1 change: 1 addition & 0 deletions static/locales/en-US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,7 @@ Page Bookmark:
Created page bookmark: Created page bookmark "{name}"
Updated page bookmark: Updated page bookmark "{name}"
Removed page bookmark: Removed page bookmark "{name}"
There is {count} other bookmark with the same name.: There is {count} other page bookmark with the same name. | There are {count} other page bookmarks with the same name.
Role Descriptions:
bookmark: bookmark
Moments Ago: moments ago
Expand Down

0 comments on commit 094b2c2

Please sign in to comment.