Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page bookmarks #5003

Open
wants to merge 43 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
920bf92
Implement page bookmarking modal & call, icon, & handling/calls
kommunarr Apr 22, 2024
808cadb
Update search results with matching bookmarks
kommunarr Apr 22, 2024
a12c4ea
Fix bookmark search result styling and keyboard interactions
kommunarr Apr 23, 2024
a3057c6
Add 'Remove All Page Bookmarks' setting
kommunarr Apr 23, 2024
e60cd78
Improve default bookmark names for Playlist and Search Results routes
kommunarr Apr 23, 2024
c254875
Fix bookmark searching logic
kommunarr Apr 23, 2024
871e330
Update bookmark icon color to use secondary colors when top nav is co…
kommunarr Apr 23, 2024
f7b8f1a
Add aria-roledescription for page bookmark search results
kommunarr Apr 23, 2024
0572d33
Fix deletion call and disable bookmark icon while data is being loade…
kommunarr Apr 23, 2024
88ec2a8
Fix bookmark search results when search suggestions are disabled
kommunarr Apr 23, 2024
7896b7b
Modify bookmark result star icon opacity
kommunarr Apr 23, 2024
392fa75
Implement changes to make work re-usable for saving generic search hi…
kommunarr Apr 23, 2024
78d1b9c
Merge branch 'development' of github.com:FreeTubeApp/FreeTube into fe…
kommunarr Apr 27, 2024
5ee7638
Merge branch 'development' of github.com:FreeTubeApp/FreeTube into fe…
kommunarr May 2, 2024
709caef
Update styling of search results
kommunarr May 3, 2024
50dc04b
Merge branch 'development' of github.com:FreeTubeApp/FreeTube into fe…
kommunarr May 8, 2024
5597720
Merge branch 'development' of github.com:FreeTubeApp/FreeTube into fe…
kommunarr May 20, 2024
c075058
Merge branch 'development' of github.com:FreeTubeApp/FreeTube into fe…
kommunarr May 22, 2024
d9d8c9c
Merge branch 'development' of github.com:FreeTubeApp/FreeTube into fe…
kommunarr Jun 4, 2024
ede347a
Fix page bookmark removal function call to pass the route, not the fu…
kommunarr Jun 4, 2024
d6429d5
Merge branch 'development' of github.com:FreeTubeApp/FreeTube into fe…
kommunarr Jun 11, 2024
7f6a4ad
Add search history sync logic
kommunarr Jun 11, 2024
33d2d50
Have 'Cancel' button appear for already bookmarked page case
kommunarr Jun 11, 2024
4736723
Update to show the proper page bookmark name upon deletion
kommunarr Jun 11, 2024
039fce1
Delete page bookmarks to user playlists when those user playlists are…
kommunarr Jun 11, 2024
85e46b5
Add icons corresponding to bookmarked page route
kommunarr Jun 11, 2024
a81a8b5
Prevent search results from wrapping across to multiple rows
kommunarr Jun 11, 2024
e5b5b43
Constrain visible ft-input results list length to 15
kommunarr Jun 11, 2024
094b2c2
Add message when there are other page bookmarks with the same name
kommunarr Jun 11, 2024
b162507
Update playlist route icons
kommunarr Jun 12, 2024
13ba73e
Merge branch 'development' of github.com:FreeTubeApp/FreeTube into fe…
kommunarr Jun 15, 2024
3504424
Merge branch 'development' into feat/add-page-bookmarking
kommunarr Jun 19, 2024
abbd349
Merge branch 'development' of github.com:FreeTubeApp/FreeTube into fe…
kommunarr Jul 1, 2024
2039016
Merge branch 'development' of github.com:FreeTubeApp/FreeTube into fe…
kommunarr Oct 16, 2024
69ed872
Merge branch 'development' of github.com:FreeTubeApp/FreeTube into fe…
kommunarr Oct 28, 2024
a2914fa
Remove ' - FreeTube' portion of default titles
kommunarr Oct 28, 2024
e9b539f
Only enable page bookmarking on certain routes
kommunarr Oct 28, 2024
7fa1d34
Merge branch 'development' of github.com:FreeTubeApp/FreeTube into fe…
kommunarr Dec 3, 2024
d3feeb9
Move helper function to class for removing '- FreeTube' suffix
kommunarr Dec 3, 2024
af49655
Add clarifying code comment, update hashtag & post route icons
kommunarr Dec 3, 2024
29485ed
Merge branch 'development' of github.com:FreeTubeApp/FreeTube into fe…
kommunarr Dec 4, 2024
d6329af
Update to use ft-icon-button with improved disabled styling & behavior
kommunarr Dec 4, 2024
2941e15
Fix route not being bookmarkable when reloading app on a bookmarkable…
kommunarr Dec 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ const IpcChannels = {
DB_HISTORY: 'db-history',
DB_PROFILES: 'db-profiles',
DB_PLAYLISTS: 'db-playlists',
DB_SEARCH_HISTORY: 'db-search-history',

SYNC_SETTINGS: 'sync-settings',
SYNC_HISTORY: 'sync-history',
SYNC_SEARCH_HISTORY: 'sync-search-history',
SYNC_PROFILES: 'sync-profiles',
SYNC_PLAYLISTS: 'sync-playlists',

Expand Down Expand Up @@ -55,6 +57,9 @@ const DBActions = {
UPDATE_PLAYLIST: 'db-action-history-update-playlist',
},

// SEARCH_HISTORY: {
// },

PLAYLISTS: {
UPSERT_VIDEO: 'db-action-playlists-upsert-video-by-playlist-name',
UPSERT_VIDEOS: 'db-action-playlists-upsert-videos-by-playlist-name',
Expand Down
28 changes: 28 additions & 0 deletions src/datastores/handlers/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,39 @@ class Playlists {
}
}

class SearchHistory {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should rename all related code to page bookmark?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention is that we could have persistent keyword search history entry logic here in the future (see Future PRs in OP), and page bookmarks are a type of search history.

static create(pageBookmark) {
return db.searchHistory.insertAsync(pageBookmark)
}

static find() {
return db.searchHistory.findAsync({})
}

static upsert(pageBookmark) {
return db.searchHistory.updateAsync({ _id: pageBookmark._id }, pageBookmark, { upsert: true })
}

static delete(_id) {
return db.searchHistory.removeAsync({ _id: _id })
}

static deleteMultiple(ids) {
return db.searchHistory.removeAsync({ _id: { $in: ids } })
}

static deleteAll() {
return db.searchHistory.removeAsync({}, { multi: true })
}
}

function compactAllDatastores() {
return Promise.allSettled([
db.settings.compactDatafileAsync(),
db.history.compactDatafileAsync(),
db.profiles.compactDatafileAsync(),
db.playlists.compactDatafileAsync(),
db.searchHistory.compactDatafileAsync()
])
}

Expand All @@ -181,6 +208,7 @@ export {
History as history,
Profiles as profiles,
Playlists as playlists,
SearchHistory as searchHistory,

compactAllDatastores,
}
47 changes: 46 additions & 1 deletion src/datastores/handlers/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,54 @@ class Playlists {
}
}

