mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-06 00:15:32 +00:00
fix: carry the inbox-only choice into bulk push and use the shared icons
Upstream now requires inboxOnly when enabling push and replaced lucide-react with the shared icon module; the bulk path had neither.
This commit is contained in:
@@ -2,11 +2,12 @@
|
||||
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { Loader2 } from 'lucide-react';
|
||||
import { Loader2 } from '@/components/icons';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { SettingsSection } from './settings-section';
|
||||
import { useAccountStore } from '@/stores/account-store';
|
||||
import { useAuthStore } from '@/stores/auth-store';
|
||||
import { useSettingsStore } from '@/stores/settings-store';
|
||||
import { disableWebPush, enableWebPushForAccounts, isWebPushEnabled, isWebPushSupported } from '@/lib/web-push';
|
||||
|
||||
/**
|
||||
@@ -55,7 +56,7 @@ export function MultiAccountPushSettings({ relayBaseUrl }: { relayBaseUrl?: stri
|
||||
if (action === 'enable') {
|
||||
const outcome = await enableWebPushForAccounts(
|
||||
targets.map(a => ({ accountId: a.id, client: auth.getClientForAccount(a.id)!, accountLabel: a.username })),
|
||||
{ relayBaseUrl },
|
||||
{ relayBaseUrl, inboxOnly: useSettingsStore.getState().pushNotifyInboxOnly },
|
||||
);
|
||||
setNotice(outcome.failed.length
|
||||
? t('result_partial', { enabled: outcome.enabled.length, failed: outcome.failed.length })
|
||||
|
||||
@@ -617,7 +617,7 @@ describe('enableWebPushForAccounts', () => {
|
||||
const result = await enableWebPushForAccounts([
|
||||
{ accountId: 'a', client: first, accountLabel: 'one' },
|
||||
{ accountId: 'b', client: second, accountLabel: 'two' },
|
||||
], { relayBaseUrl: RELAY });
|
||||
], { relayBaseUrl: RELAY, inboxOnly: false });
|
||||
|
||||
expect(result.enabled).toEqual(['a', 'b']);
|
||||
expect(result.failed).toEqual([]);
|
||||
@@ -637,7 +637,7 @@ describe('enableWebPushForAccounts', () => {
|
||||
const result = await enableWebPushForAccounts([
|
||||
{ accountId: 'a', client: first },
|
||||
{ accountId: 'b', client: second },
|
||||
], { relayBaseUrl: RELAY });
|
||||
], { relayBaseUrl: RELAY, inboxOnly: false });
|
||||
|
||||
expect(result.enabled).toEqual([]);
|
||||
expect(result.failed.map(f => f.accountId)).toEqual(['a', 'b']);
|
||||
|
||||
+3
-1
@@ -791,7 +791,8 @@ export interface BulkWebPushResult {
|
||||
*/
|
||||
export async function enableWebPushForAccounts(
|
||||
targets: BulkWebPushTarget[],
|
||||
options: { relayBaseUrl?: string; forceRecreate?: boolean } = {},
|
||||
// inboxOnly mirrors settings-store's pushNotifyInboxOnly, as for a single account.
|
||||
options: { relayBaseUrl?: string; forceRecreate?: boolean; inboxOnly: boolean },
|
||||
): Promise<BulkWebPushResult> {
|
||||
const result: BulkWebPushResult = { enabled: [], failed: [] };
|
||||
let browserRefusal: unknown;
|
||||
@@ -806,6 +807,7 @@ export async function enableWebPushForAccounts(
|
||||
relayBaseUrl: options.relayBaseUrl,
|
||||
accountLabel: target.accountLabel,
|
||||
forceRecreate: options.forceRecreate,
|
||||
inboxOnly: options.inboxOnly,
|
||||
});
|
||||
result.enabled.push(target.accountId);
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user