ui: Refactor isMobile as reactive value in viewport store (#23330)
* refactor: `isMobile` as reactive value in `viewport` store * refactor: Use Svelte media query for the viewport store
This commit is contained in:
@@ -41,8 +41,7 @@ import {
|
||||
SETTINGS_KEYS,
|
||||
USER_OVERRIDES_LOCALSTORAGE_KEY
|
||||
} from '$lib/constants';
|
||||
|
||||
import { IsMobile } from '$lib/hooks/is-mobile.svelte';
|
||||
import { isMobile } from '$lib/stores/viewport.svelte';
|
||||
import { ParameterSyncService } from '$lib/services/parameter-sync.service';
|
||||
import { serverStore } from '$lib/stores/server.svelte';
|
||||
import {
|
||||
@@ -132,7 +131,7 @@ class SettingsStore {
|
||||
|
||||
// Default sendOnEnter to false on mobile when the user has no saved preference
|
||||
if (!(SETTINGS_KEYS.SEND_ON_ENTER in savedVal)) {
|
||||
if (new IsMobile().current) {
|
||||
if (isMobile.current) {
|
||||
this.config[SETTINGS_KEYS.SEND_ON_ENTER] = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { browser } from '$app/environment';
|
||||
import { DEFAULT_MOBILE_BREAKPOINT } from '$lib/constants/viewport';
|
||||
import { MediaQuery } from 'svelte/reactivity';
|
||||
|
||||
export const viewport = $state({
|
||||
width: browser ? window.innerWidth : 0
|
||||
});
|
||||
|
||||
export const isMobile = new MediaQuery(`max-width: ${DEFAULT_MOBILE_BREAKPOINT - 1}px`);
|
||||
Reference in New Issue
Block a user