diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 64970551d..2be91bbf9 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -27,7 +27,15 @@ ts-rs = "12.0.0" sha2 = "0.10" percent-encoding = "2" -tauri = { version = "2.11.5", default-features = false, features = ["tray-icon", "dynamic-acl", "compression", "x11", "common-controls-v6", "dbus", "image-png"] } +tauri = { version = "2.11.5", default-features = false, features = [ + "tray-icon", + "dynamic-acl", + "compression", + "x11", + "common-controls-v6", + "dbus", + "image-png", +] } tauri-plugin-log = "2.9.0" tauri-plugin-opener = "2.5.4" @@ -43,7 +51,7 @@ windows = { version = "0.61", features = [ "Win32_Foundation", "Win32_UI_WindowsAndMessaging", "Win32_System_Threading", - "Win32_System_ProcessStatus" + "Win32_System_ProcessStatus", ] } [target.'cfg(any(target_os = "macos", windows, target_os = "linux"))'.dependencies] @@ -57,7 +65,9 @@ webkit2gtk = "2.0" gtk = "0.18" [target.'cfg(any(target_os = "android", target_os = "ios"))'.dependencies] -tauri-plugin-notifications = { git = "https://github.com/Choochmeque/tauri-plugin-notifications.git", rev = "2ff1373d218ff02a93f71f589c56e4e8b588ea7d", features = ["push-notifications"] } +tauri-plugin-notifications = { git = "https://github.com/Choochmeque/tauri-plugin-notifications.git", rev = "2ff1373d218ff02a93f71f589c56e4e8b588ea7d", features = [ + "push-notifications", +] } tauri-plugin-edge-to-edge = { git = "https://github.com/SableClient/tauri-plugin-edge-to-edge.git", rev = "33c6116c27be28c06df5a9d02231ecc5fdeb93c5" } [target.'cfg(target_os = "android")'.dependencies] diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 580f540ad..5051bb9d3 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -23,10 +23,24 @@ }, "linux": { "deb": { - "depends": ["xwayland", "gstreamer1.0-plugins-good", "gstreamer1.0-plugins-bad", "gstreamer1.0-libav", "gstreamer1.0-nice", "geoclue-2.0"] + "depends": [ + "xwayland", + "gstreamer1.0-plugins-good", + "gstreamer1.0-plugins-bad", + "gstreamer1.0-libav", + "gstreamer1.0-nice", + "geoclue-2.0" + ] }, "rpm": { - "depends": ["xorg-x11-server-Xwayland", "gstreamer1-plugins-good", "gstreamer1-plugins-bad-free", "gstreamer1-libav", "gstreamer1-plugins-nice", "geoclue2"] + "depends": [ + "xorg-x11-server-Xwayland", + "gstreamer1-plugins-good", + "gstreamer1-plugins-bad-free", + "gstreamer1-libav", + "gstreamer1-plugins-nice", + "geoclue2" + ] } }, "icon": [ diff --git a/src/app/components/app-shell/AppShell.tsx b/src/app/components/app-shell/AppShell.tsx index c93f26606..0a5589502 100644 --- a/src/app/components/app-shell/AppShell.tsx +++ b/src/app/components/app-shell/AppShell.tsx @@ -7,7 +7,7 @@ import { type as osType } from '@tauri-apps/plugin-os'; import { TauriFrontendReady } from '$components/tauri/TauriFrontendReady'; import { WindowsTitleBar } from '$components/tauri/WindowsTitleBar'; -import type { ScreenSize} from '$hooks/useScreenSize'; +import type { ScreenSize } from '$hooks/useScreenSize'; import { ScreenSizeProvider } from '$hooks/useScreenSize'; import { isReactQueryDevtoolsEnabled } from '$pages/reactQueryDevtoolsGate'; import { SystemBarShell } from './SystemBarShell'; diff --git a/src/app/components/message/content/ImageContent.tsx b/src/app/components/message/content/ImageContent.tsx index 254282b1b..0dc49340b 100644 --- a/src/app/components/message/content/ImageContent.tsx +++ b/src/app/components/message/content/ImageContent.tsx @@ -135,7 +135,7 @@ export const ImageContent = as<'div', ImageContentProps>( url.toLowerCase().endsWith('.apng') || url.toLowerCase().endsWith('.webp'); -const rawMediaUrl = useMemo(() => { + const rawMediaUrl = useMemo(() => { if (url.startsWith('http')) return url; return mxcUrlToHttp(mx, url, useAuthentication) ?? undefined; }, [mx, url, useAuthentication]); diff --git a/src/app/components/message/content/ThumbnailContent.tsx b/src/app/components/message/content/ThumbnailContent.tsx index 3e4bad228..1f037c65e 100644 --- a/src/app/components/message/content/ThumbnailContent.tsx +++ b/src/app/components/message/content/ThumbnailContent.tsx @@ -1,4 +1,4 @@ -import type { ReactNode} from 'react'; +import type { ReactNode } from 'react'; import { useCallback, useEffect, useMemo } from 'react'; import type { IThumbnailContent } from '$types/matrix/common'; import { useMatrixClient } from '$hooks/useMatrixClient'; @@ -48,4 +48,4 @@ export function ThumbnailContent({ info, renderImage }: ThumbnailContentProps) { }, [loadThumbSrc]); return thumbSrcState.status === AsyncStatus.Success ? renderImage(thumbSrcState.data) : null; -} \ No newline at end of file +} diff --git a/src/app/components/message/content/VideoContent.tsx b/src/app/components/message/content/VideoContent.tsx index beb945623..7b2e37796 100644 --- a/src/app/components/message/content/VideoContent.tsx +++ b/src/app/components/message/content/VideoContent.tsx @@ -75,7 +75,7 @@ export const VideoContent = as<'div', VideoContentProps>( const [blurred, setBlurred] = useState(markedAsSpoiler ?? false); const [isHovered, setIsHovered] = useState(false); -const [srcState, loadSrc] = useAsyncCallback( + const [srcState, loadSrc] = useAsyncCallback( useCallback(async () => { if (url.startsWith('http')) return url; diff --git a/src/app/features/room/RoomInput.tsx b/src/app/features/room/RoomInput.tsx index 2f5720845..c01eb16cd 100644 --- a/src/app/features/room/RoomInput.tsx +++ b/src/app/features/room/RoomInput.tsx @@ -2006,4 +2006,4 @@ export const RoomInput = forwardRef( ); } -); \ No newline at end of file +); diff --git a/src/app/features/settings/desktop/Desktop.test.tsx b/src/app/features/settings/desktop/Desktop.test.tsx index cc1665122..6cc6fe763 100644 --- a/src/app/features/settings/desktop/Desktop.test.tsx +++ b/src/app/features/settings/desktop/Desktop.test.tsx @@ -12,9 +12,7 @@ const { mockUseDesktopSettingsSyncing, } = vi.hoisted(() => ({ mockUseDesktopSetting: vi.fn< - ( - key: 'closeToBackgroundOnClose' | 'showSystemTrayIcon' - ) => readonly [boolean, () => void] + (key: 'closeToBackgroundOnClose' | 'showSystemTrayIcon') => readonly [boolean, () => void] >((key) => { if (key === 'closeToBackgroundOnClose') return [true, vi.fn<() => void>()] as const; return [true, vi.fn<() => void>()] as const; diff --git a/src/app/features/settings/desktop/Desktop.tsx b/src/app/features/settings/desktop/Desktop.tsx index 1cb9d42f8..a9bcb8f0a 100644 --- a/src/app/features/settings/desktop/Desktop.tsx +++ b/src/app/features/settings/desktop/Desktop.tsx @@ -29,7 +29,7 @@ export function Desktop({ requestBack, requestClose }: DesktopProps) { if (!isTauri() || !ready) return null; - let type = osType() + let type = osType(); if (type === 'android' || type === 'ios') return null; const trayFallback = showSystemTrayIcon && !runtimeState.trayAvailable && !syncing; diff --git a/src/app/features/settings/notifications/NativePushNotifications.test.ts b/src/app/features/settings/notifications/NativePushNotifications.test.ts index 6411b281e..6b9dfde81 100644 --- a/src/app/features/settings/notifications/NativePushNotifications.test.ts +++ b/src/app/features/settings/notifications/NativePushNotifications.test.ts @@ -22,8 +22,12 @@ const getNativePushNotificationsApi = vi.hoisted(() => const matrixClient = vi.hoisted(() => ({ setPusher: vi.fn<() => Promise>().mockResolvedValue(undefined), getDeviceId: vi.fn<() => string>(() => 'DEVICE'), - getDevice: vi.fn<() => Promise<{ display_name: string }>>().mockResolvedValue({ display_name: 'Pixel' }), - getPushers: vi.fn<() => Promise<{ pushers: Array }>>().mockResolvedValue({ pushers: [] }), + getDevice: vi + .fn<() => Promise<{ display_name: string }>>() + .mockResolvedValue({ display_name: 'Pixel' }), + getPushers: vi + .fn<() => Promise<{ pushers: Array }>>() + .mockResolvedValue({ pushers: [] }), })); const nativePushClientConfig = { diff --git a/src/app/features/settings/notifications/NativePushNotificationsApiClient.ts b/src/app/features/settings/notifications/NativePushNotificationsApiClient.ts index f7b4c737d..e1fb5c607 100644 --- a/src/app/features/settings/notifications/NativePushNotificationsApiClient.ts +++ b/src/app/features/settings/notifications/NativePushNotificationsApiClient.ts @@ -10,9 +10,7 @@ let nativePushNotificationsApiPromise: Promise | nul export async function getNativePushNotificationsApi(): Promise { if (!nativePushNotificationsApiPromise) { nativePushNotificationsApiPromise = - import( - '@choochmeque/tauri-plugin-notifications-api' - ) as unknown as Promise; + import('@choochmeque/tauri-plugin-notifications-api') as unknown as Promise; } return nativePushNotificationsApiPromise; diff --git a/src/app/features/settings/notifications/SystemNotification.tsx b/src/app/features/settings/notifications/SystemNotification.tsx index 90d65a46a..f84a6b227 100644 --- a/src/app/features/settings/notifications/SystemNotification.tsx +++ b/src/app/features/settings/notifications/SystemNotification.tsx @@ -1,8 +1,7 @@ -import type { MouseEventHandler} from 'react'; +import type { MouseEventHandler } from 'react'; import { type FormEvent, useCallback, useEffect, useRef, useState } from 'react'; import FocusTrap from 'focus-trap-react'; -import type { - RectCords} from 'folds'; +import type { RectCords } from 'folds'; import { Box, Button, @@ -600,7 +599,8 @@ function BackgroundPushNotificationSetting() { ): UnifiedPushState => ({ endpoint: registration.endpoint, appId: effectivePushTransport.unifiedPushAppID?.trim() ?? DEFAULT_UNIFIED_PUSH_APP_ID, - gatewayUrl: registration.gatewayUrl ?? effectivePushTransport.unifiedPushGatewayUrl?.trim() ?? undefined, + gatewayUrl: + registration.gatewayUrl ?? effectivePushTransport.unifiedPushGatewayUrl?.trim() ?? undefined, status: 'registered', distributor: distributorOverride ?? registration.distributor, permissionState: 'granted', @@ -1237,4 +1237,4 @@ export function SystemNotification() { ); -} \ No newline at end of file +} diff --git a/src/app/features/settings/notifications/UnifiedPushNotifications.test.ts b/src/app/features/settings/notifications/UnifiedPushNotifications.test.ts index 250420d27..188108c30 100644 --- a/src/app/features/settings/notifications/UnifiedPushNotifications.test.ts +++ b/src/app/features/settings/notifications/UnifiedPushNotifications.test.ts @@ -34,8 +34,12 @@ const getTauriNotificationsApi = vi.hoisted(() => const matrixClient = vi.hoisted(() => ({ setPusher: vi.fn<() => Promise>().mockResolvedValue(undefined), getDeviceId: vi.fn<() => string>(() => 'DEVICE'), - getDevice: vi.fn<() => Promise<{ display_name: string }>>().mockResolvedValue({ display_name: 'Pixel' }), - getPushers: vi.fn<() => Promise<{ pushers: Array }>>().mockResolvedValue({ pushers: [] }), + getDevice: vi + .fn<() => Promise<{ display_name: string }>>() + .mockResolvedValue({ display_name: 'Pixel' }), + getPushers: vi + .fn<() => Promise<{ pushers: Array }>>() + .mockResolvedValue({ pushers: [] }), })); vi.mock('./UnifiedPushTransport', () => unifiedPushTransport); @@ -61,7 +65,10 @@ describe('UnifiedPushNotifications', () => { unifiedPushTransport.unregisterUnifiedPushTransport.mockResolvedValue(undefined); matrixClient.setPusher.mockClear(); matrixClient.getPushers.mockResolvedValue({ pushers: [] }); - vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('gateway probe failed'))); + vi.stubGlobal( + 'fetch', + vi.fn().mockRejectedValue(new Error('gateway probe failed')) + ); }); afterEach(() => { diff --git a/src/app/features/settings/notifications/UnifiedPushNotifications.ts b/src/app/features/settings/notifications/UnifiedPushNotifications.ts index 1137a15cd..d299ae6aa 100644 --- a/src/app/features/settings/notifications/UnifiedPushNotifications.ts +++ b/src/app/features/settings/notifications/UnifiedPushNotifications.ts @@ -323,9 +323,7 @@ async function postRoomNotification( const latestMsg = messages[messages.length - 1]; const latestBody = latestMsg ? `${latestMsg.sender?.name ?? 'You'}: ${latestMsg.text}` : ''; - const inboxLines = messages - .slice(-5) - .map((m) => `${m.sender?.name ?? 'You'}: ${m.text}`); + const inboxLines = messages.slice(-5).map((m) => `${m.sender?.name ?? 'You'}: ${m.text}`); await notificationsApi.sendNotification({ id: roomNotifId(roomId), @@ -371,10 +369,7 @@ async function postRoomNotification( } /** Handles a rich push payload containing full event details (type, room_name, content, etc.). */ -async function handleRichPushPayload( - pushData: UnifiedPushPayload, - settings: NotificationSettings -) { +async function handleRichPushPayload(pushData: UnifiedPushPayload, settings: NotificationSettings) { const eventType = pushData.type as EventType; switch (eventType) { diff --git a/src/app/features/settings/notifications/UnifiedPushTransport.test.ts b/src/app/features/settings/notifications/UnifiedPushTransport.test.ts index e4e6e4021..b94529df1 100644 --- a/src/app/features/settings/notifications/UnifiedPushTransport.test.ts +++ b/src/app/features/settings/notifications/UnifiedPushTransport.test.ts @@ -19,7 +19,9 @@ const unifiedPushApi = vi.hoisted(() => ({ })); vi.mock('./UnifiedPushTransportApiClient', () => ({ - getUnifiedPushTransportApi: vi.fn<() => Promise>().mockResolvedValue(unifiedPushApi), + getUnifiedPushTransportApi: vi + .fn<() => Promise>() + .mockResolvedValue(unifiedPushApi), })); afterEach(() => { @@ -47,9 +49,7 @@ describe('registerUnifiedPushTransport', () => { unifiedPushApi.requestPermission.mockResolvedValue('granted'); localStorage.removeItem('unifiedpush_distributor'); unifiedPushApi.listDistributors.mockResolvedValue(['org.unifiedpush.distributor.ntfy']); - unifiedPushApi.registerForPushNotifications.mockResolvedValue( - 'https://up.example/endpoint' - ); + unifiedPushApi.registerForPushNotifications.mockResolvedValue('https://up.example/endpoint'); await expect(registerUnifiedPushTransport()).resolves.toEqual({ status: 'registered', @@ -151,9 +151,7 @@ describe('UnifiedPush distributor state helpers', () => { distributors: ['org.unifiedpush.distributor.ntfy'], selectedDistributor: 'org.unifiedpush.distributor.ntfy', }); - expect(unifiedPushApi.setDistributor).toHaveBeenCalledWith( - 'org.unifiedpush.distributor.ntfy' - ); + expect(unifiedPushApi.setDistributor).toHaveBeenCalledWith('org.unifiedpush.distributor.ntfy'); }); it('ensures a distributor selection by auto-saving the first available distributor', async () => { @@ -175,9 +173,7 @@ describe('UnifiedPush distributor state helpers', () => { 'org.unifiedpush.distributor.removed' ) ).resolves.toBe('org.unifiedpush.distributor.ntfy'); - expect(unifiedPushApi.setDistributor).toHaveBeenCalledWith( - 'org.unifiedpush.distributor.ntfy' - ); + expect(unifiedPushApi.setDistributor).toHaveBeenCalledWith('org.unifiedpush.distributor.ntfy'); }); it('persists a selected distributor through the transport helper', async () => { @@ -199,7 +195,9 @@ describe('UnifiedPush distributor state helpers', () => { it('restores the previous distributor when a switch registration fails', async () => { unifiedPushApi.setDistributor.mockResolvedValue(undefined); - const register = vi.fn<() => Promise>().mockRejectedValue(new Error('registration failed')); + const register = vi + .fn<() => Promise>() + .mockRejectedValue(new Error('registration failed')); await expect( switchUnifiedPushDistributorSelection( diff --git a/src/app/generated/tauri/commands.ts b/src/app/generated/tauri/commands.ts index 3f18beca1..3eeab486d 100644 --- a/src/app/generated/tauri/commands.ts +++ b/src/app/generated/tauri/commands.ts @@ -30,7 +30,9 @@ export async function isWindowTrackingActive(): Promise { return invoke('is_window_tracking_active'); } -export async function loopbackFetch(params: types.LoopbackFetchParams): Promise { +export async function loopbackFetch( + params: types.LoopbackFetchParams +): Promise { return invoke('loopback_fetch', params); } @@ -46,7 +48,9 @@ export async function showSnapOverlay(): Promise { return invoke('show_snap_overlay'); } -export async function startWindowTrackingWithTarget(params: types.StartWindowTrackingWithTargetParams): Promise { +export async function startWindowTrackingWithTarget( + params: types.StartWindowTrackingWithTargetParams +): Promise { return invoke('start_window_tracking_with_target', params); } @@ -54,6 +58,8 @@ export async function stopWindowTracking(): Promise { return invoke('stop_window_tracking'); } -export async function syncDesktopSettings(params: types.SyncDesktopSettingsParams): Promise { +export async function syncDesktopSettings( + params: types.SyncDesktopSettingsParams +): Promise { return invoke('sync_desktop_settings', params); } diff --git a/src/app/generated/tauri/desktop/DesktopRuntimeState.ts b/src/app/generated/tauri/desktop/DesktopRuntimeState.ts index b5561254a..b0640f018 100644 --- a/src/app/generated/tauri/desktop/DesktopRuntimeState.ts +++ b/src/app/generated/tauri/desktop/DesktopRuntimeState.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type DesktopRuntimeState = { trayAvailable: boolean, }; +export type DesktopRuntimeState = { trayAvailable: boolean }; diff --git a/src/app/generated/tauri/desktop/DesktopSettings.ts b/src/app/generated/tauri/desktop/DesktopSettings.ts index 4367a6ccc..98fb9dcdf 100644 --- a/src/app/generated/tauri/desktop/DesktopSettings.ts +++ b/src/app/generated/tauri/desktop/DesktopSettings.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type DesktopSettings = { closeToBackgroundOnClose: boolean, showSystemTrayIcon: boolean, }; +export type DesktopSettings = { closeToBackgroundOnClose: boolean; showSystemTrayIcon: boolean }; diff --git a/src/app/generated/tauri/types.ts b/src/app/generated/tauri/types.ts index 6a938cbe6..869c14dec 100644 --- a/src/app/generated/tauri/types.ts +++ b/src/app/generated/tauri/types.ts @@ -67,4 +67,3 @@ export interface SyncDesktopSettingsParams { settings: DesktopSettings; [key: string]: unknown; } - diff --git a/src/app/hooks/useRenderableMediaUrl.test.tsx b/src/app/hooks/useRenderableMediaUrl.test.tsx index 3f09abe2c..7b2f49f0d 100644 --- a/src/app/hooks/useRenderableMediaUrl.test.tsx +++ b/src/app/hooks/useRenderableMediaUrl.test.tsx @@ -15,7 +15,9 @@ const mediaTransport = vi.hoisted(() => ({ const tauriApi = vi.hoisted(() => ({ isTauri: vi.fn<() => boolean>(), - convertFileSrc: vi.fn<(url: string, protocol: string) => string>((url: string, protocol: string) => `${protocol}://${url}`), + convertFileSrc: vi.fn<(url: string, protocol: string) => string>( + (url: string, protocol: string) => `${protocol}://${url}` + ), })); vi.mock('$utils/platform', () => platform); @@ -32,7 +34,9 @@ describe('useRenderableMediaUrl', () => { mediaTransport.getCurrentMediaSessionScope.mockReturnValue('anonymous'); tauriApi.isTauri.mockReset(); tauriApi.convertFileSrc.mockReset(); - tauriApi.convertFileSrc.mockImplementation((url: string, protocol: string) => `${protocol}://${url}`); + tauriApi.convertFileSrc.mockImplementation( + (url: string, protocol: string) => `${protocol}://${url}` + ); vi.spyOn(URL, 'createObjectURL').mockReturnValue('blob:rendered-media'); vi.spyOn(URL, 'revokeObjectURL').mockImplementation(() => undefined); Object.defineProperty(navigator, 'serviceWorker', { @@ -205,7 +209,8 @@ describe('useRenderableMediaUrl', () => { tauriApi.isTauri.mockReturnValue(true); const { useRenderableMediaUrl } = await import('./useRenderableMediaUrl'); - const rawAuthUrl = 'https://matrix.example.org/_matrix/client/v1/media/thumbnail/example.org/abc123?width=96&height=96'; + const rawAuthUrl = + 'https://matrix.example.org/_matrix/client/v1/media/thumbnail/example.org/abc123?width=96&height=96'; const { result } = renderHook(() => useRenderableMediaUrl(rawAuthUrl)); expect(result.current).toBe(`sable-media://${rawAuthUrl}`); @@ -216,7 +221,8 @@ describe('useRenderableMediaUrl', () => { tauriApi.isTauri.mockReturnValue(true); const { useRenderableMediaUrl } = await import('./useRenderableMediaUrl'); - const rewrittenUrl = 'sable-media://https://matrix.example.org/_matrix/client/v1/media/thumbnail/example.org/abc123'; + const rewrittenUrl = + 'sable-media://https://matrix.example.org/_matrix/client/v1/media/thumbnail/example.org/abc123'; const { result } = renderHook(() => useRenderableMediaUrl(rewrittenUrl)); expect(result.current).toBe(rewrittenUrl); diff --git a/src/app/pages/auth/SSOTauri.ts b/src/app/pages/auth/SSOTauri.ts index 378924474..91f9a4716 100644 --- a/src/app/pages/auth/SSOTauri.ts +++ b/src/app/pages/auth/SSOTauri.ts @@ -40,8 +40,7 @@ const TAURI_OIDC_PROTOCOL = 'moe.sable.app:'; const TAURI_OIDC_PATH = '/login'; const TAURI_OIDC_SERVER_KEY = 'sable:tauri-oidc:server'; -export const buildTauriOidcRedirectUrl = (): string => - `${TAURI_OIDC_PROTOCOL}${TAURI_OIDC_PATH}`; +export const buildTauriOidcRedirectUrl = (): string => `${TAURI_OIDC_PROTOCOL}${TAURI_OIDC_PATH}`; export const rememberTauriOidcServer = (server?: string): void => { try { diff --git a/src/app/state/desktopSettings.test.ts b/src/app/state/desktopSettings.test.ts index f1127fbd5..424218eac 100644 --- a/src/app/state/desktopSettings.test.ts +++ b/src/app/state/desktopSettings.test.ts @@ -18,9 +18,13 @@ const { mockClose, mockEntries, mockGetDesktopRuntimeState, mockSet, mockSyncDes vi.hoisted(() => ({ mockClose: vi.fn<() => Promise>(), mockEntries: vi.fn<() => Promise>>(), - mockGetDesktopRuntimeState: vi.fn<() => Promise>().mockResolvedValue({ trayAvailable: true }), + mockGetDesktopRuntimeState: vi + .fn<() => Promise>() + .mockResolvedValue({ trayAvailable: true }), mockSet: vi.fn<(key: string, value: unknown) => Promise>(), - mockSyncDesktopSettings: vi.fn<(params: SyncDesktopSettingsParams) => Promise>().mockResolvedValue({ trayAvailable: false }), + mockSyncDesktopSettings: vi + .fn<(params: SyncDesktopSettingsParams) => Promise>() + .mockResolvedValue({ trayAvailable: false }), })); vi.mock('@tauri-apps/plugin-store', () => ({ diff --git a/src/app/state/hooks/desktopSettings.test.tsx b/src/app/state/hooks/desktopSettings.test.tsx index f2102a41f..ca2f86f94 100644 --- a/src/app/state/hooks/desktopSettings.test.tsx +++ b/src/app/state/hooks/desktopSettings.test.tsx @@ -9,9 +9,13 @@ import { useDesktopSetting } from './desktopSettings'; const { mockEntries, mockGetDesktopRuntimeState, mockSet, mockSyncDesktopSettings } = vi.hoisted( () => ({ mockEntries: vi.fn<() => Promise>>(), - mockGetDesktopRuntimeState: vi.fn<() => Promise>().mockResolvedValue({ trayAvailable: true }), + mockGetDesktopRuntimeState: vi + .fn<() => Promise>() + .mockResolvedValue({ trayAvailable: true }), mockSet: vi.fn<(key: string, value: unknown) => Promise>(), - mockSyncDesktopSettings: vi.fn<(params: SyncDesktopSettingsParams) => Promise>().mockResolvedValue({ trayAvailable: true }), + mockSyncDesktopSettings: vi + .fn<(params: SyncDesktopSettingsParams) => Promise>() + .mockResolvedValue({ trayAvailable: true }), }) ); diff --git a/src/app/utils/download.ts b/src/app/utils/download.ts index 7ab144243..769277ba4 100644 --- a/src/app/utils/download.ts +++ b/src/app/utils/download.ts @@ -66,9 +66,8 @@ export async function saveFileToDevice( if (isTauri() && osType() === 'android') { const blob = await resolveBlob(input); const bytes = new Uint8Array(await blob.arrayBuffer()); - const { AndroidFs, AndroidPublicGeneralPurposeDir } = await import( - 'tauri-plugin-android-fs-api' - ); + const { AndroidFs, AndroidPublicGeneralPurposeDir } = + await import('tauri-plugin-android-fs-api'); const uri = await AndroidFs.createNewPublicFile( AndroidPublicGeneralPurposeDir.Download, filename, diff --git a/src/app/utils/matrix.test.ts b/src/app/utils/matrix.test.ts index 3fbb85275..ac0a78040 100644 --- a/src/app/utils/matrix.test.ts +++ b/src/app/utils/matrix.test.ts @@ -2,7 +2,9 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'; const tauriApi = vi.hoisted(() => ({ isTauri: vi.fn<() => boolean>(), - convertFileSrc: vi.fn<(url: string, protocol: string) => string>((url: string, protocol: string) => `${protocol}://${url}`), + convertFileSrc: vi.fn<(url: string, protocol: string) => string>( + (url: string, protocol: string) => `${protocol}://${url}` + ), })); vi.mock('@tauri-apps/api/core', () => tauriApi); @@ -42,13 +44,15 @@ describe('rewriteAuthenticatedMediaUrl', () => { it('rewrites authenticated-media thumbnail URLs under Tauri', () => { tauriApi.isTauri.mockReturnValue(true); - const url = 'https://matrix.example.org/_matrix/client/v1/media/thumbnail/example.org/abc123?width=96&height=96&method=crop'; + const url = + 'https://matrix.example.org/_matrix/client/v1/media/thumbnail/example.org/abc123?width=96&height=96&method=crop'; expect(rewriteAuthenticatedMediaUrl(url)).toBe(`sable-media://${url}`); }); it('passes through already-rewritten sable-media:// URLs', () => { tauriApi.isTauri.mockReturnValue(true); - const url = 'sable-media://https://matrix.example.org/_matrix/client/v1/media/download/example.org/abc123'; + const url = + 'sable-media://https://matrix.example.org/_matrix/client/v1/media/download/example.org/abc123'; expect(rewriteAuthenticatedMediaUrl(url)).toBe(url); expect(tauriApi.convertFileSrc).not.toHaveBeenCalled(); }); diff --git a/src/app/utils/mediaTransport.test.ts b/src/app/utils/mediaTransport.test.ts index 7fa3b0c40..2eba3368d 100644 --- a/src/app/utils/mediaTransport.test.ts +++ b/src/app/utils/mediaTransport.test.ts @@ -8,15 +8,21 @@ const mediaCache = vi.hoisted(() => { const cache = new Map(); return { cache, - getFromMediaCache: vi.fn<(url: string) => Promise>(async (url: string) => cache.get(url)), - putInMediaCache: vi.fn<(url: string, blob: Blob) => Promise>(async (url: string, blob: Blob) => { - cache.set(url, blob); - }), + getFromMediaCache: vi.fn<(url: string) => Promise>(async (url: string) => + cache.get(url) + ), + putInMediaCache: vi.fn<(url: string, blob: Blob) => Promise>( + async (url: string, blob: Blob) => { + cache.set(url, blob); + } + ), }; }); const appFetch = vi.hoisted(() => ({ - fetch: vi.fn<(input: RequestInfo | URL, init?: RequestInit) => Promise>((input: RequestInfo | URL, init?: RequestInit) => globalThis.fetch(input, init)), + fetch: vi.fn<(input: RequestInfo | URL, init?: RequestInit) => Promise>( + (input: RequestInfo | URL, init?: RequestInit) => globalThis.fetch(input, init) + ), })); vi.mock('$utils/platform', () => platform); diff --git a/src/serviceWorkerBootstrap.test.ts b/src/serviceWorkerBootstrap.test.ts index 7c4c264b6..6b2f42a56 100644 --- a/src/serviceWorkerBootstrap.test.ts +++ b/src/serviceWorkerBootstrap.test.ts @@ -11,11 +11,25 @@ const { } = vi.hoisted(() => ({ mockHasServiceWorker: vi.fn<() => boolean>(), mockRegister: vi.fn<() => Promise>>().mockResolvedValue({ - addEventListener: vi.fn<(type: string, listener: EventListenerOrEventListenerObject, options?: AddEventListenerOptions | boolean) => void>(), + addEventListener: + vi.fn< + ( + type: string, + listener: EventListenerOrEventListenerObject, + options?: AddEventListenerOptions | boolean + ) => void + >(), installing: null, waiting: null, }), - mockAddEventListener: vi.fn<(type: string, listener: EventListenerOrEventListenerObject, options?: AddEventListenerOptions | boolean) => void>(), + mockAddEventListener: + vi.fn< + ( + type: string, + listener: EventListenerOrEventListenerObject, + options?: AddEventListenerOptions | boolean + ) => void + >(), mockReady: Promise.resolve(undefined), mockPushSessionToSW: vi.fn<(baseUrl?: string, accessToken?: string, userId?: string) => void>(), mockWarn: vi.fn<(...args: unknown[]) => void>(), @@ -36,7 +50,9 @@ vi.mock('./app/state/sessions', () => ({ })); vi.mock('./app/state/utils/atomWithLocalStorage', () => ({ - getLocalStorageItem: vi.fn<(key: string, fallback: unknown) => unknown>((_: string, fallback: unknown) => fallback), + getLocalStorageItem: vi.fn<(key: string, fallback: unknown) => unknown>( + (_: string, fallback: unknown) => fallback + ), })); vi.mock('./app/utils/debug', () => ({ @@ -99,7 +115,9 @@ describe('registerAppServiceWorker', () => { serviceWorker: { register: mockRegister, ready: mockReady, - controller: { postMessage: vi.fn<(message: unknown, transfer?: Transferable[]) => void>() }, + controller: { + postMessage: vi.fn<(message: unknown, transfer?: Transferable[]) => void>(), + }, addEventListener: mockAddEventListener, }, }, diff --git a/src/serviceWorkerBootstrap.ts b/src/serviceWorkerBootstrap.ts index 68ff98302..566bf6179 100644 --- a/src/serviceWorkerBootstrap.ts +++ b/src/serviceWorkerBootstrap.ts @@ -1,12 +1,7 @@ import { trimTrailingSlash } from './app/utils/common'; import { createLogger } from './app/utils/debug'; -import type { - Sessions} from './app/state/sessions'; -import { - getFallbackSession, - MATRIX_SESSIONS_KEY, - ACTIVE_SESSION_KEY, -} from './app/state/sessions'; +import type { Sessions } from './app/state/sessions'; +import { getFallbackSession, MATRIX_SESSIONS_KEY, ACTIVE_SESSION_KEY } from './app/state/sessions'; import { getLocalStorageItem } from './app/state/utils/atomWithLocalStorage'; import { hasServiceWorker } from './app/utils/platform'; import { pushSessionToSW } from './sw-session'; diff --git a/src/types/tauri-plugin-notifications-api.d.ts b/src/types/tauri-plugin-notifications-api.d.ts index a999d02a8..bec70ff8e 100644 --- a/src/types/tauri-plugin-notifications-api.d.ts +++ b/src/types/tauri-plugin-notifications-api.d.ts @@ -41,7 +41,7 @@ declare module '@choochmeque/tauri-plugin-notifications-api' { lights?: boolean; lightColor?: string; vibration?: boolean; - importance?: typeof Importance[keyof typeof Importance]; + importance?: (typeof Importance)[keyof typeof Importance]; visibility?: number; };