diff --git a/src/constants.js b/src/constants.js index 282443998..5c7f9ed46 100644 --- a/src/constants.js +++ b/src/constants.js @@ -17,9 +17,9 @@ const IpcChannels = { DB_SETTINGS: 'db-settings', DB_HISTORY: 'db-history', - DB_SEARCH_HISTORY: 'db-search-history', DB_PROFILES: 'db-profiles', DB_PLAYLISTS: 'db-playlists', + DB_SEARCH_HISTORY: 'db-search-history', SYNC_SETTINGS: 'sync-settings', SYNC_HISTORY: 'sync-history', diff --git a/src/datastores/handlers/base.js b/src/datastores/handlers/base.js index 302a567f6..d715669cb 100644 --- a/src/datastores/handlers/base.js +++ b/src/datastores/handlers/base.js @@ -193,11 +193,11 @@ class SearchHistory { } static upsert(pageBookmark) { - return db.searchHistory.updateAsync({ _id: pageBookmark.route }, pageBookmark, { upsert: true }) + return db.searchHistory.updateAsync({ _id: pageBookmark._id }, pageBookmark, { upsert: true }) } static delete(route) { - return db.searchHistory.removeAsync({ _id: route }) + return db.searchHistory.removeAsync({ route: route }) } static deleteAll() { diff --git a/src/main/index.js b/src/main/index.js index d364a5454..72ba55690 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -1071,15 +1071,15 @@ function runApp() { ipcMain.handle(IpcChannels.DB_SEARCH_HISTORY, async (event, { action, data }) => { try { switch (action) { - case DBActions.GENERAL.CREATE: - await baseHandlers.searchHistory.create(data) + case DBActions.GENERAL.CREATE: { + const pageBookmark = await baseHandlers.searchHistory.create(data) syncOtherWindows( IpcChannels.SYNC_SEARCH_HISTORY, event, { event: SyncEvents.GENERAL.CREATE, data } ) - return null - + return pageBookmark + } case DBActions.GENERAL.FIND: return await baseHandlers.searchHistory.find() diff --git a/src/renderer/App.js b/src/renderer/App.js index ffef75879..2abf4fd65 100644 --- a/src/renderer/App.js +++ b/src/renderer/App.js @@ -171,6 +171,7 @@ export default defineComponent({ this.grabAllProfiles(this.$t('Profile.All Channels')).then(async () => { this.grabHistory() + this.grabPageBookmarks() this.grabAllPlaylists() if (process.env.IS_ELECTRON) { @@ -539,6 +540,7 @@ export default defineComponent({ 'grabUserSettings', 'grabAllProfiles', 'grabHistory', + 'grabPageBookmarks', 'grabAllPlaylists', 'getYoutubeUrlInfo', 'getExternalPlayerCmdArgumentsData', diff --git a/src/renderer/components/ft-input/ft-input.css b/src/renderer/components/ft-input/ft-input.css index e5f9a1704..ba2d3dab5 100644 --- a/src/renderer/components/ft-input/ft-input.css +++ b/src/renderer/components/ft-input/ft-input.css @@ -205,6 +205,10 @@ line-height: 2rem; } +/* .list .li.bookmarked { + color: green; +} */ + .hover { background-color: var(--scrollbar-color-hover); color: var(--scrollbar-text-color-hover); diff --git a/src/renderer/components/ft-input/ft-input.js b/src/renderer/components/ft-input/ft-input.js index 9c3bfc197..0e23e1809 100644 --- a/src/renderer/components/ft-input/ft-input.js +++ b/src/renderer/components/ft-input/ft-input.js @@ -231,9 +231,13 @@ export default defineComponent({ } }, - handleOptionClick: function (index) { + handleOptionClick: function (index, isBookmark) { this.searchState.showOptions = false - this.inputData = this.visibleDataList[index] + if (isBookmark) { + this.inputData = `ft:${this.visibleDataList[index].route}` + } else { + this.inputData = this.visibleDataList[index] + } this.$emit('input', this.inputData) this.handleClick() }, @@ -307,6 +311,10 @@ export default defineComponent({ const lowerCaseInputData = this.inputData.toLowerCase() this.visibleDataList = this.dataList.filter(x => { + if (x.bookmarkName) { + return x.bookmarkName.toLowerCase().indexOf(lowerCaseInputData) !== -1 + } + return x.toLowerCase().indexOf(lowerCaseInputData) !== -1 }) }, diff --git a/src/renderer/components/ft-input/ft-input.vue b/src/renderer/components/ft-input/ft-input.vue index c9a7c8523..a4e20f873 100644 --- a/src/renderer/components/ft-input/ft-input.vue +++ b/src/renderer/components/ft-input/ft-input.vue @@ -76,14 +76,18 @@ >