class SearchHistory {
static create(pageBookmark) {
return ipcRenderer.invoke(
IpcChannels.DB_SEARCH_HISTORY,
{ action: DBActions.GENERAL.CREATE, data: pageBookmark }
)
}

static find() {
return ipcRenderer.invoke(
IpcChannels.DB_SEARCH_HISTORY,
{ action: DBActions.GENERAL.FIND }
)
}

static upsert(pageBookmark) {
return ipcRenderer.invoke(
IpcChannels.DB_SEARCH_HISTORY,
{ action: DBActions.GENERAL.UPSERT, data: pageBookmark }
)
}

static delete(_id) {
return ipcRenderer.invoke(
IpcChannels.DB_SEARCH_HISTORY,
{ action: DBActions.GENERAL.DELETE, data: _id }
)
}

static deleteMultiple(ids) {
return ipcRenderer.invoke(
IpcChannels.DB_SEARCH_HISTORY,
{ action: DBActions.GENERAL.DELETE_MULTIPLE, data: ids }
)
}

static deleteAll() {
return ipcRenderer.invoke(
IpcChannels.DB_SEARCH_HISTORY,
{ action: DBActions.GENERAL.DELETE_ALL }
)
}
}

export {
Settings as settings,
History as history,
Profiles as profiles,
Playlists as playlists
Playlists as playlists,
SearchHistory as searchHistory
}
3 changes: 2 additions & 1 deletion src/datastores/handlers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export {
settings as DBSettingHandlers,
history as DBHistoryHandlers,
profiles as DBProfileHandlers,
playlists as DBPlaylistHandlers
playlists as DBPlaylistHandlers,
searchHistory as DBSearchHistoryHandlers
} from 'DB_HANDLERS_ELECTRON_RENDERER_OR_WEB'
29 changes: 28 additions & 1 deletion src/datastores/handlers/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,36 @@ class Playlists {
}
}

