Removed config dependency from searchbar

This commit is contained in:
Alicia Sykes 2022-08-14 20:32:23 +01:00
parent c9cd395313
commit 8f893c36d7
2 changed files with 4 additions and 3 deletions

View File

@ -95,7 +95,8 @@ export default {
}, },
/* If configured, launch specific app when hotkey pressed */ /* If configured, launch specific app when hotkey pressed */
handleHotKey(key) { handleHotKey(key) {
const usersHotKeys = this.getCustomKeyShortcuts(); const sections = this.$store.getters.sections || [];
const usersHotKeys = this.getCustomKeyShortcuts(sections);
usersHotKeys.forEach((hotkey) => { usersHotKeys.forEach((hotkey) => {
if (hotkey.hotkey === parseInt(key, 10)) { if (hotkey.hotkey === parseInt(key, 10)) {
if (hotkey.url) window.open(hotkey.url, '_blank'); if (hotkey.url) window.open(hotkey.url, '_blank');

View File

@ -1,4 +1,5 @@
import ConfigAccumulator from '@/utils/ConfigAccumalator'; import ConfigAccumulator from '@/utils/ConfigAccumalator';
// import $store from '@/store';
import filterUserSections from '@/utils/CheckSectionVisibility'; import filterUserSections from '@/utils/CheckSectionVisibility';
import { languages } from '@/utils/languages'; import { languages } from '@/utils/languages';
import { import {
@ -77,9 +78,8 @@ export const componentVisibility = (appConfig) => {
* Returns a list of items which the user has assigned a hotkey to * Returns a list of items which the user has assigned a hotkey to
* So that when the hotkey is pressed, the app/ service can be launched * So that when the hotkey is pressed, the app/ service can be launched
*/ */
export const getCustomKeyShortcuts = () => { export const getCustomKeyShortcuts = (sections) => {
const results = []; const results = [];
const sections = config.sections || [];
sections.forEach((section) => { sections.forEach((section) => {
const itemsWithHotKeys = section.items.filter(item => item.hotkey); const itemsWithHotKeys = section.items.filter(item => item.hotkey);
results.push(itemsWithHotKeys.map(item => ({ hotkey: item.hotkey, url: item.url }))); results.push(itemsWithHotKeys.map(item => ({ hotkey: item.hotkey, url: item.url })));