Skip to content

Commit

Permalink
feat: handle-notification-changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Binatik committed Oct 21, 2024
1 parent a187ec7 commit 3a480a2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/actions/handleEngineUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function handleEngineUpdates(fromPts: number, updates: IEngine.Upda
const { api } = useEnv()

const hasUsefulUpdates = updates.some(([eventId]) => (
(eventId >= 10002 && eventId <= 10007) || eventId === 10018
(eventId >= 10002 && eventId <= 10007) || eventId === 10018 || eventId === 114
))
if (!hasUsefulUpdates) {
return
Expand Down Expand Up @@ -141,6 +141,16 @@ export async function handleEngineUpdates(fromPts: number, updates: IEngine.Upda
}
break
}

case 114: {
const [, setting] = update
const peerId = Peer.resolveId(setting.peer_id)
const convo = Convo.safeGet(peerId)

convo.notifications.enabled = Boolean(setting.sound)
convo.notifications.disabledUntil = setting.disabled_until
break
}
}
}
}
11 changes: 11 additions & 0 deletions src/env/IEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type Update =
| Update10006
| Update10007
| Update10018
| Update114

// Изменение флагов сообщения
type Update10002 = [
Expand Down Expand Up @@ -132,3 +133,13 @@ type Update10018 = [
messageId: Update10004[10],
updateTimestampInSeconds: number
]

// Изменение настроек пуш-уведомлений в беседе
type Update114 = [
type: 114,
data: {
peer_id: number
sound: 0 | 1
disabled_until: number
}
]

0 comments on commit 3a480a2

Please sign in to comment.