mirror of
https://github.com/lux-tel/session-desktop.git
synced 2026-10-30 20:33:24 +00:00
25 lines
767 B
TypeScript
25 lines
767 B
TypeScript
import type { ConversationNotificationSettingType } from '../../models/conversationAttributes';
|
|
import { ConvoHub } from '../../session/conversations';
|
|
|
|
async function setNotificationForConvoId(
|
|
conversationId: string,
|
|
selected: ConversationNotificationSettingType
|
|
) {
|
|
const conversation = ConvoHub.use().get(conversationId);
|
|
|
|
const existingSettings = conversation.getNotificationsFor();
|
|
if (existingSettings !== selected) {
|
|
conversation.setNotificationsFor(selected);
|
|
await conversation.commit();
|
|
}
|
|
}
|
|
|
|
export function useSetNotificationsFor(conversationId?: string) {
|
|
return (selected: ConversationNotificationSettingType) => {
|
|
if (!conversationId) {
|
|
return;
|
|
}
|
|
void setNotificationForConvoId(conversationId, selected);
|
|
};
|
|
}
|