This commit is contained in:
Erwan Leboucher committed 2026-07-18 13:40:36 +02:00
1 parent 1fe606eaaa
commit 3a8bd64d1a
29 files changed
+149 -85

No files matched your search

+13 -3
View File
@@ -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]
+16 -2
View File
@@ -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": [
+1 -1
View File
@@ -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';
@@ -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]);
@@ -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;
}
}
@@ -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;
+1 -1
View File
@@ -2006,4 +2006,4 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
</div>
);
}
);
);
@@ -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;
@@ -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;
@@ -22,8 +22,12 @@ const getNativePushNotificationsApi = vi.hoisted(() =>
const matrixClient = vi.hoisted(() => ({
setPusher: vi.fn<() => Promise<void>>().mockResolvedValue(undefined),
getDeviceId: vi.fn<() => string>(() => 'DEVICE'),
getDevice: vi.fn<() => Promise<{ display_name: string }>>().mockResolvedValue({ display_name: 'Pixel' }),
getPushers: vi.fn<() => Promise<{ pushers: Array<unknown> }>>().mockResolvedValue({ pushers: [] }),
getDevice: vi
.fn<() => Promise<{ display_name: string }>>()
.mockResolvedValue({ display_name: 'Pixel' }),
getPushers: vi
.fn<() => Promise<{ pushers: Array<unknown> }>>()
.mockResolvedValue({ pushers: [] }),
}));
const nativePushClientConfig = {
@@ -10,9 +10,7 @@ let nativePushNotificationsApiPromise: Promise<NativePushNotificationsApi> | nul
export async function getNativePushNotificationsApi(): Promise<NativePushNotificationsApi> {
if (!nativePushNotificationsApiPromise) {
nativePushNotificationsApiPromise =
import(
'@choochmeque/tauri-plugin-notifications-api'
) as unknown as Promise<NativePushNotificationsApi>;
import('@choochmeque/tauri-plugin-notifications-api') as unknown as Promise<NativePushNotificationsApi>;
}
return nativePushNotificationsApiPromise;
@@ -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() {
</SequenceCard>
</Box>
);
}
}
@@ -34,8 +34,12 @@ const getTauriNotificationsApi = vi.hoisted(() =>
const matrixClient = vi.hoisted(() => ({
setPusher: vi.fn<() => Promise<void>>().mockResolvedValue(undefined),
getDeviceId: vi.fn<() => string>(() => 'DEVICE'),
getDevice: vi.fn<() => Promise<{ display_name: string }>>().mockResolvedValue({ display_name: 'Pixel' }),
getPushers: vi.fn<() => Promise<{ pushers: Array<unknown> }>>().mockResolvedValue({ pushers: [] }),
getDevice: vi
.fn<() => Promise<{ display_name: string }>>()
.mockResolvedValue({ display_name: 'Pixel' }),
getPushers: vi
.fn<() => Promise<{ pushers: Array<unknown> }>>()
.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<typeof fetch>().mockRejectedValue(new Error('gateway probe failed')));
vi.stubGlobal(
'fetch',
vi.fn<typeof fetch>().mockRejectedValue(new Error('gateway probe failed'))
);
});
afterEach(() => {
@@ -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) {
@@ -19,7 +19,9 @@ const unifiedPushApi = vi.hoisted(() => ({
}));
vi.mock('./UnifiedPushTransportApiClient', () => ({
getUnifiedPushTransportApi: vi.fn<() => Promise<typeof unifiedPushApi>>().mockResolvedValue(unifiedPushApi),
getUnifiedPushTransportApi: vi
.fn<() => Promise<typeof unifiedPushApi>>()
.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<void>>().mockRejectedValue(new Error('registration failed'));
const register = vi
.fn<() => Promise<void>>()
.mockRejectedValue(new Error('registration failed'));
await expect(
switchUnifiedPushDistributorSelection(
+9 -3
View File
@@ -30,7 +30,9 @@ export async function isWindowTrackingActive(): Promise<boolean> {
return invoke('is_window_tracking_active');
}
export async function loopbackFetch(params: types.LoopbackFetchParams): Promise<types.LoopbackFetchResponse> {
export async function loopbackFetch(
params: types.LoopbackFetchParams
): Promise<types.LoopbackFetchResponse> {
return invoke('loopback_fetch', params);
}
@@ -46,7 +48,9 @@ export async function showSnapOverlay(): Promise<void> {
return invoke('show_snap_overlay');
}
export async function startWindowTrackingWithTarget(params: types.StartWindowTrackingWithTargetParams): Promise<void> {
export async function startWindowTrackingWithTarget(
params: types.StartWindowTrackingWithTargetParams
): Promise<void> {
return invoke('start_window_tracking_with_target', params);
}
@@ -54,6 +58,8 @@ export async function stopWindowTracking(): Promise<void> {
return invoke('stop_window_tracking');
}
export async function syncDesktopSettings(params: types.SyncDesktopSettingsParams): Promise<types.DesktopRuntimeState> {
export async function syncDesktopSettings(
params: types.SyncDesktopSettingsParams
): Promise<types.DesktopRuntimeState> {
return invoke('sync_desktop_settings', params);
}
@@ -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 };
@@ -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 };
-1
View File
@@ -67,4 +67,3 @@ export interface SyncDesktopSettingsParams {
settings: DesktopSettings;
[key: string]: unknown;
}
+10 -4
View File
@@ -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);
+1 -2
View File
@@ -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 {
+6 -2
View File
@@ -18,9 +18,13 @@ const { mockClose, mockEntries, mockGetDesktopRuntimeState, mockSet, mockSyncDes
vi.hoisted(() => ({
mockClose: vi.fn<() => Promise<unknown>>(),
mockEntries: vi.fn<() => Promise<Array<[string, unknown]>>>(),
mockGetDesktopRuntimeState: vi.fn<() => Promise<DesktopRuntimeState>>().mockResolvedValue({ trayAvailable: true }),
mockGetDesktopRuntimeState: vi
.fn<() => Promise<DesktopRuntimeState>>()
.mockResolvedValue({ trayAvailable: true }),
mockSet: vi.fn<(key: string, value: unknown) => Promise<unknown>>(),
mockSyncDesktopSettings: vi.fn<(params: SyncDesktopSettingsParams) => Promise<DesktopRuntimeState>>().mockResolvedValue({ trayAvailable: false }),
mockSyncDesktopSettings: vi
.fn<(params: SyncDesktopSettingsParams) => Promise<DesktopRuntimeState>>()
.mockResolvedValue({ trayAvailable: false }),
}));
vi.mock('@tauri-apps/plugin-store', () => ({
+6 -2
View File
@@ -9,9 +9,13 @@ import { useDesktopSetting } from './desktopSettings';
const { mockEntries, mockGetDesktopRuntimeState, mockSet, mockSyncDesktopSettings } = vi.hoisted(
() => ({
mockEntries: vi.fn<() => Promise<Array<[string, unknown]>>>(),
mockGetDesktopRuntimeState: vi.fn<() => Promise<DesktopRuntimeState>>().mockResolvedValue({ trayAvailable: true }),
mockGetDesktopRuntimeState: vi
.fn<() => Promise<DesktopRuntimeState>>()
.mockResolvedValue({ trayAvailable: true }),
mockSet: vi.fn<(key: string, value: unknown) => Promise<unknown>>(),
mockSyncDesktopSettings: vi.fn<(params: SyncDesktopSettingsParams) => Promise<DesktopRuntimeState>>().mockResolvedValue({ trayAvailable: true }),
mockSyncDesktopSettings: vi
.fn<(params: SyncDesktopSettingsParams) => Promise<DesktopRuntimeState>>()
.mockResolvedValue({ trayAvailable: true }),
})
);
+2 -3
View File
@@ -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,
+7 -3
View File
@@ -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();
});
+11 -5
View File
@@ -8,15 +8,21 @@ const mediaCache = vi.hoisted(() => {
const cache = new Map<string, Blob>();
return {
cache,
getFromMediaCache: vi.fn<(url: string) => Promise<Blob | undefined>>(async (url: string) => cache.get(url)),
putInMediaCache: vi.fn<(url: string, blob: Blob) => Promise<void>>(async (url: string, blob: Blob) => {
cache.set(url, blob);
}),
getFromMediaCache: vi.fn<(url: string) => Promise<Blob | undefined>>(async (url: string) =>
cache.get(url)
),
putInMediaCache: vi.fn<(url: string, blob: Blob) => Promise<void>>(
async (url: string, blob: Blob) => {
cache.set(url, blob);
}
),
};
});
const appFetch = vi.hoisted(() => ({
fetch: vi.fn<(input: RequestInfo | URL, init?: RequestInit) => Promise<Response>>((input: RequestInfo | URL, init?: RequestInit) => globalThis.fetch(input, init)),
fetch: vi.fn<(input: RequestInfo | URL, init?: RequestInit) => Promise<Response>>(
(input: RequestInfo | URL, init?: RequestInit) => globalThis.fetch(input, init)
),
}));
vi.mock('$utils/platform', () => platform);
+22 -4
View File
@@ -11,11 +11,25 @@ const {
} = vi.hoisted(() => ({
mockHasServiceWorker: vi.fn<() => boolean>(),
mockRegister: vi.fn<() => Promise<Partial<ServiceWorkerRegistration>>>().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,
},
},
+2 -7
View File
@@ -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';
+1 -1
View File
@@ -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;
};