class SearchHistory {
static create(pageBookmark) {
return baseHandlers.searchHistory.create(pageBookmark)
}

static find() {
return baseHandlers.searchHistory.find()
}

static upsert(pageBookmark) {
return baseHandlers.searchHistory.upsert(pageBookmark)
}

static delete(_id) {
return baseHandlers.searchHistory.delete(_id)
}

static deleteMultiple(ids) {
return baseHandlers.searchHistory.deleteMultiple(ids)
}

static deleteAll() {
return baseHandlers.searchHistory.deleteAll()
}
}

export {
Settings as settings,
History as history,
Profiles as profiles,
Playlists as playlists
Playlists as playlists,
SearchHistory as searchHistory
}
1 change: 1 addition & 0 deletions src/datastores/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ export const settings = new Datastore({ filename: dbPath('settings'), autoload:
export const profiles = new Datastore({ filename: dbPath('profiles'), autoload: true })
export const playlists = new Datastore({ filename: dbPath('playlists'), autoload: true })
export const history = new Datastore({ filename: dbPath('history'), autoload: true })
export const searchHistory = new Datastore({ filename: dbPath('search-history'), autoload: true })
58 changes: 58 additions & 0 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,64 @@ function runApp() {
}
})

// ************** //
// Search History
ipcMain.handle(IpcChannels.DB_SEARCH_HISTORY, async (event, { action, data }) => {
try {
switch (action) {
case DBActions.GENERAL.CREATE: {
const pageBookmark = await baseHandlers.searchHistory.create(data)
syncOtherWindows(
IpcChannels.SYNC_SEARCH_HISTORY,
event,
{ event: SyncEvents.GENERAL.CREATE, data }
)
return pageBookmark
}
case DBActions.GENERAL.FIND:
return await baseHandlers.searchHistory.find()

case DBActions.GENERAL.UPSERT:
await baseHandlers.searchHistory.upsert(data)
syncOtherWindows(
IpcChannels.SYNC_SEARCH_HISTORY,
event,
{ event: SyncEvents.GENERAL.UPSERT, data }
)
return null

case DBActions.GENERAL.DELETE:
await baseHandlers.searchHistory.delete(data)
syncOtherWindows(
IpcChannels.SYNC_SEARCH_HISTORY,
event,
{ event: SyncEvents.GENERAL.DELETE, data }
)
return null

case DBActions.GENERAL.DELETE_MULTIPLE:
await baseHandlers.searchHistory.deleteMultiple(data)
syncOtherWindows(
IpcChannels.SYNC_SEARCH_HISTORY,
event,
{ event: SyncEvents.GENERAL.DELETE_MULTIPLE, data }
)
return null

case DBActions.GENERAL.DELETE_ALL:
await baseHandlers.searchHistory.deleteAll()
return null

default:
// eslint-disable-next-line no-throw-literal
throw 'invalid search history db action'
}
} catch (err) {
if (typeof err === 'string') throw err
else throw err.toString()
}
})

// *********** //

function syncOtherWindows(channel, event, payload) {
Expand Down
12 changes: 11 additions & 1 deletion src/renderer/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import FtToast from './components/ft-toast/ft-toast.vue'
import FtProgressBar from './components/ft-progress-bar/ft-progress-bar.vue'
import FtPlaylistAddVideoPrompt from './components/ft-playlist-add-video-prompt/ft-playlist-add-video-prompt.vue'
import FtCreatePlaylistPrompt from './components/ft-create-playlist-prompt/ft-create-playlist-prompt.vue'
import PageBookmarkPrompt from './components/page-bookmark-prompt/page-bookmark-prompt.vue'
import FtSearchFilters from './components/ft-search-filters/ft-search-filters.vue'
import { marked } from 'marked'
import { IpcChannels } from '../constants'
Expand All @@ -32,6 +33,7 @@ export default defineComponent({
FtProgressBar,
FtPlaylistAddVideoPrompt,
FtCreatePlaylistPrompt,
PageBookmarkPrompt,
FtSearchFilters
},
data: function () {
Expand All @@ -40,6 +42,7 @@ export default defineComponent({
showUpdatesBanner: false,
showBlogBanner: false,
showReleaseNotes: false,
pageBookmarksAvailable: false,
updateBannerMessage: '',
blogBannerMessage: '',
latestBlogUrl: '',
Expand Down Expand Up @@ -77,6 +80,9 @@ export default defineComponent({
showCreatePlaylistPrompt: function () {
return this.$store.getters.getShowCreatePlaylistPrompt
},
showPageBookmarkPrompt: function () {
return this.$store.getters.getShowPageBookmarkPrompt
},
showSearchFilters: function () {
return this.$store.getters.getShowSearchFilters
},
Expand Down Expand Up @@ -142,7 +148,7 @@ export default defineComponent({

externalLinkHandling: function () {
return this.$store.getters.getExternalLinkHandling
}
},
},
watch: {
windowTitle: 'setWindowTitle',
Expand Down Expand Up @@ -178,6 +184,9 @@ export default defineComponent({
this.grabAllProfiles(this.$t('Profile.All Channels')).then(async () => {
this.grabHistory()
this.grabAllPlaylists()
this.grabPageBookmarks().then(async () => {
this.pageBookmarksAvailable = true
})

if (process.env.IS_ELECTRON) {
ipcRenderer = require('electron').ipcRenderer
Expand Down Expand Up @@ -544,6 +553,7 @@ export default defineComponent({
'grabUserSettings',
'grabAllProfiles',
'grabHistory',
'grabPageBookmarks',
'grabAllPlaylists',
'getYoutubeUrlInfo',
'getExternalPlayerCmdArgumentsData',
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,17 @@
<ft-create-playlist-prompt
v-if="showCreatePlaylistPrompt"
/>
<page-bookmark-prompt
v-if="showPageBookmarkPrompt"
/>
<ft-toast />
<ft-progress-bar
v-if="showProgressBar"
/>
<top-nav
ref="topNav"
:inert="isPromptOpen"
:page-bookmarks-available="pageBookmarksAvailable"
/>
<side-nav
ref="sideNav"
Expand Down
16 changes: 15 additions & 1 deletion src/renderer/components/ft-input/ft-input.css
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,22 @@
.list li {
display: block;
padding-block: 0;
padding-inline: 15px;
line-height: 2rem;
padding-inline: 15px;
text-overflow: ellipsis;
overflow-x: hidden;
white-space: nowrap;
}

.bookmarkStarIcon {
color: var(--favorite-icon-color);
}

.searchResultIcon {
opacity: 0.6;
padding-inline-end: 10px;
inline-size: 16px;
block-size: 16px;
}

.hover {
Expand Down
Loading