44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import type { ActionReturnType } from '../../types';
|
|
|
|
import { addActionHandler, setGlobal } from '../../index';
|
|
import {
|
|
addNotifyException, updateChat, updateNotifySettings,
|
|
updateTopic,
|
|
} from '../../reducers';
|
|
|
|
addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => {
|
|
switch (update['@type']) {
|
|
case 'updateNotifySettings': {
|
|
return updateNotifySettings(global, update.peerType, update.isSilent, update.shouldShowPreviews);
|
|
}
|
|
|
|
case 'updateNotifyExceptions': {
|
|
const {
|
|
chatId, isMuted, isSilent, shouldShowPreviews,
|
|
} = update;
|
|
const chat = global.chats.byId[chatId];
|
|
|
|
if (chat) {
|
|
global = updateChat(global, chatId, { isMuted });
|
|
}
|
|
|
|
global = addNotifyException(global, chatId, { isMuted, isSilent, shouldShowPreviews });
|
|
setGlobal(global);
|
|
break;
|
|
}
|
|
|
|
case 'updateTopicNotifyExceptions': {
|
|
const {
|
|
chatId, topicId, isMuted,
|
|
} = update;
|
|
|
|
global = updateTopic(global, chatId, topicId, { isMuted });
|
|
|
|
setGlobal(global);
|
|
break;
|
|
}
|
|
}
|
|
|
|
return undefined;
|
|
});
|