mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 10:33:41 -05:00
web/preferences: implement read receipt, typing notification and emoji pack options
This commit is contained in:
parent
795eef1449
commit
1cef899e5c
3 changed files with 17 additions and 10 deletions
|
@ -83,9 +83,9 @@ export function useCustomEmojis(
|
||||||
ss.emojiRoomsSub.subscribe,
|
ss.emojiRoomsSub.subscribe,
|
||||||
() => ss.getRoomEmojiPacks(),
|
() => ss.getRoomEmojiPacks(),
|
||||||
)
|
)
|
||||||
const specialRoomPacks = useSyncExternalStore(
|
const specialRoomPacks = useSyncExternalStore<Record<string, CustomEmojiPack>>(
|
||||||
room.stateSubs.getSubscriber("im.ponies.room_emotes"),
|
room.stateSubs.getSubscriber("im.ponies.room_emotes"),
|
||||||
() => room.getAllEmojiPacks(),
|
() => room.preferences.show_room_emoji_packs ? room.getAllEmojiPacks() : {},
|
||||||
)
|
)
|
||||||
return useMemo(() => {
|
return useMemo(() => {
|
||||||
const allPacksObject = { ...watchedRoomPacks, ...specialRoomPacks }
|
const allPacksObject = { ...watchedRoomPacks, ...specialRoomPacks }
|
||||||
|
|
|
@ -262,12 +262,16 @@ const MessageComposer = () => {
|
||||||
const now = Date.now()
|
const now = Date.now()
|
||||||
if (evt.target.value !== "" && typingSentAt.current + 5_000 < now) {
|
if (evt.target.value !== "" && typingSentAt.current + 5_000 < now) {
|
||||||
typingSentAt.current = now
|
typingSentAt.current = now
|
||||||
client.rpc.setTyping(room.roomID, 10_000)
|
if (room.preferences.send_typing_notifications) {
|
||||||
.catch(err => console.error("Failed to send typing notification:", err))
|
client.rpc.setTyping(room.roomID, 10_000)
|
||||||
|
.catch(err => console.error("Failed to send typing notification:", err))
|
||||||
|
}
|
||||||
} else if (evt.target.value === "" && typingSentAt.current > 0) {
|
} else if (evt.target.value === "" && typingSentAt.current > 0) {
|
||||||
typingSentAt.current = 0
|
typingSentAt.current = 0
|
||||||
client.rpc.setTyping(room.roomID, 0)
|
if (room.preferences.send_typing_notifications) {
|
||||||
.catch(err => console.error("Failed to send stop typing notification:", err))
|
client.rpc.setTyping(room.roomID, 0)
|
||||||
|
.catch(err => console.error("Failed to send stop typing notification:", err))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
onComposerCaretChange(evt, evt.target.value)
|
onComposerCaretChange(evt, evt.target.value)
|
||||||
})
|
})
|
||||||
|
@ -322,11 +326,13 @@ const MessageComposer = () => {
|
||||||
return () => {
|
return () => {
|
||||||
if (typingSentAt.current > 0) {
|
if (typingSentAt.current > 0) {
|
||||||
typingSentAt.current = 0
|
typingSentAt.current = 0
|
||||||
client.rpc.setTyping(room.roomID, 0)
|
if (room.preferences.send_typing_notifications) {
|
||||||
.catch(err => console.error("Failed to send stop typing notification due to room switch:", err))
|
client.rpc.setTyping(room.roomID, 0)
|
||||||
|
.catch(err => console.error("Failed to send stop typing notification due to room switch:", err))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [client, room.roomID])
|
}, [client, room])
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (!textInput.current) {
|
if (!textInput.current) {
|
||||||
return
|
return
|
||||||
|
|
|
@ -79,7 +79,8 @@ const TimelineView = () => {
|
||||||
&& newestEvent.sender !== client.userID
|
&& newestEvent.sender !== client.userID
|
||||||
) {
|
) {
|
||||||
room.readUpToRow = newestEvent.timeline_rowid
|
room.readUpToRow = newestEvent.timeline_rowid
|
||||||
client.rpc.markRead(room.roomID, newestEvent.event_id, "m.read").then(
|
const receiptType = roomCtx.store.preferences.send_read_receipts ? "m.read" : "m.read.private"
|
||||||
|
client.rpc.markRead(room.roomID, newestEvent.event_id, receiptType).then(
|
||||||
() => console.log("Marked read up to", newestEvent.event_id, newestEvent.timeline_rowid),
|
() => console.log("Marked read up to", newestEvent.event_id, newestEvent.timeline_rowid),
|
||||||
err => console.error(`Failed to send read receipt for ${newestEvent.event_id}:`, err),
|
err => console.error(`Failed to send read receipt for ${newestEvent.event_id}:`, err),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue