refactor: remove redundant spread fallbacks

This commit is contained in:
Peter Steinberger 2026-01-13 07:29:18 +00:00
parent 3eb48cbea7
commit fcac2464e6
4 changed files with 4 additions and 7 deletions

View File

@ -106,10 +106,7 @@ export function deleteAccountFromConfigSection(params: {
} as ClawdbotConfig; } as ClawdbotConfig;
} }
const nextChannels = { ...(params.cfg.channels ?? {}) } as Record< const nextChannels = { ...params.cfg.channels } as Record<string, unknown>;
string,
unknown
>;
delete nextChannels[params.sectionKey]; delete nextChannels[params.sectionKey];
const nextCfg = { ...params.cfg } as ClawdbotConfig; const nextCfg = { ...params.cfg } as ClawdbotConfig;
if (Object.keys(nextChannels).length > 0) { if (Object.keys(nextChannels).length > 0) {

View File

@ -67,7 +67,7 @@ export const msteamsPlugin: ChannelPlugin<ResolvedMSTeamsAccount> = {
}), }),
deleteAccount: ({ cfg }) => { deleteAccount: ({ cfg }) => {
const next = { ...cfg } as ClawdbotConfig; const next = { ...cfg } as ClawdbotConfig;
const nextChannels = { ...(cfg.channels ?? {}) }; const nextChannels = { ...cfg.channels };
delete nextChannels.msteams; delete nextChannels.msteams;
if (Object.keys(nextChannels).length > 0) { if (Object.keys(nextChannels).length > 0) {
next.channels = nextChannels; next.channels = nextChannels;

View File

@ -462,7 +462,7 @@ export const telegramPlugin: ChannelPlugin<ResolvedTelegramAccount> = {
if (nextTelegram && Object.keys(nextTelegram).length > 0) { if (nextTelegram && Object.keys(nextTelegram).length > 0) {
nextCfg.channels = { ...nextCfg.channels, telegram: nextTelegram }; nextCfg.channels = { ...nextCfg.channels, telegram: nextTelegram };
} else { } else {
const nextChannels = { ...(nextCfg.channels ?? {}) }; const nextChannels = { ...nextCfg.channels };
delete nextChannels.telegram; delete nextChannels.telegram;
if (Object.keys(nextChannels).length > 0) { if (Object.keys(nextChannels).length > 0) {
nextCfg.channels = nextChannels; nextCfg.channels = nextChannels;

View File

@ -620,7 +620,7 @@ async function removeChannelConfigWizard(
); );
if (!confirmed) continue; if (!confirmed) continue;
const nextChannels: Record<string, unknown> = { ...(next.channels ?? {}) }; const nextChannels: Record<string, unknown> = { ...next.channels };
delete nextChannels[channel]; delete nextChannels[channel];
next = { next = {
...next, ...next,