From f0361d5f55aec9f4d673d7eea8e7e9cab48d2ca8 Mon Sep 17 00:00:00 2001 From: lgmarchi Date: Wed, 13 Nov 2024 10:59:08 -0300 Subject: [PATCH] chore(layout): clean up code and improve event handling in layout components --- src/app.d.ts | 1 + src/custom-events.d.ts | 9 +++++++++ src/lib/layouts/Chatbar.svelte | 1 - src/lib/wasm/IWarp.ts | 2 +- src/routes/+layout.svelte | 8 ++++---- src/routes/chat/+page.svelte | 1 - 6 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 src/custom-events.d.ts diff --git a/src/app.d.ts b/src/app.d.ts index 548c358be..3a54b1f93 100644 --- a/src/app.d.ts +++ b/src/app.d.ts @@ -9,6 +9,7 @@ declare global { // interface Platform {} } } + declare const __COMMIT_HASH__: string export {} diff --git a/src/custom-events.d.ts b/src/custom-events.d.ts new file mode 100644 index 000000000..753044620 --- /dev/null +++ b/src/custom-events.d.ts @@ -0,0 +1,9 @@ +// custom-events.d.ts +declare namespace svelteHTML { + interface HTMLAttributes { + "on:swipeleft"?: (event: CustomEvent) => void + "on:swiperight"?: (event: CustomEvent) => void + "on:swipeup"?: (event: CustomEvent) => void + "on:swipedown"?: (event: CustomEvent) => void + } +} diff --git a/src/lib/layouts/Chatbar.svelte b/src/lib/layouts/Chatbar.svelte index ff5a1b2ef..4fd64afc6 100644 --- a/src/lib/layouts/Chatbar.svelte +++ b/src/lib/layouts/Chatbar.svelte @@ -25,7 +25,6 @@ export let replyTo: MessageType | undefined = undefined export let emojiClickHook: (emoji: string) => boolean export let activeChat: Chat - export const typing: User[] = [] const dispatch = createEventDispatcher() diff --git a/src/lib/wasm/IWarp.ts b/src/lib/wasm/IWarp.ts index c345bd374..f46a9f73c 100644 --- a/src/lib/wasm/IWarp.ts +++ b/src/lib/wasm/IWarp.ts @@ -12,7 +12,7 @@ const inititialized: Writable = writable(false) export async function initWarp() { if (!get(inititialized)) { - await init() + await init({}) inititialized.set(true) } } diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index c3a5b5d9c..652eb5af8 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -28,6 +28,8 @@ import Market from "$lib/components/market/Market.svelte" import { swipe } from "$lib/components/ui/Swipe" + log.debug("Initializing app, layout routes page.") + TimeAgo.addDefaultLocale(en) let keybinds: Keybind[] let devmode: boolean = get(SettingsStore.state).devmode @@ -229,8 +231,6 @@ Store.state.devices.muted.subscribe(state => (muted = state)) Store.state.devices.deafened.subscribe(state => (deafened = state)) - console.log("Arriving here on +layout") - window.addEventListener( "click", () => { @@ -275,10 +275,10 @@
{ + on:swipeleft={() => { UIStore.closeSidebar() }} - on:swiperight={_ => { + on:swiperight={() => { UIStore.openSidebar() }}> {@html ``} diff --git a/src/routes/chat/+page.svelte b/src/routes/chat/+page.svelte index 58bf706a6..25928f755 100644 --- a/src/routes/chat/+page.svelte +++ b/src/routes/chat/+page.svelte @@ -976,7 +976,6 @@ $users[u])} emojiClickHook={emoji => { if (reactingTo) { reactTo(reactingTo, emoji, true)