Move SearchGlobalShortcut to a colocated hook
This commit is contained in:
+2
-3
@@ -20,16 +20,15 @@ import "phoenix_html";
|
||||
// Establish Phoenix Socket and LiveView configuration.
|
||||
import { Socket } from "phoenix";
|
||||
import { LiveSocket } from "phoenix_live_view";
|
||||
import { hooks as colocatedHooks } from "phoenix-colocated/music_library";
|
||||
import topbar from "../vendor/topbar";
|
||||
import { Hooks as FluxonHooks, DOM as FluxonDOM } from "fluxon";
|
||||
import BarcodeScannerHook from "./barcode-scanner";
|
||||
import SearchGlobalShortcut from "./search-global-shortcut";
|
||||
import confetti from "canvas-confetti";
|
||||
import { createLiveToastHook } from "live_toast";
|
||||
|
||||
let Hooks = FluxonHooks;
|
||||
Hooks.BarcodeScanner = BarcodeScannerHook;
|
||||
Hooks.SearchGlobalShortcut = SearchGlobalShortcut;
|
||||
Hooks.LiveToast = createLiveToastHook();
|
||||
|
||||
let csrfToken = document
|
||||
@@ -38,7 +37,7 @@ let csrfToken = document
|
||||
let liveSocket = new LiveSocket("/live", Socket, {
|
||||
longPollFallbackMs: 2500,
|
||||
params: { _csrf_token: csrfToken },
|
||||
hooks: Hooks,
|
||||
hooks: { ...Hooks, ...colocatedHooks },
|
||||
dom: {
|
||||
onBeforeElUpdated(from, to) {
|
||||
FluxonDOM.onBeforeElUpdated(from, to);
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
export default {
|
||||
mounted() {
|
||||
const universalSearchButton = document.querySelector("#universal-search-button");
|
||||
|
||||
document.addEventListener("keydown", (event) => {
|
||||
switch (event.key) {
|
||||
case "k":
|
||||
if (event.metaKey || event.ctrlKey) {
|
||||
event.preventDefault();
|
||||
universalSearchButton.click();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user