CI / Build & Quality Checks (push) Skipped
CI / Secret scan (gitleaks) (push) Skipped
CI / Playwright smoke (e2e) (push) Skipped
CI / Build & Quality Checks (pull_request) Successful in 3m18s
CI / Trigger Desktop Build (pull_request) Skipped
CI / Docker image build & smoke test (pull_request) Skipped
CI / Secret scan (gitleaks) (pull_request) Successful in 12s
CI / Playwright smoke (e2e) (pull_request) Successful in 24m56s
- #456 Copy pass: sentence case for every setting title and section, plainer names ("Hide joins and leaves", "Link previews", "Emoji style: Twemoji", "Rejoin calls after a restart", "Also use the browser's noise suppression", "Push-to-talk key"...) and grammar fixes ("when messages arrive", "Play a sound when a new message arrives", blocked users "Enter their Matrix ID"). Labels only: no setting is renamed in storage. - #455 One theme control: Theme: System / Light / Dark. System shows the light and dark variant pickers, Light or Dark one picker of that kind. Replaces the System switch plus a Theme dropdown that was greyed out whenever the switch was on. Uses the existing settings (no migration); picking a variant also remembers it for System. - #457 Remove the "Block Messages" stub from Notifications; the GIF picker row only appears in builds with a GIF key. - #458 (part 1) "Export/Import Messages Data" -> "Export/Import encryption keys", with a sentence on when you need it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5
169 lines
4.8 KiB
TypeScript
169 lines
4.8 KiB
TypeScript
import React, { ChangeEventHandler, FormEventHandler, useCallback, useState } from 'react';
|
|
import { Box, Button, Chip, Icon, IconButton, Icons, Input, Spinner, Text, config } from 'folds';
|
|
import { SequenceCard } from '../../../components/sequence-card';
|
|
import { SequenceCardStyle } from '../styles.css';
|
|
import { SettingTile } from '../../../components/setting-tile';
|
|
import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
|
import { AsyncStatus, useAsyncCallback } from '../../../hooks/useAsyncCallback';
|
|
import { isUserId } from '../../../utils/matrix';
|
|
import { useIgnoredUsers } from '../../../hooks/useIgnoredUsers';
|
|
import { useAlive } from '../../../hooks/useAlive';
|
|
|
|
function IgnoreUserInput({ userList }: { userList: string[] }) {
|
|
const mx = useMatrixClient();
|
|
const [userId, setUserId] = useState<string>('');
|
|
const alive = useAlive();
|
|
|
|
const [ignoreState, ignore] = useAsyncCallback(
|
|
useCallback(
|
|
async (uId: string) => {
|
|
await mx.setIgnoredUsers([...userList, uId]);
|
|
},
|
|
[mx, userList],
|
|
),
|
|
);
|
|
const ignoring = ignoreState.status === AsyncStatus.Loading;
|
|
|
|
const handleChange: ChangeEventHandler<HTMLInputElement> = (evt) => {
|
|
const uId = evt.currentTarget.value;
|
|
setUserId(uId);
|
|
};
|
|
|
|
const handleReset = () => {
|
|
setUserId('');
|
|
};
|
|
|
|
const handleSubmit: FormEventHandler<HTMLFormElement> = (evt) => {
|
|
evt.preventDefault();
|
|
if (ignoring) return;
|
|
|
|
const target = evt.target as HTMLFormElement | undefined;
|
|
const userIdInput = target?.userIdInput as HTMLInputElement | undefined;
|
|
const uId = userIdInput?.value.trim();
|
|
if (!uId) return;
|
|
|
|
if (!isUserId(uId)) return;
|
|
|
|
ignore(uId).then(() => {
|
|
if (alive()) {
|
|
setUserId('');
|
|
}
|
|
});
|
|
};
|
|
|
|
return (
|
|
<Box as="form" onSubmit={handleSubmit} gap="200" aria-disabled={ignoring}>
|
|
<Box grow="Yes" direction="Column">
|
|
<Input
|
|
required
|
|
name="userIdInput"
|
|
aria-label="User ID to ignore"
|
|
value={userId}
|
|
onChange={handleChange}
|
|
variant="Secondary"
|
|
radii="300"
|
|
style={{ paddingRight: config.space.S200 }}
|
|
readOnly={ignoring}
|
|
after={
|
|
userId &&
|
|
!ignoring && (
|
|
<IconButton
|
|
type="reset"
|
|
onClick={handleReset}
|
|
size="300"
|
|
radii="300"
|
|
variant="Secondary"
|
|
aria-label="Clear"
|
|
>
|
|
<Icon src={Icons.Cross} size="100" />
|
|
</IconButton>
|
|
)
|
|
}
|
|
/>
|
|
</Box>
|
|
<Button
|
|
size="400"
|
|
variant="Secondary"
|
|
fill="Soft"
|
|
outlined
|
|
radii="300"
|
|
type="submit"
|
|
disabled={ignoring}
|
|
>
|
|
{ignoring && <Spinner variant="Secondary" size="300" />}
|
|
<Text size="B400">Block</Text>
|
|
</Button>
|
|
</Box>
|
|
);
|
|
}
|
|
|
|
function IgnoredUserChip({ userId, userList }: { userId: string; userList: string[] }) {
|
|
const mx = useMatrixClient();
|
|
const [unignoreState, unignore] = useAsyncCallback(
|
|
useCallback(
|
|
() => mx.setIgnoredUsers(userList.filter((uId) => uId !== userId)),
|
|
[mx, userId, userList],
|
|
),
|
|
);
|
|
|
|
const handleUnignore = () => unignore();
|
|
|
|
const unIgnoring = unignoreState.status === AsyncStatus.Loading;
|
|
return (
|
|
<Chip
|
|
variant="Secondary"
|
|
radii="Pill"
|
|
after={
|
|
unIgnoring ? (
|
|
<Spinner variant="Secondary" size="100" />
|
|
) : (
|
|
<Icon src={Icons.Cross} size="100" />
|
|
)
|
|
}
|
|
onClick={handleUnignore}
|
|
disabled={unIgnoring}
|
|
>
|
|
<Text size="T200" truncate>
|
|
{userId}
|
|
</Text>
|
|
</Chip>
|
|
);
|
|
}
|
|
|
|
export function IgnoredUserList() {
|
|
const ignoredUsers = useIgnoredUsers();
|
|
|
|
return (
|
|
<Box direction="Column" gap="100">
|
|
<Box alignItems="Center" justifyContent="SpaceBetween" gap="200">
|
|
<Text size="L400">Blocked users</Text>
|
|
</Box>
|
|
<SequenceCard
|
|
className={SequenceCardStyle}
|
|
variant="SurfaceVariant"
|
|
direction="Column"
|
|
gap="400"
|
|
>
|
|
<SettingTile
|
|
title="Block someone"
|
|
description="Stop someone's messages and invites reaching you. Enter their Matrix ID, e.g. @name:server."
|
|
>
|
|
<Box direction="Column" gap="300">
|
|
<IgnoreUserInput userList={ignoredUsers} />
|
|
{ignoredUsers.length > 0 && (
|
|
<Box direction="Inherit" gap="100">
|
|
<Text size="L400">Users</Text>
|
|
<Box wrap="Wrap" gap="200">
|
|
{ignoredUsers.map((userId) => (
|
|
<IgnoredUserChip key={userId} userId={userId} userList={ignoredUsers} />
|
|
))}
|
|
</Box>
|
|
</Box>
|
|
)}
|
|
</Box>
|
|
</SettingTile>
|
|
</SequenceCard>
|
|
</Box>
|
|
);
|
|
}
|