mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-05 06:50:28 +03:00
Added unread symbol for Spaces, DMs and Home (#82)
This commit is contained in:
parent
fc0dc8aea0
commit
b07c50e580
14 changed files with 229 additions and 108 deletions
|
|
@ -12,7 +12,7 @@ import { AtoZ } from './common';
|
|||
|
||||
const drawerPostie = new Postie();
|
||||
function Directs() {
|
||||
const { roomList } = initMatrix;
|
||||
const { roomList, notifications } = initMatrix;
|
||||
const directIds = [...roomList.directs].sort(AtoZ);
|
||||
|
||||
const [, forceUpdate] = useState({});
|
||||
|
|
@ -26,10 +26,11 @@ function Directs() {
|
|||
drawerPostie.post('selector-change', addresses, selectedRoomId);
|
||||
}
|
||||
|
||||
function unreadChanged(roomId) {
|
||||
if (!drawerPostie.hasTopic('unread-change')) return;
|
||||
if (!drawerPostie.hasSubscriber('unread-change', roomId)) return;
|
||||
drawerPostie.post('unread-change', roomId);
|
||||
function notiChanged(roomId, total, prevTotal) {
|
||||
if (total === prevTotal) return;
|
||||
if (drawerPostie.hasTopicAndSubscriber('unread-change', roomId)) {
|
||||
drawerPostie.post('unread-change', roomId);
|
||||
}
|
||||
}
|
||||
|
||||
function roomListUpdated() {
|
||||
|
|
@ -47,13 +48,11 @@ function Directs() {
|
|||
useEffect(() => {
|
||||
roomList.on(cons.events.roomList.ROOMLIST_UPDATED, roomListUpdated);
|
||||
navigation.on(cons.events.navigation.ROOM_SELECTED, selectorChanged);
|
||||
roomList.on(cons.events.roomList.MY_RECEIPT_ARRIVED, unreadChanged);
|
||||
roomList.on(cons.events.roomList.EVENT_ARRIVED, unreadChanged);
|
||||
notifications.on(cons.events.notifications.NOTI_CHANGED, notiChanged);
|
||||
return () => {
|
||||
roomList.removeListener(cons.events.roomList.ROOMLIST_UPDATED, roomListUpdated);
|
||||
navigation.removeListener(cons.events.navigation.ROOM_SELECTED, selectorChanged);
|
||||
roomList.removeListener(cons.events.roomList.MY_RECEIPT_ARRIVED, unreadChanged);
|
||||
roomList.removeListener(cons.events.roomList.EVENT_ARRIVED, unreadChanged);
|
||||
notifications.removeListener(cons.events.notifications.NOTI_CHANGED, notiChanged);
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue