@@ -11,9 +11,6 @@ import { translateWindowTitle } from '../../helpers/strings'
11
11
import { clearLocalSearchSuggestionsSession , getLocalSearchSuggestions } from '../../helpers/api/local'
12
12
import { getInvidiousSearchSuggestions } from '../../helpers/api/invidious'
13
13
14
- const NAV_HISTORY_DISPLAY_LIMIT = 15
15
- const HALF_OF_NAV_HISTORY_DISPLAY_LIMIT = Math . floor ( NAV_HISTORY_DISPLAY_LIMIT / 2 )
16
-
17
14
export default defineComponent ( {
18
15
name : 'TopNav' ,
19
16
components : {
@@ -343,52 +340,21 @@ export default defineComponent({
343
340
this . showSearchContainer = ! this . showSearchContainer
344
341
} ,
345
342
346
- getNavigationHistoryResultEndIndex : function ( navigationHistoryActiveIndex , navigationHistoryLength ) {
347
- if ( navigationHistoryActiveIndex < HALF_OF_NAV_HISTORY_DISPLAY_LIMIT ) {
348
- return Math . min ( navigationHistoryLength - 1 , NAV_HISTORY_DISPLAY_LIMIT - 1 )
349
- } else if ( navigationHistoryLength - navigationHistoryActiveIndex < HALF_OF_NAV_HISTORY_DISPLAY_LIMIT + 1 ) {
350
- return navigationHistoryLength - 1
351
- } else {
352
- return navigationHistoryActiveIndex + HALF_OF_NAV_HISTORY_DISPLAY_LIMIT
353
- }
354
- } ,
355
-
356
- getNavigationHistoryDropdownOptions : async function ( ipcRenderer , navigationHistoryActiveIndex , navigationHistoryLength ) {
357
- const dropdownOptions = [ ]
358
- const end = this . getNavigationHistoryResultEndIndex ( navigationHistoryActiveIndex , navigationHistoryLength )
359
-
360
- for ( let index = end ; index >= Math . max ( 0 , end + 1 - NAV_HISTORY_DISPLAY_LIMIT ) ; -- index ) {
361
- const routeLabel = await ipcRenderer . invoke ( IpcChannels . GET_NAV_HISTORY_ENTRY_TITLE_AT_INDEX , index )
362
- const isActiveIndex = index === navigationHistoryActiveIndex
363
- const dropdownOption = {
364
- label : routeLabel ,
365
- value : index - navigationHistoryActiveIndex ,
366
- active : isActiveIndex
367
- }
368
-
369
- dropdownOptions . push ( dropdownOption )
370
-
371
- if ( isActiveIndex ) {
372
- this . navigationHistoryDropdownActiveEntry = dropdownOption
373
- }
374
- }
375
- return dropdownOptions
376
- } ,
377
-
378
343
setNavigationHistoryDropdownOptions : async function ( ) {
379
344
if ( process . env . IS_ELECTRON ) {
380
345
const { ipcRenderer } = require ( 'electron' )
381
- const navigationHistoryLength = await ipcRenderer . invoke ( IpcChannels . GET_NAV_HISTORY_LENGTH )
382
- const navigationHistoryActiveIndex = await ipcRenderer . invoke ( IpcChannels . GET_NAV_HISTORY_ACTIVE_INDEX )
383
346
384
- this . navigationHistoryDropdownOptions = await this . getNavigationHistoryDropdownOptions ( ipcRenderer , navigationHistoryActiveIndex , navigationHistoryLength )
347
+ const dropdownOptions = await ipcRenderer . invoke ( IpcChannels . GET_NAVIGATION_HISTORY )
348
+
349
+ this . navigationHistoryDropdownOptions = dropdownOptions
350
+ this . navigationHistoryDropdownActiveEntry = dropdownOptions . find ( option => option . active )
385
351
}
386
352
} ,
387
353
388
354
goToOffset : function ( offset ) {
389
- if ( process . env . IS_ELECTRON ) {
390
- const { ipcRenderer } = require ( 'electron' )
391
- ipcRenderer . send ( IpcChannels . GO_TO_NAV_HISTORY_OFFSET , offset )
355
+ // no point navigating to the current route
356
+ if ( offset !== 0 ) {
357
+ this . $router . go ( offset )
392
358
}
393
359
} ,
394
360
0 commit comments