Compare commits
4 commits
dev
...
add/ignore
Author | SHA1 | Date | |
---|---|---|---|
|
19217fd1e0 | ||
|
1fd5cde10f | ||
|
667d6077c1 | ||
|
b28b94bfe7 |
9 changed files with 95 additions and 9 deletions
|
@ -5,12 +5,12 @@ import initMatrix from '../../client/initMatrix';
|
||||||
|
|
||||||
export function useAccountData(eventType) {
|
export function useAccountData(eventType) {
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = initMatrix.matrixClient;
|
||||||
const [event, setEvent] = useState(mx.getAccountData(eventType)?.getContent());
|
const [event, setEvent] = useState(mx.getAccountData(eventType));
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleChange = (mEvent) => {
|
const handleChange = (mEvent) => {
|
||||||
if (mEvent.getType() !== eventType) return;
|
if (mEvent.getType() !== eventType) return;
|
||||||
setEvent(mEvent.getContent());
|
setEvent(mEvent);
|
||||||
};
|
};
|
||||||
mx.on('accountData', handleChange);
|
mx.on('accountData', handleChange);
|
||||||
return () => {
|
return () => {
|
||||||
|
|
|
@ -53,7 +53,7 @@ export function getTypeActions(type, highlightValue = false) {
|
||||||
|
|
||||||
function useGlobalNotif() {
|
function useGlobalNotif() {
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = initMatrix.matrixClient;
|
||||||
const pushRules = useAccountData('m.push_rules');
|
const pushRules = useAccountData('m.push_rules')?.getContent();
|
||||||
const underride = pushRules?.global?.underride ?? [];
|
const underride = pushRules?.global?.underride ?? [];
|
||||||
const rulesToType = {
|
const rulesToType = {
|
||||||
[DM]: notifType.ON,
|
[DM]: notifType.ON,
|
||||||
|
|
64
src/app/molecules/global-notification/IgnoreUserList.jsx
Normal file
64
src/app/molecules/global-notification/IgnoreUserList.jsx
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
import React from 'react';
|
||||||
|
import './IgnoreUserList.scss';
|
||||||
|
|
||||||
|
import initMatrix from '../../../client/initMatrix';
|
||||||
|
import * as roomActions from '../../../client/action/room';
|
||||||
|
|
||||||
|
import Text from '../../atoms/text/Text';
|
||||||
|
import Chip from '../../atoms/chip/Chip';
|
||||||
|
import Input from '../../atoms/input/Input';
|
||||||
|
import Button from '../../atoms/button/Button';
|
||||||
|
import { MenuHeader } from '../../atoms/context-menu/ContextMenu';
|
||||||
|
import SettingTile from '../setting-tile/SettingTile';
|
||||||
|
|
||||||
|
import CrossIC from '../../../../public/res/ic/outlined/cross.svg';
|
||||||
|
|
||||||
|
import { useAccountData } from '../../hooks/useAccountData';
|
||||||
|
|
||||||
|
function IgnoreUserList() {
|
||||||
|
useAccountData('m.ignored_user_list');
|
||||||
|
const ignoredUsers = initMatrix.matrixClient.getIgnoredUsers();
|
||||||
|
|
||||||
|
const handleSubmit = (evt) => {
|
||||||
|
evt.preventDefault();
|
||||||
|
const { ignoreInput } = evt.target.elements;
|
||||||
|
const value = ignoreInput.value.trim();
|
||||||
|
const userIds = value.split(' ').filter((v) => v.match(/^@\S+:\S+$/));
|
||||||
|
if (userIds.length === 0) return;
|
||||||
|
ignoreInput.value = '';
|
||||||
|
roomActions.ignore(userIds);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="ignore-user-list">
|
||||||
|
<MenuHeader>Ignored users</MenuHeader>
|
||||||
|
<SettingTile
|
||||||
|
title="Ignore user"
|
||||||
|
content={(
|
||||||
|
<div className="ignore-user-list__users">
|
||||||
|
<Text variant="b3">Ignore userId if you do not want to receive their messages or invites.</Text>
|
||||||
|
<form onSubmit={handleSubmit}>
|
||||||
|
<Input name="ignoreInput" required />
|
||||||
|
<Button variant="primary" type="submit">Ignore</Button>
|
||||||
|
</form>
|
||||||
|
{ignoredUsers.length > 0 && (
|
||||||
|
<div>
|
||||||
|
{ignoredUsers.map((uId) => (
|
||||||
|
<Chip
|
||||||
|
iconSrc={CrossIC}
|
||||||
|
key={uId}
|
||||||
|
text={uId}
|
||||||
|
iconColor={CrossIC}
|
||||||
|
onClick={() => roomActions.unignore([uId])}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default IgnoreUserList;
|
17
src/app/molecules/global-notification/IgnoreUserList.scss
Normal file
17
src/app/molecules/global-notification/IgnoreUserList.scss
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
.ignore-user-list {
|
||||||
|
&__users {
|
||||||
|
& form,
|
||||||
|
& > div:last-child {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: var(--sp-tight);
|
||||||
|
}
|
||||||
|
|
||||||
|
& form {
|
||||||
|
margin: var(--sp-extra-tight) 0 var(--sp-normal);
|
||||||
|
.input-container {
|
||||||
|
flex-grow: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,7 +29,7 @@ const KEYWORD = 'keyword';
|
||||||
|
|
||||||
function useKeywordNotif() {
|
function useKeywordNotif() {
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = initMatrix.matrixClient;
|
||||||
const pushRules = useAccountData('m.push_rules');
|
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 ?? [];
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,12 @@
|
||||||
& form,
|
& form,
|
||||||
& > div:last-child {
|
& > div:last-child {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
gap: var(--sp-tight);
|
gap: var(--sp-tight);
|
||||||
}
|
}
|
||||||
|
|
||||||
& form {
|
& form {
|
||||||
margin: var(--sp-ultra-tight) 0 var(--sp-normal);
|
margin: var(--sp-extra-tight) 0 var(--sp-normal);
|
||||||
.input-container {
|
.input-container {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,10 @@ function RoomViewHeader({ roomId }) {
|
||||||
const [, forceUpdate] = useForceUpdate();
|
const [, forceUpdate] = useForceUpdate();
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = initMatrix.matrixClient;
|
||||||
const isDM = initMatrix.roomList.directs.has(roomId);
|
const isDM = initMatrix.roomList.directs.has(roomId);
|
||||||
let avatarSrc = mx.getRoom(roomId).getAvatarUrl(mx.baseUrl, 36, 36, 'crop');
|
const room = mx.getRoom(roomId);
|
||||||
avatarSrc = isDM ? mx.getRoom(roomId).getAvatarFallbackMember()?.getAvatarUrl(mx.baseUrl, 36, 36, 'crop') : avatarSrc;
|
let avatarSrc = room.getAvatarUrl(mx.baseUrl, 36, 36, 'crop');
|
||||||
const roomName = mx.getRoom(roomId).name;
|
avatarSrc = isDM ? room.getAvatarFallbackMember()?.getAvatarUrl(mx.baseUrl, 36, 36, 'crop') : avatarSrc;
|
||||||
|
const roomName = room.name;
|
||||||
|
|
||||||
const roomHeaderBtnRef = useRef(null);
|
const roomHeaderBtnRef = useRef(null);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -93,7 +94,7 @@ function RoomViewHeader({ roomId }) {
|
||||||
</TitleWrapper>
|
</TitleWrapper>
|
||||||
<RawIcon src={ChevronBottomIC} />
|
<RawIcon src={ChevronBottomIC} />
|
||||||
</button>
|
</button>
|
||||||
<IconButton onClick={() => toggleRoomSettings(tabText.SEARCH)} tooltip="Search" src={SearchIC} />
|
{mx.isRoomEncrypted(roomId) === false && <IconButton onClick={() => toggleRoomSettings(tabText.SEARCH)} tooltip="Search" src={SearchIC} />}
|
||||||
<IconButton className="room-header__drawer-btn" onClick={togglePeopleDrawer} tooltip="People" src={UserIC} />
|
<IconButton className="room-header__drawer-btn" onClick={togglePeopleDrawer} tooltip="People" src={UserIC} />
|
||||||
<IconButton className="room-header__members-btn" onClick={() => toggleRoomSettings(tabText.MEMBERS)} tooltip="Members" src={UserIC} />
|
<IconButton className="room-header__members-btn" onClick={() => toggleRoomSettings(tabText.MEMBERS)} tooltip="Members" src={UserIC} />
|
||||||
<IconButton
|
<IconButton
|
||||||
|
|
|
@ -27,6 +27,7 @@ import ExportE2ERoomKeys from '../../molecules/import-export-e2e-room-keys/Expor
|
||||||
import { ImagePackUser, ImagePackGlobal } from '../../molecules/image-pack/ImagePack';
|
import { ImagePackUser, ImagePackGlobal } from '../../molecules/image-pack/ImagePack';
|
||||||
import GlobalNotification from '../../molecules/global-notification/GlobalNotification';
|
import GlobalNotification from '../../molecules/global-notification/GlobalNotification';
|
||||||
import KeywordNotification from '../../molecules/global-notification/KeywordNotification';
|
import KeywordNotification from '../../molecules/global-notification/KeywordNotification';
|
||||||
|
import IgnoreUserList from '../../molecules/global-notification/IgnoreUserList';
|
||||||
|
|
||||||
import ProfileEditor from '../profile-editor/ProfileEditor';
|
import ProfileEditor from '../profile-editor/ProfileEditor';
|
||||||
import CrossSigning from './CrossSigning';
|
import CrossSigning from './CrossSigning';
|
||||||
|
@ -173,6 +174,7 @@ function NotificationsSection() {
|
||||||
</div>
|
</div>
|
||||||
<GlobalNotification />
|
<GlobalNotification />
|
||||||
<KeywordNotification />
|
<KeywordNotification />
|
||||||
|
<IgnoreUserList />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
.settings-notifications,
|
.settings-notifications,
|
||||||
.global-notification,
|
.global-notification,
|
||||||
.keyword-notification,
|
.keyword-notification,
|
||||||
|
.ignore-user-list,
|
||||||
.settings-security__card,
|
.settings-security__card,
|
||||||
.settings-security .device-manage,
|
.settings-security .device-manage,
|
||||||
.settings-about__card,
|
.settings-about__card,
|
||||||
|
|
Loading…
Reference in a new issue