handle error in loading screen (#1823)
* handle client boot error in loading screen * use sync state hook in client root * add loading screen options * removed extra condition in loading finish * add sync connection status bar
This commit is contained in:
parent
e046c59f7c
commit
e2228a18c1
62 changed files with 609 additions and 510 deletions
|
|
@ -53,7 +53,7 @@ const RoomNavItemMenu = forwardRef<HTMLDivElement, RoomNavItemMenuProps>(
|
||||||
const canInvite = canDoAction('invite', getPowerLevel(mx.getUserId() ?? ''));
|
const canInvite = canDoAction('invite', getPowerLevel(mx.getUserId() ?? ''));
|
||||||
|
|
||||||
const handleMarkAsRead = () => {
|
const handleMarkAsRead = () => {
|
||||||
markAsRead(room.roomId);
|
markAsRead(mx, room.roomId);
|
||||||
requestClose();
|
requestClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,12 @@ import { PowerLevelsContextProvider, usePowerLevels } from '../../hooks/usePower
|
||||||
import { useRoom } from '../../hooks/useRoom';
|
import { useRoom } from '../../hooks/useRoom';
|
||||||
import { useKeyDown } from '../../hooks/useKeyDown';
|
import { useKeyDown } from '../../hooks/useKeyDown';
|
||||||
import { markAsRead } from '../../../client/action/notifications';
|
import { markAsRead } from '../../../client/action/notifications';
|
||||||
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||||
|
|
||||||
export function Room() {
|
export function Room() {
|
||||||
const { eventId } = useParams();
|
const { eventId } = useParams();
|
||||||
const room = useRoom();
|
const room = useRoom();
|
||||||
|
const mx = useMatrixClient();
|
||||||
|
|
||||||
const [isDrawer] = useSetting(settingsAtom, 'isPeopleDrawer');
|
const [isDrawer] = useSetting(settingsAtom, 'isPeopleDrawer');
|
||||||
const screenSize = useScreenSizeContext();
|
const screenSize = useScreenSizeContext();
|
||||||
|
|
@ -25,7 +27,7 @@ export function Room() {
|
||||||
useCallback(
|
useCallback(
|
||||||
(evt) => {
|
(evt) => {
|
||||||
if (isKeyHotkey('escape', evt)) {
|
if (isKeyHotkey('escape', evt)) {
|
||||||
markAsRead(room.roomId);
|
markAsRead(mx, room.roomId);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[room.roomId]
|
[room.roomId]
|
||||||
|
|
|
||||||
|
|
@ -597,7 +597,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||||
// so timeline can be updated with evt like: edits, reactions etc
|
// so timeline can be updated with evt like: edits, reactions etc
|
||||||
if (atBottomRef.current) {
|
if (atBottomRef.current) {
|
||||||
if (document.hasFocus() && (!unreadInfo || mEvt.getSender() === mx.getUserId())) {
|
if (document.hasFocus() && (!unreadInfo || mEvt.getSender() === mx.getUserId())) {
|
||||||
requestAnimationFrame(() => markAsRead(mEvt.getRoomId()));
|
requestAnimationFrame(() => markAsRead(mx, mEvt.getRoomId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (document.hasFocus()) {
|
if (document.hasFocus()) {
|
||||||
|
|
@ -658,15 +658,15 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||||
|
|
||||||
const tryAutoMarkAsRead = useCallback(() => {
|
const tryAutoMarkAsRead = useCallback(() => {
|
||||||
if (!unreadInfo) {
|
if (!unreadInfo) {
|
||||||
requestAnimationFrame(() => markAsRead(room.roomId));
|
requestAnimationFrame(() => markAsRead(mx, room.roomId));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const evtTimeline = getEventTimeline(room, unreadInfo.readUptoEventId);
|
const evtTimeline = getEventTimeline(room, unreadInfo.readUptoEventId);
|
||||||
const latestTimeline = evtTimeline && getFirstLinkedTimeline(evtTimeline, Direction.Forward);
|
const latestTimeline = evtTimeline && getFirstLinkedTimeline(evtTimeline, Direction.Forward);
|
||||||
if (latestTimeline === room.getLiveTimeline()) {
|
if (latestTimeline === room.getLiveTimeline()) {
|
||||||
requestAnimationFrame(() => markAsRead(room.roomId));
|
requestAnimationFrame(() => markAsRead(mx, room.roomId));
|
||||||
}
|
}
|
||||||
}, [room, unreadInfo]);
|
}, [mx, room, unreadInfo]);
|
||||||
|
|
||||||
const debounceSetAtBottom = useDebounce(
|
const debounceSetAtBottom = useDebounce(
|
||||||
useCallback((entry: IntersectionObserverEntry) => {
|
useCallback((entry: IntersectionObserverEntry) => {
|
||||||
|
|
@ -832,7 +832,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMarkAsRead = () => {
|
const handleMarkAsRead = () => {
|
||||||
markAsRead(room.roomId);
|
markAsRead(mx, room.roomId);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOpenReply: MouseEventHandler<HTMLButtonElement> = useCallback(
|
const handleOpenReply: MouseEventHandler<HTMLButtonElement> = useCallback(
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ export function RoomTombstone({ roomId, body, replacementRoomId }: RoomTombstone
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
<Box shrink="No">
|
||||||
{replacementRoom?.getMyMembership() === Membership.Join ||
|
{replacementRoom?.getMyMembership() === Membership.Join ||
|
||||||
joinState.status === AsyncStatus.Success ? (
|
joinState.status === AsyncStatus.Success ? (
|
||||||
<Button onClick={handleOpen} size="300" variant="Success" fill="Solid" radii="300">
|
<Button onClick={handleOpen} size="300" variant="Success" fill="Solid" radii="300">
|
||||||
|
|
@ -62,6 +63,7 @@ export function RoomTombstone({ roomId, body, replacementRoomId }: RoomTombstone
|
||||||
<Text size="B300">Join New Room</Text>
|
<Text size="B300">Join New Room</Text>
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
</Box>
|
||||||
</RoomInputPlaceholder>
|
</RoomInputPlaceholder>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ const RoomMenu = forwardRef<HTMLDivElement, RoomMenuProps>(
|
||||||
const canInvite = canDoAction('invite', getPowerLevel(mx.getUserId() ?? ''));
|
const canInvite = canDoAction('invite', getPowerLevel(mx.getUserId() ?? ''));
|
||||||
|
|
||||||
const handleMarkAsRead = () => {
|
const handleMarkAsRead = () => {
|
||||||
markAsRead(room.roomId);
|
markAsRead(mx, room.roomId);
|
||||||
requestClose();
|
requestClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
/* eslint-disable import/prefer-default-export */
|
/* eslint-disable import/prefer-default-export */
|
||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
|
import { useMatrixClient } from './useMatrixClient';
|
||||||
import initMatrix from '../../client/initMatrix';
|
|
||||||
|
|
||||||
export function useAccountData(eventType) {
|
export function useAccountData(eventType) {
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = useMatrixClient();
|
||||||
const [event, setEvent] = useState(mx.getAccountData(eventType));
|
const [event, setEvent] = useState(mx.getAccountData(eventType));
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -16,7 +15,7 @@ export function useAccountData(eventType) {
|
||||||
return () => {
|
return () => {
|
||||||
mx.removeListener('accountData', handleChange);
|
mx.removeListener('accountData', handleChange);
|
||||||
};
|
};
|
||||||
}, [eventType]);
|
}, [mx, eventType]);
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,9 +92,9 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const devices = await Promise.all(userIds.map(hasDevices));
|
const devices = await Promise.all(userIds.map(uid => hasDevices(mx, uid)));
|
||||||
const isEncrypt = devices.every((hasDevice) => hasDevice);
|
const isEncrypt = devices.every((hasDevice) => hasDevice);
|
||||||
const result = await roomActions.createDM(userIds, isEncrypt);
|
const result = await roomActions.createDM(mx, userIds, isEncrypt);
|
||||||
navigateRoom(result.room_id);
|
navigateRoom(result.room_id);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -106,7 +106,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
|
||||||
const roomIds = rawIds.filter(
|
const roomIds = rawIds.filter(
|
||||||
(idOrAlias) => isRoomId(idOrAlias) || isRoomAlias(idOrAlias)
|
(idOrAlias) => isRoomId(idOrAlias) || isRoomAlias(idOrAlias)
|
||||||
);
|
);
|
||||||
roomIds.map((id) => roomActions.join(id));
|
roomIds.map((id) => roomActions.join(mx, id));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[Command.Leave]: {
|
[Command.Leave]: {
|
||||||
|
|
@ -127,7 +127,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
|
||||||
description: 'Invite user to room. Example: /invite userId1 userId2 [-r reason]',
|
description: 'Invite user to room. Example: /invite userId1 userId2 [-r reason]',
|
||||||
exe: async (payload) => {
|
exe: async (payload) => {
|
||||||
const { users, reason } = parseUsersAndReason(payload);
|
const { users, reason } = parseUsersAndReason(payload);
|
||||||
users.map((id) => roomActions.invite(room.roomId, id, reason));
|
users.map((id) => mx.invite(room.roomId, id, reason));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[Command.DisInvite]: {
|
[Command.DisInvite]: {
|
||||||
|
|
@ -135,7 +135,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
|
||||||
description: 'Disinvite user to room. Example: /disinvite userId1 userId2 [-r reason]',
|
description: 'Disinvite user to room. Example: /disinvite userId1 userId2 [-r reason]',
|
||||||
exe: async (payload) => {
|
exe: async (payload) => {
|
||||||
const { users, reason } = parseUsersAndReason(payload);
|
const { users, reason } = parseUsersAndReason(payload);
|
||||||
users.map((id) => roomActions.kick(room.roomId, id, reason));
|
users.map((id) => mx.kick(room.roomId, id, reason));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[Command.Kick]: {
|
[Command.Kick]: {
|
||||||
|
|
@ -143,7 +143,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
|
||||||
description: 'Kick user from room. Example: /kick userId1 userId2 [-r reason]',
|
description: 'Kick user from room. Example: /kick userId1 userId2 [-r reason]',
|
||||||
exe: async (payload) => {
|
exe: async (payload) => {
|
||||||
const { users, reason } = parseUsersAndReason(payload);
|
const { users, reason } = parseUsersAndReason(payload);
|
||||||
users.map((id) => roomActions.kick(room.roomId, id, reason));
|
users.map((id) => mx.kick(room.roomId, id, reason));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[Command.Ban]: {
|
[Command.Ban]: {
|
||||||
|
|
@ -151,7 +151,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
|
||||||
description: 'Ban user from room. Example: /ban userId1 userId2 [-r reason]',
|
description: 'Ban user from room. Example: /ban userId1 userId2 [-r reason]',
|
||||||
exe: async (payload) => {
|
exe: async (payload) => {
|
||||||
const { users, reason } = parseUsersAndReason(payload);
|
const { users, reason } = parseUsersAndReason(payload);
|
||||||
users.map((id) => roomActions.ban(room.roomId, id, reason));
|
users.map((id) => mx.ban(room.roomId, id, reason));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[Command.UnBan]: {
|
[Command.UnBan]: {
|
||||||
|
|
@ -160,7 +160,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
|
||||||
exe: async (payload) => {
|
exe: async (payload) => {
|
||||||
const rawIds = payload.split(' ');
|
const rawIds = payload.split(' ');
|
||||||
const users = rawIds.filter((id) => isUserId(id));
|
const users = rawIds.filter((id) => isUserId(id));
|
||||||
users.map((id) => roomActions.unban(room.roomId, id));
|
users.map((id) => mx.unban(room.roomId, id));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[Command.Ignore]: {
|
[Command.Ignore]: {
|
||||||
|
|
@ -169,7 +169,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
|
||||||
exe: async (payload) => {
|
exe: async (payload) => {
|
||||||
const rawIds = payload.split(' ');
|
const rawIds = payload.split(' ');
|
||||||
const userIds = rawIds.filter((id) => isUserId(id));
|
const userIds = rawIds.filter((id) => isUserId(id));
|
||||||
if (userIds.length > 0) roomActions.ignore(userIds);
|
if (userIds.length > 0) roomActions.ignore(mx, userIds);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[Command.UnIgnore]: {
|
[Command.UnIgnore]: {
|
||||||
|
|
@ -178,7 +178,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
|
||||||
exe: async (payload) => {
|
exe: async (payload) => {
|
||||||
const rawIds = payload.split(' ');
|
const rawIds = payload.split(' ');
|
||||||
const userIds = rawIds.filter((id) => isUserId(id));
|
const userIds = rawIds.filter((id) => isUserId(id));
|
||||||
if (userIds.length > 0) roomActions.unignore(userIds);
|
if (userIds.length > 0) roomActions.unignore(mx, userIds);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[Command.MyRoomNick]: {
|
[Command.MyRoomNick]: {
|
||||||
|
|
@ -187,7 +187,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
|
||||||
exe: async (payload) => {
|
exe: async (payload) => {
|
||||||
const nick = payload.trim();
|
const nick = payload.trim();
|
||||||
if (nick === '') return;
|
if (nick === '') return;
|
||||||
roomActions.setMyRoomNick(room.roomId, nick);
|
roomActions.setMyRoomNick(mx, room.roomId, nick);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[Command.MyRoomAvatar]: {
|
[Command.MyRoomAvatar]: {
|
||||||
|
|
@ -195,7 +195,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
|
||||||
description: 'Change profile picture in current room. Example /myroomavatar mxc://xyzabc',
|
description: 'Change profile picture in current room. Example /myroomavatar mxc://xyzabc',
|
||||||
exe: async (payload) => {
|
exe: async (payload) => {
|
||||||
if (payload.match(/^mxc:\/\/\S+$/)) {
|
if (payload.match(/^mxc:\/\/\S+$/)) {
|
||||||
roomActions.setMyRoomAvatar(room.roomId, payload);
|
roomActions.setMyRoomAvatar(mx, room.roomId, payload);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -203,14 +203,14 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
|
||||||
name: Command.ConvertToDm,
|
name: Command.ConvertToDm,
|
||||||
description: 'Convert room to direct message',
|
description: 'Convert room to direct message',
|
||||||
exe: async () => {
|
exe: async () => {
|
||||||
roomActions.convertToDm(room.roomId);
|
roomActions.convertToDm(mx, room.roomId);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[Command.ConvertToRoom]: {
|
[Command.ConvertToRoom]: {
|
||||||
name: Command.ConvertToRoom,
|
name: Command.ConvertToRoom,
|
||||||
description: 'Convert direct message to room',
|
description: 'Convert direct message to room',
|
||||||
exe: async () => {
|
exe: async () => {
|
||||||
roomActions.convertToRoom(room.roomId);
|
roomActions.convertToRoom(mx, room.roomId);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* eslint-disable import/prefer-default-export */
|
/* eslint-disable import/prefer-default-export */
|
||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
|
|
||||||
import initMatrix from '../../client/initMatrix';
|
|
||||||
import { hasCrossSigningAccountData } from '../../util/matrixUtil';
|
import { hasCrossSigningAccountData } from '../../util/matrixUtil';
|
||||||
|
import { useMatrixClient } from './useMatrixClient';
|
||||||
|
|
||||||
export function useCrossSigningStatus() {
|
export function useCrossSigningStatus() {
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = useMatrixClient();
|
||||||
const [isCSEnabled, setIsCSEnabled] = useState(hasCrossSigningAccountData());
|
const [isCSEnabled, setIsCSEnabled] = useState(hasCrossSigningAccountData(mx));
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isCSEnabled) return undefined;
|
if (isCSEnabled) return undefined;
|
||||||
|
|
@ -20,6 +20,6 @@ export function useCrossSigningStatus() {
|
||||||
return () => {
|
return () => {
|
||||||
mx.removeListener('accountData', handleAccountData);
|
mx.removeListener('accountData', handleAccountData);
|
||||||
};
|
};
|
||||||
}, [isCSEnabled === false]);
|
}, [mx, isCSEnabled]);
|
||||||
return isCSEnabled;
|
return isCSEnabled;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
/* eslint-disable import/prefer-default-export */
|
/* eslint-disable import/prefer-default-export */
|
||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
|
import { useMatrixClient } from './useMatrixClient';
|
||||||
import initMatrix from '../../client/initMatrix';
|
|
||||||
|
|
||||||
export function useDeviceList() {
|
export function useDeviceList() {
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = useMatrixClient();
|
||||||
const [deviceList, setDeviceList] = useState(null);
|
const [deviceList, setDeviceList] = useState(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -27,6 +26,6 @@ export function useDeviceList() {
|
||||||
mx.removeListener('crypto.devicesUpdated', handleDevicesUpdate);
|
mx.removeListener('crypto.devicesUpdated', handleDevicesUpdate);
|
||||||
isMounted = false;
|
isMounted = false;
|
||||||
};
|
};
|
||||||
}, []);
|
}, [mx]);
|
||||||
return deviceList;
|
return deviceList;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,13 @@ import { ClientEvent, ClientEventHandlerMap, MatrixClient } from 'matrix-js-sdk'
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
export const useSyncState = (
|
export const useSyncState = (
|
||||||
mx: MatrixClient,
|
mx: MatrixClient | undefined,
|
||||||
onChange: ClientEventHandlerMap[ClientEvent.Sync]
|
onChange: ClientEventHandlerMap[ClientEvent.Sync]
|
||||||
): void => {
|
): void => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
mx.on(ClientEvent.Sync, onChange);
|
mx?.on(ClientEvent.Sync, onChange);
|
||||||
return () => {
|
return () => {
|
||||||
mx.removeListener(ClientEvent.Sync, onChange);
|
mx?.removeListener(ClientEvent.Sync, onChange);
|
||||||
};
|
};
|
||||||
}, [mx, onChange]);
|
}, [mx, onChange]);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import initMatrix from '../../../client/initMatrix';
|
|
||||||
import { openReusableContextMenu } from '../../../client/action/navigation';
|
import { openReusableContextMenu } from '../../../client/action/navigation';
|
||||||
import { getEventCords } from '../../../util/common';
|
import { getEventCords } from '../../../util/common';
|
||||||
|
|
||||||
|
|
@ -14,6 +13,7 @@ import NotificationSelector from './NotificationSelector';
|
||||||
import ChevronBottomIC from '../../../../public/res/ic/outlined/chevron-bottom.svg';
|
import ChevronBottomIC from '../../../../public/res/ic/outlined/chevron-bottom.svg';
|
||||||
|
|
||||||
import { useAccountData } from '../../hooks/useAccountData';
|
import { useAccountData } from '../../hooks/useAccountData';
|
||||||
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||||
|
|
||||||
export const notifType = {
|
export const notifType = {
|
||||||
ON: 'on',
|
ON: 'on',
|
||||||
|
|
@ -52,7 +52,7 @@ export function getTypeActions(type, highlightValue = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function useGlobalNotif() {
|
function useGlobalNotif() {
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = useMatrixClient();
|
||||||
const pushRules = useAccountData('m.push_rules')?.getContent();
|
const pushRules = useAccountData('m.push_rules')?.getContent();
|
||||||
const underride = pushRules?.global?.underride ?? [];
|
const underride = pushRules?.global?.underride ?? [];
|
||||||
const rulesToType = {
|
const rulesToType = {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import './IgnoreUserList.scss';
|
import './IgnoreUserList.scss';
|
||||||
|
|
||||||
import initMatrix from '../../../client/initMatrix';
|
|
||||||
import * as roomActions from '../../../client/action/room';
|
import * as roomActions from '../../../client/action/room';
|
||||||
|
|
||||||
import Text from '../../atoms/text/Text';
|
import Text from '../../atoms/text/Text';
|
||||||
|
|
@ -14,10 +13,12 @@ import SettingTile from '../setting-tile/SettingTile';
|
||||||
import CrossIC from '../../../../public/res/ic/outlined/cross.svg';
|
import CrossIC from '../../../../public/res/ic/outlined/cross.svg';
|
||||||
|
|
||||||
import { useAccountData } from '../../hooks/useAccountData';
|
import { useAccountData } from '../../hooks/useAccountData';
|
||||||
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||||
|
|
||||||
function IgnoreUserList() {
|
function IgnoreUserList() {
|
||||||
useAccountData('m.ignored_user_list');
|
useAccountData('m.ignored_user_list');
|
||||||
const ignoredUsers = initMatrix.matrixClient.getIgnoredUsers();
|
const mx = useMatrixClient();
|
||||||
|
const ignoredUsers = mx.getIgnoredUsers();
|
||||||
|
|
||||||
const handleSubmit = (evt) => {
|
const handleSubmit = (evt) => {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
|
|
@ -26,7 +27,7 @@ function IgnoreUserList() {
|
||||||
const userIds = value.split(' ').filter((v) => v.match(/^@\S+:\S+$/));
|
const userIds = value.split(' ').filter((v) => v.match(/^@\S+:\S+$/));
|
||||||
if (userIds.length === 0) return;
|
if (userIds.length === 0) return;
|
||||||
ignoreInput.value = '';
|
ignoreInput.value = '';
|
||||||
roomActions.ignore(userIds);
|
roomActions.ignore(mx, userIds);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -49,7 +50,7 @@ function IgnoreUserList() {
|
||||||
key={uId}
|
key={uId}
|
||||||
text={uId}
|
text={uId}
|
||||||
iconColor={CrossIC}
|
iconColor={CrossIC}
|
||||||
onClick={() => roomActions.unignore([uId])}
|
onClick={() => roomActions.unignore(mx, [uId])}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import './KeywordNotification.scss';
|
import './KeywordNotification.scss';
|
||||||
|
|
||||||
import initMatrix from '../../../client/initMatrix';
|
|
||||||
import { openReusableContextMenu } from '../../../client/action/navigation';
|
import { openReusableContextMenu } from '../../../client/action/navigation';
|
||||||
import { getEventCords } from '../../../util/common';
|
import { getEventCords } from '../../../util/common';
|
||||||
|
|
||||||
|
|
@ -21,6 +20,7 @@ import { useAccountData } from '../../hooks/useAccountData';
|
||||||
import {
|
import {
|
||||||
notifType, typeToLabel, getActionType, getTypeActions,
|
notifType, typeToLabel, getActionType, getTypeActions,
|
||||||
} from './GlobalNotification';
|
} from './GlobalNotification';
|
||||||
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||||
|
|
||||||
const DISPLAY_NAME = '.m.rule.contains_display_name';
|
const DISPLAY_NAME = '.m.rule.contains_display_name';
|
||||||
const ROOM_PING = '.m.rule.roomnotif';
|
const ROOM_PING = '.m.rule.roomnotif';
|
||||||
|
|
@ -28,7 +28,7 @@ const USERNAME = '.m.rule.contains_user_name';
|
||||||
const KEYWORD = 'keyword';
|
const KEYWORD = 'keyword';
|
||||||
|
|
||||||
function useKeywordNotif() {
|
function useKeywordNotif() {
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = useMatrixClient();
|
||||||
const pushRules = useAccountData('m.push_rules')?.getContent();
|
const pushRules = useAccountData('m.push_rules')?.getContent();
|
||||||
const override = pushRules?.global?.override ?? [];
|
const override = pushRules?.global?.override ?? [];
|
||||||
const content = pushRules?.global?.content ?? [];
|
const content = pushRules?.global?.content ?? [];
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import React, {
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import './ImagePack.scss';
|
import './ImagePack.scss';
|
||||||
|
|
||||||
import initMatrix from '../../../client/initMatrix';
|
|
||||||
import { openReusableDialog } from '../../../client/action/navigation';
|
import { openReusableDialog } from '../../../client/action/navigation';
|
||||||
import { suffixRename } from '../../../util/common';
|
import { suffixRename } from '../../../util/common';
|
||||||
|
|
||||||
|
|
@ -19,6 +18,7 @@ import { confirmDialog } from '../confirm-dialog/ConfirmDialog';
|
||||||
import ImagePackProfile from './ImagePackProfile';
|
import ImagePackProfile from './ImagePackProfile';
|
||||||
import ImagePackItem from './ImagePackItem';
|
import ImagePackItem from './ImagePackItem';
|
||||||
import ImagePackUpload from './ImagePackUpload';
|
import ImagePackUpload from './ImagePackUpload';
|
||||||
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||||
|
|
||||||
const renameImagePackItem = (shortcode) => new Promise((resolve) => {
|
const renameImagePackItem = (shortcode) => new Promise((resolve) => {
|
||||||
let isCompleted = false;
|
let isCompleted = false;
|
||||||
|
|
@ -63,8 +63,7 @@ function getUsage(usage) {
|
||||||
return 'both';
|
return 'both';
|
||||||
}
|
}
|
||||||
|
|
||||||
function isGlobalPack(roomId, stateKey) {
|
function isGlobalPack(mx, roomId, stateKey) {
|
||||||
const mx = initMatrix.matrixClient;
|
|
||||||
const globalContent = mx.getAccountData('im.ponies.emote_rooms')?.getContent();
|
const globalContent = mx.getAccountData('im.ponies.emote_rooms')?.getContent();
|
||||||
if (typeof globalContent !== 'object') return false;
|
if (typeof globalContent !== 'object') return false;
|
||||||
|
|
||||||
|
|
@ -75,13 +74,13 @@ function isGlobalPack(roomId, stateKey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function useRoomImagePack(roomId, stateKey) {
|
function useRoomImagePack(roomId, stateKey) {
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = useMatrixClient();
|
||||||
const room = mx.getRoom(roomId);
|
const room = mx.getRoom(roomId);
|
||||||
|
|
||||||
|
const pack = useMemo(() => {
|
||||||
const packEvent = room.currentState.getStateEvents('im.ponies.room_emotes', stateKey);
|
const packEvent = room.currentState.getStateEvents('im.ponies.room_emotes', stateKey);
|
||||||
const pack = useMemo(() => (
|
return ImagePackBuilder.parsePack(packEvent.getId(), packEvent.getContent())
|
||||||
ImagePackBuilder.parsePack(packEvent.getId(), packEvent.getContent())
|
}, [room, stateKey]);
|
||||||
), [room, stateKey]);
|
|
||||||
|
|
||||||
const sendPackContent = (content) => {
|
const sendPackContent = (content) => {
|
||||||
mx.sendStateEvent(roomId, 'im.ponies.room_emotes', content, stateKey);
|
mx.sendStateEvent(roomId, 'im.ponies.room_emotes', content, stateKey);
|
||||||
|
|
@ -94,14 +93,14 @@ function useRoomImagePack(roomId, stateKey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function useUserImagePack() {
|
function useUserImagePack() {
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = useMatrixClient();
|
||||||
|
const pack = useMemo(() => {
|
||||||
const packEvent = mx.getAccountData('im.ponies.user_emotes');
|
const packEvent = mx.getAccountData('im.ponies.user_emotes');
|
||||||
const pack = useMemo(() => (
|
return ImagePackBuilder.parsePack(mx.getUserId(), packEvent?.getContent() ?? {
|
||||||
ImagePackBuilder.parsePack(mx.getUserId(), packEvent?.getContent() ?? {
|
|
||||||
pack: { display_name: 'Personal' },
|
pack: { display_name: 'Personal' },
|
||||||
images: {},
|
images: {},
|
||||||
})
|
})
|
||||||
), []);
|
}, [mx]);
|
||||||
|
|
||||||
const sendPackContent = (content) => {
|
const sendPackContent = (content) => {
|
||||||
mx.setAccountData('im.ponies.user_emotes', content);
|
mx.setAccountData('im.ponies.user_emotes', content);
|
||||||
|
|
@ -223,10 +222,10 @@ function removeGlobalImagePack(mx, roomId, stateKey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function ImagePack({ roomId, stateKey, handlePackDelete }) {
|
function ImagePack({ roomId, stateKey, handlePackDelete }) {
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = useMatrixClient();
|
||||||
const room = mx.getRoom(roomId);
|
const room = mx.getRoom(roomId);
|
||||||
const [viewMore, setViewMore] = useState(false);
|
const [viewMore, setViewMore] = useState(false);
|
||||||
const [isGlobal, setIsGlobal] = useState(isGlobalPack(roomId, stateKey));
|
const [isGlobal, setIsGlobal] = useState(isGlobalPack(mx, roomId, stateKey));
|
||||||
|
|
||||||
const { pack, sendPackContent } = useRoomImagePack(roomId, stateKey);
|
const { pack, sendPackContent } = useRoomImagePack(roomId, stateKey);
|
||||||
|
|
||||||
|
|
@ -331,7 +330,7 @@ ImagePack.propTypes = {
|
||||||
};
|
};
|
||||||
|
|
||||||
function ImagePackUser() {
|
function ImagePackUser() {
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = useMatrixClient();
|
||||||
const [viewMore, setViewMore] = useState(false);
|
const [viewMore, setViewMore] = useState(false);
|
||||||
|
|
||||||
const { pack, sendPackContent } = useUserImagePack();
|
const { pack, sendPackContent } = useUserImagePack();
|
||||||
|
|
@ -397,7 +396,7 @@ function ImagePackUser() {
|
||||||
|
|
||||||
function useGlobalImagePack() {
|
function useGlobalImagePack() {
|
||||||
const [, forceUpdate] = useReducer((count) => count + 1, 0);
|
const [, forceUpdate] = useReducer((count) => count + 1, 0);
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = useMatrixClient();
|
||||||
|
|
||||||
const roomIdToStateKeys = new Map();
|
const roomIdToStateKeys = new Map();
|
||||||
const globalContent = mx.getAccountData('im.ponies.emote_rooms')?.getContent() ?? { rooms: {} };
|
const globalContent = mx.getAccountData('im.ponies.emote_rooms')?.getContent() ?? { rooms: {} };
|
||||||
|
|
@ -419,13 +418,13 @@ function useGlobalImagePack() {
|
||||||
return () => {
|
return () => {
|
||||||
mx.removeListener('accountData', handleEvent);
|
mx.removeListener('accountData', handleEvent);
|
||||||
};
|
};
|
||||||
}, []);
|
}, [mx]);
|
||||||
|
|
||||||
return roomIdToStateKeys;
|
return roomIdToStateKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ImagePackGlobal() {
|
function ImagePackGlobal() {
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = useMatrixClient();
|
||||||
const roomIdToStateKeys = useGlobalImagePack();
|
const roomIdToStateKeys = useGlobalImagePack();
|
||||||
|
|
||||||
const handleChange = (roomId, stateKey) => {
|
const handleChange = (roomId, stateKey) => {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import React, { useState, useRef } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import './ImagePackUpload.scss';
|
import './ImagePackUpload.scss';
|
||||||
|
|
||||||
import initMatrix from '../../../client/initMatrix';
|
|
||||||
import { scaleDownImage } from '../../../util/common';
|
import { scaleDownImage } from '../../../util/common';
|
||||||
|
|
||||||
import Text from '../../atoms/text/Text';
|
import Text from '../../atoms/text/Text';
|
||||||
|
|
@ -10,9 +9,10 @@ import Button from '../../atoms/button/Button';
|
||||||
import Input from '../../atoms/input/Input';
|
import Input from '../../atoms/input/Input';
|
||||||
import IconButton from '../../atoms/button/IconButton';
|
import IconButton from '../../atoms/button/IconButton';
|
||||||
import CirclePlusIC from '../../../../public/res/ic/outlined/circle-plus.svg';
|
import CirclePlusIC from '../../../../public/res/ic/outlined/circle-plus.svg';
|
||||||
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||||
|
|
||||||
function ImagePackUpload({ onUpload }) {
|
function ImagePackUpload({ onUpload }) {
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = useMatrixClient();
|
||||||
const inputRef = useRef(null);
|
const inputRef = useRef(null);
|
||||||
const shortcodeRef = useRef(null);
|
const shortcodeRef = useRef(null);
|
||||||
const [imgFile, setImgFile] = useState(null);
|
const [imgFile, setImgFile] = useState(null);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import React, { useState, useRef } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import './ImageUpload.scss';
|
import './ImageUpload.scss';
|
||||||
|
|
||||||
import initMatrix from '../../../client/initMatrix';
|
|
||||||
|
|
||||||
import Text from '../../atoms/text/Text';
|
import Text from '../../atoms/text/Text';
|
||||||
import Avatar from '../../atoms/avatar/Avatar';
|
import Avatar from '../../atoms/avatar/Avatar';
|
||||||
|
|
@ -10,6 +9,7 @@ import Spinner from '../../atoms/spinner/Spinner';
|
||||||
import RawIcon from '../../atoms/system-icons/RawIcon';
|
import RawIcon from '../../atoms/system-icons/RawIcon';
|
||||||
|
|
||||||
import PlusIC from '../../../../public/res/ic/outlined/plus.svg';
|
import PlusIC from '../../../../public/res/ic/outlined/plus.svg';
|
||||||
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||||
|
|
||||||
function ImageUpload({
|
function ImageUpload({
|
||||||
text, bgColor, imageSrc, onUpload, onRequestRemove,
|
text, bgColor, imageSrc, onUpload, onRequestRemove,
|
||||||
|
|
@ -17,12 +17,13 @@ function ImageUpload({
|
||||||
}) {
|
}) {
|
||||||
const [uploadPromise, setUploadPromise] = useState(null);
|
const [uploadPromise, setUploadPromise] = useState(null);
|
||||||
const uploadImageRef = useRef(null);
|
const uploadImageRef = useRef(null);
|
||||||
|
const mx = useMatrixClient();
|
||||||
|
|
||||||
async function uploadImage(e) {
|
async function uploadImage(e) {
|
||||||
const file = e.target.files.item(0);
|
const file = e.target.files.item(0);
|
||||||
if (file === null) return;
|
if (file === null) return;
|
||||||
try {
|
try {
|
||||||
const uPromise = initMatrix.matrixClient.uploadContent(file);
|
const uPromise = mx.uploadContent(file);
|
||||||
setUploadPromise(uPromise);
|
setUploadPromise(uPromise);
|
||||||
|
|
||||||
const res = await uPromise;
|
const res = await uPromise;
|
||||||
|
|
@ -35,7 +36,7 @@ function ImageUpload({
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancelUpload() {
|
function cancelUpload() {
|
||||||
initMatrix.matrixClient.cancelUpload(uploadPromise);
|
mx.cancelUpload(uploadPromise);
|
||||||
setUploadPromise(null);
|
setUploadPromise(null);
|
||||||
uploadImageRef.current.value = null;
|
uploadImageRef.current.value = null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import './ExportE2ERoomKeys.scss';
|
||||||
|
|
||||||
import FileSaver from 'file-saver';
|
import FileSaver from 'file-saver';
|
||||||
|
|
||||||
import initMatrix from '../../../client/initMatrix';
|
|
||||||
import cons from '../../../client/state/cons';
|
import cons from '../../../client/state/cons';
|
||||||
import { encryptMegolmKeyFile } from '../../../util/cryptE2ERoomKeys';
|
import { encryptMegolmKeyFile } from '../../../util/cryptE2ERoomKeys';
|
||||||
|
|
||||||
|
|
@ -13,8 +12,10 @@ import Input from '../../atoms/input/Input';
|
||||||
import Spinner from '../../atoms/spinner/Spinner';
|
import Spinner from '../../atoms/spinner/Spinner';
|
||||||
|
|
||||||
import { useStore } from '../../hooks/useStore';
|
import { useStore } from '../../hooks/useStore';
|
||||||
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||||
|
|
||||||
function ExportE2ERoomKeys() {
|
function ExportE2ERoomKeys() {
|
||||||
|
const mx = useMatrixClient();
|
||||||
const isMountStore = useStore();
|
const isMountStore = useStore();
|
||||||
const [status, setStatus] = useState({
|
const [status, setStatus] = useState({
|
||||||
isOngoing: false,
|
isOngoing: false,
|
||||||
|
|
@ -40,7 +41,7 @@ function ExportE2ERoomKeys() {
|
||||||
type: cons.status.IN_FLIGHT,
|
type: cons.status.IN_FLIGHT,
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
const keys = await initMatrix.matrixClient.exportRoomKeys();
|
const keys = await mx.exportRoomKeys();
|
||||||
if (isMountStore.getItem()) {
|
if (isMountStore.getItem()) {
|
||||||
setStatus({
|
setStatus({
|
||||||
isOngoing: true,
|
isOngoing: true,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import React, { useState, useEffect, useRef } from 'react';
|
import React, { useState, useEffect, useRef } from 'react';
|
||||||
import './ImportE2ERoomKeys.scss';
|
import './ImportE2ERoomKeys.scss';
|
||||||
|
|
||||||
import initMatrix from '../../../client/initMatrix';
|
|
||||||
import cons from '../../../client/state/cons';
|
import cons from '../../../client/state/cons';
|
||||||
import { decryptMegolmKeyFile } from '../../../util/cryptE2ERoomKeys';
|
import { decryptMegolmKeyFile } from '../../../util/cryptE2ERoomKeys';
|
||||||
|
|
||||||
|
|
@ -14,8 +13,10 @@ import Spinner from '../../atoms/spinner/Spinner';
|
||||||
import CirclePlusIC from '../../../../public/res/ic/outlined/circle-plus.svg';
|
import CirclePlusIC from '../../../../public/res/ic/outlined/circle-plus.svg';
|
||||||
|
|
||||||
import { useStore } from '../../hooks/useStore';
|
import { useStore } from '../../hooks/useStore';
|
||||||
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||||
|
|
||||||
function ImportE2ERoomKeys() {
|
function ImportE2ERoomKeys() {
|
||||||
|
const mx = useMatrixClient();
|
||||||
const isMountStore = useStore();
|
const isMountStore = useStore();
|
||||||
const [keyFile, setKeyFile] = useState(null);
|
const [keyFile, setKeyFile] = useState(null);
|
||||||
const [status, setStatus] = useState({
|
const [status, setStatus] = useState({
|
||||||
|
|
@ -45,7 +46,7 @@ function ImportE2ERoomKeys() {
|
||||||
type: cons.status.IN_FLIGHT,
|
type: cons.status.IN_FLIGHT,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
await initMatrix.matrixClient.importRoomKeys(JSON.parse(keys));
|
await mx.importRoomKeys(JSON.parse(keys));
|
||||||
if (isMountStore.getItem()) {
|
if (isMountStore.getItem()) {
|
||||||
setStatus({
|
setStatus({
|
||||||
isOngoing: false,
|
isOngoing: false,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import React, { useState, useEffect } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import './RoomAliases.scss';
|
import './RoomAliases.scss';
|
||||||
|
|
||||||
import initMatrix from '../../../client/initMatrix';
|
|
||||||
import cons from '../../../client/state/cons';
|
import cons from '../../../client/state/cons';
|
||||||
import { Debounce } from '../../../util/common';
|
import { Debounce } from '../../../util/common';
|
||||||
import { isRoomAliasAvailable } from '../../../util/matrixUtil';
|
import { isRoomAliasAvailable } from '../../../util/matrixUtil';
|
||||||
|
|
@ -16,8 +15,10 @@ import { MenuHeader } from '../../atoms/context-menu/ContextMenu';
|
||||||
import SettingTile from '../setting-tile/SettingTile';
|
import SettingTile from '../setting-tile/SettingTile';
|
||||||
|
|
||||||
import { useStore } from '../../hooks/useStore';
|
import { useStore } from '../../hooks/useStore';
|
||||||
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||||
|
|
||||||
function useValidate(hsString) {
|
function useValidate(hsString) {
|
||||||
|
const mx = useMatrixClient();
|
||||||
const [debounce] = useState(new Debounce());
|
const [debounce] = useState(new Debounce());
|
||||||
const [validate, setValidate] = useState({ alias: null, status: cons.status.PRE_FLIGHT });
|
const [validate, setValidate] = useState({ alias: null, status: cons.status.PRE_FLIGHT });
|
||||||
|
|
||||||
|
|
@ -62,7 +63,7 @@ function useValidate(hsString) {
|
||||||
msg: `validating ${alias}...`,
|
msg: `validating ${alias}...`,
|
||||||
});
|
});
|
||||||
|
|
||||||
const isValid = await isRoomAliasAvailable(alias);
|
const isValid = await isRoomAliasAvailable(mx, alias);
|
||||||
setValidate(() => {
|
setValidate(() => {
|
||||||
if (e.target.value !== value) {
|
if (e.target.value !== value) {
|
||||||
return { alias: null, status: cons.status.PRE_FLIGHT };
|
return { alias: null, status: cons.status.PRE_FLIGHT };
|
||||||
|
|
@ -79,8 +80,7 @@ function useValidate(hsString) {
|
||||||
return [validate, setValidateToDefault, handleAliasChange];
|
return [validate, setValidateToDefault, handleAliasChange];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAliases(roomId) {
|
function getAliases(mx, roomId) {
|
||||||
const mx = initMatrix.matrixClient;
|
|
||||||
const room = mx.getRoom(roomId);
|
const room = mx.getRoom(roomId);
|
||||||
|
|
||||||
const main = room.getCanonicalAlias();
|
const main = room.getCanonicalAlias();
|
||||||
|
|
@ -95,7 +95,7 @@ function getAliases(roomId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function RoomAliases({ roomId }) {
|
function RoomAliases({ roomId }) {
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = useMatrixClient();
|
||||||
const room = mx.getRoom(roomId);
|
const room = mx.getRoom(roomId);
|
||||||
const userId = mx.getUserId();
|
const userId = mx.getUserId();
|
||||||
const hsString = userId.slice(userId.indexOf(':') + 1);
|
const hsString = userId.slice(userId.indexOf(':') + 1);
|
||||||
|
|
@ -103,7 +103,7 @@ function RoomAliases({ roomId }) {
|
||||||
const isMountedStore = useStore();
|
const isMountedStore = useStore();
|
||||||
const [isPublic, setIsPublic] = useState(false);
|
const [isPublic, setIsPublic] = useState(false);
|
||||||
const [isLocalVisible, setIsLocalVisible] = useState(false);
|
const [isLocalVisible, setIsLocalVisible] = useState(false);
|
||||||
const [aliases, setAliases] = useState(getAliases(roomId));
|
const [aliases, setAliases] = useState(getAliases(mx, roomId));
|
||||||
const [selectedAlias, setSelectedAlias] = useState(null);
|
const [selectedAlias, setSelectedAlias] = useState(null);
|
||||||
const [deleteAlias, setDeleteAlias] = useState(null);
|
const [deleteAlias, setDeleteAlias] = useState(null);
|
||||||
const [validate, setValidateToDefault, handleAliasChange] = useValidate(hsString);
|
const [validate, setValidateToDefault, handleAliasChange] = useValidate(hsString);
|
||||||
|
|
@ -140,7 +140,7 @@ function RoomAliases({ roomId }) {
|
||||||
return () => {
|
return () => {
|
||||||
isUnmounted = true;
|
isUnmounted = true;
|
||||||
};
|
};
|
||||||
}, [roomId]);
|
}, [mx, roomId]);
|
||||||
|
|
||||||
const toggleDirectoryVisibility = () => {
|
const toggleDirectoryVisibility = () => {
|
||||||
mx.setRoomDirectoryVisibility(roomId, isPublic ? 'private' : 'public');
|
mx.setRoomDirectoryVisibility(roomId, isPublic ? 'private' : 'public');
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import React, { useReducer, useEffect } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import './RoomEmojis.scss';
|
import './RoomEmojis.scss';
|
||||||
|
|
||||||
import initMatrix from '../../../client/initMatrix';
|
|
||||||
import { suffixRename } from '../../../util/common';
|
import { suffixRename } from '../../../util/common';
|
||||||
|
|
||||||
import { MenuHeader } from '../../atoms/context-menu/ContextMenu';
|
import { MenuHeader } from '../../atoms/context-menu/ContextMenu';
|
||||||
|
|
@ -10,9 +9,10 @@ import Text from '../../atoms/text/Text';
|
||||||
import Input from '../../atoms/input/Input';
|
import Input from '../../atoms/input/Input';
|
||||||
import Button from '../../atoms/button/Button';
|
import Button from '../../atoms/button/Button';
|
||||||
import ImagePack from '../image-pack/ImagePack';
|
import ImagePack from '../image-pack/ImagePack';
|
||||||
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||||
|
|
||||||
function useRoomPacks(room) {
|
function useRoomPacks(room) {
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = useMatrixClient();
|
||||||
const [, forceUpdate] = useReducer((count) => count + 1, 0);
|
const [, forceUpdate] = useReducer((count) => count + 1, 0);
|
||||||
|
|
||||||
const packEvents = room.currentState.getStateEvents('im.ponies.room_emotes');
|
const packEvents = room.currentState.getStateEvents('im.ponies.room_emotes');
|
||||||
|
|
@ -75,7 +75,7 @@ function useRoomPacks(room) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function RoomEmojis({ roomId }) {
|
function RoomEmojis({ roomId }) {
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = useMatrixClient();
|
||||||
const room = mx.getRoom(roomId);
|
const room = mx.getRoom(roomId);
|
||||||
|
|
||||||
const { usablePacks, createPack, deletePack } = useRoomPacks(room);
|
const { usablePacks, createPack, deletePack } = useRoomPacks(room);
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue