mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-11 01:30:29 +03:00
refectored Drawer component and added Postie
This commit is contained in:
parent
8996b562bc
commit
b5dfc337ec
10 changed files with 336 additions and 191 deletions
|
|
@ -155,12 +155,13 @@ class RoomList extends EventEmitter {
|
|||
this.matrixClient.on('Room.name', () => {
|
||||
this.emit(cons.events.roomList.ROOMLIST_UPDATED);
|
||||
});
|
||||
this.matrixClient.on('Room.receipt', (event) => {
|
||||
this.matrixClient.on('Room.receipt', (event, room) => {
|
||||
if (event.getType() === 'm.receipt') {
|
||||
const evContent = event.getContent();
|
||||
const userId = Object.keys(evContent[Object.keys(evContent)[0]]['m.read'])[0];
|
||||
if (userId !== this.matrixClient.getUserId()) return;
|
||||
this.emit(cons.events.roomList.ROOMLIST_UPDATED);
|
||||
const content = event.getContent();
|
||||
const userReadEventId = Object.keys(content)[0];
|
||||
const eventReaderUserId = Object.keys(content[userReadEventId]['m.read'])[0];
|
||||
if (eventReaderUserId !== this.matrixClient.getUserId()) return;
|
||||
this.emit(cons.events.roomList.MY_RECEIPT_ARRIVED, room.roomId);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -280,8 +281,13 @@ class RoomList extends EventEmitter {
|
|||
this.emit(cons.events.roomList.ROOMLIST_UPDATED);
|
||||
});
|
||||
|
||||
this.matrixClient.on('Room.timeline', () => {
|
||||
this.emit(cons.events.roomList.ROOMLIST_UPDATED);
|
||||
this.matrixClient.on('Room.timeline', (event, room) => {
|
||||
const supportEvents = ['m.room.message', 'm.room.encrypted', 'm.sticker'];
|
||||
if (!supportEvents.includes(event.getType())) return;
|
||||
|
||||
const lastTimelineEvent = room.timeline[room.timeline.length - 1];
|
||||
if (lastTimelineEvent.getId() !== event.getId()) return;
|
||||
this.emit(cons.events.roomList.EVENT_ARRIVED, room.roomId);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ const cons = {
|
|||
ROOM_JOINED: 'ROOM_JOINED',
|
||||
ROOM_LEAVED: 'ROOM_LEAVED',
|
||||
ROOM_CREATED: 'ROOM_CREATED',
|
||||
MY_RECEIPT_ARRIVED: 'MY_RECEIPT_ARRIVED',
|
||||
EVENT_ARRIVED: 'EVENT_ARRIVED',
|
||||
},
|
||||
roomTimeline: {
|
||||
EVENT: 'EVENT',
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ class Navigation extends EventEmitter {
|
|||
constructor() {
|
||||
super();
|
||||
|
||||
this.activeTab = 'channels';
|
||||
this.activeTab = 'home';
|
||||
this.activeRoomId = null;
|
||||
this.isPeopleDrawerVisible = true;
|
||||
}
|
||||
|
|
@ -26,8 +26,9 @@ class Navigation extends EventEmitter {
|
|||
this.emit(cons.events.navigation.TAB_CHANGED, this.activeTab);
|
||||
},
|
||||
[cons.actions.navigation.SELECT_ROOM]: () => {
|
||||
const prevActiveRoomId = this.activeRoomId;
|
||||
this.activeRoomId = action.roomId;
|
||||
this.emit(cons.events.navigation.ROOM_SELECTED, this.activeRoomId);
|
||||
this.emit(cons.events.navigation.ROOM_SELECTED, this.activeRoomId, prevActiveRoomId);
|
||||
},
|
||||
[cons.actions.navigation.TOGGLE_PEOPLE_DRAWER]: () => {
|
||||
this.isPeopleDrawerVisible = !this.isPeopleDrawerVisible;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue