Skip to content

Commit a3ad9e9

Browse files
new room viewer script to mobile.
1 parent 6af557e commit a3ad9e9

File tree

3 files changed

+235
-199
lines changed

3 files changed

+235
-199
lines changed

info/dev/preparing-changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
- some css classes `noselect` is fixed.
44
- Share room url button added.
55
- Force Dev Mode option added into the `.env` file.
6+
- New room viewer script to mobile.

src/app/organisms/room/Room.jsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';
22
import clone from 'clone';
33
import { objType } from 'for-promise/utils/lib.mjs';
44

5+
import { isMobile } from '@src/util/libs/mobile';
56
import blobUrlManager from '@src/util/libs/blobUrlManager';
67
import matrixAppearance from '@src/util/libs/appearance';
78

@@ -33,6 +34,7 @@ function Room() {
3334
forceScroll: null,
3435
};
3536

37+
const [isRoomMode, setIsRoomMode] = useState(false);
3638
const [roomInfo, setRoomInfo] = useState(defaultRoomInfo);
3739
tinyAPI.emit('setRoomInfo', defaultRoomInfo);
3840

@@ -66,6 +68,9 @@ function Room() {
6668
};
6769

6870
useEffect(() => {
71+
const onRoomModeSelected = (roomType) => {
72+
setIsRoomMode(roomType === 'room' ? true : false);
73+
};
6974
const setRoomSelected = (roomId, threadId, eventId, forceScroll) => {
7075
const threadTimeline = threadId ? RoomTimeline.newFromThread(threadId, roomId) : null;
7176
const roomTimeline = threadTimeline ?? new RoomTimeline(roomId);
@@ -137,8 +142,10 @@ function Room() {
137142
}
138143
};
139144

145+
navigation.on(cons.events.navigation.SELECTED_ROOM_MODE, onRoomModeSelected);
140146
navigation.on(cons.events.navigation.ROOM_SELECTED, handleRoomSelected);
141147
return () => {
148+
navigation.removeListener(cons.events.navigation.SELECTED_ROOM_MODE, onRoomModeSelected);
142149
navigation.removeListener(cons.events.navigation.ROOM_SELECTED, handleRoomSelected);
143150
};
144151
}, [mx, roomInfo]);
@@ -172,7 +179,10 @@ function Room() {
172179

173180
// Checker is User List
174181
const cloneIsUserList = clone(isUserList);
175-
if (cloneIsUserList === isUserList) {
182+
if (
183+
cloneIsUserList === isUserList &&
184+
(!isMobile() || window.matchMedia('screen and (min-width: 768px)').matches || isRoomMode)
185+
) {
176186
// Complete
177187
return (
178188
<div className="room">

0 commit comments

Comments
 (0)