mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-16 04:00:29 +03:00
Auto update room profile on change
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
5777c1ab27
commit
5e89675c9c
5 changed files with 47 additions and 12 deletions
|
|
@ -26,8 +26,12 @@ function RoomView({ roomTimeline, eventId }) {
|
|||
roomView.classList.toggle('room-view--dropped');
|
||||
|
||||
const roomViewContent = roomView.children[1];
|
||||
if (isVisible) setTimeout(() => { roomViewContent.style.visibility = 'hidden'; }, 200);
|
||||
else roomViewContent.style.visibility = 'visible';
|
||||
if (isVisible) {
|
||||
setTimeout(() => {
|
||||
if (!navigation.isRoomSettings) return;
|
||||
roomViewContent.style.visibility = 'hidden';
|
||||
}, 200);
|
||||
} else roomViewContent.style.visibility = 'visible';
|
||||
};
|
||||
navigation.on(cons.events.navigation.ROOM_SETTINGS_TOGGLED, settingsToggle);
|
||||
return () => {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,10 @@ import UserIC from '../../../../public/res/ic/outlined/user.svg';
|
|||
import ChevronBottomIC from '../../../../public/res/ic/outlined/chevron-bottom.svg';
|
||||
import VerticalMenuIC from '../../../../public/res/ic/outlined/vertical-menu.svg';
|
||||
|
||||
import { useForceUpdate } from '../../hooks/useForceUpdate';
|
||||
|
||||
function RoomViewHeader({ roomId }) {
|
||||
const [, forceUpdate] = useForceUpdate();
|
||||
const mx = initMatrix.matrixClient;
|
||||
const isDM = initMatrix.roomList.directs.has(roomId);
|
||||
let avatarSrc = mx.getRoom(roomId).getAvatarUrl(mx.baseUrl, 36, 36, 'crop');
|
||||
|
|
@ -43,6 +46,20 @@ function RoomViewHeader({ roomId }) {
|
|||
navigation.removeListener(cons.events.navigation.ROOM_SETTINGS_TOGGLED, settingsToggle);
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const { roomList } = initMatrix;
|
||||
const handleProfileUpdate = (rId) => {
|
||||
if (roomId !== rId) return;
|
||||
forceUpdate();
|
||||
};
|
||||
|
||||
roomList.on(cons.events.roomList.ROOM_PROFILE_UPDATED, handleProfileUpdate);
|
||||
return () => {
|
||||
roomList.on(cons.events.roomList.ROOM_PROFILE_UPDATED, handleProfileUpdate);
|
||||
};
|
||||
}, [roomId]);
|
||||
|
||||
return (
|
||||
<Header>
|
||||
<button
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue