mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-21 09:31:17 -08:00
Merge pull request #310 from SableClient/fix/quick-issues-batch-1
fix: Quick issues batch 1 — UI/UX polish
This commit is contained in:
31 files changed
+324
-27
No files matched your search
@@ -0,0 +1,7 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Account switcher: show a confirmation dialog before signing out of an account.
|
||||
|
||||
Closes #44
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Autocomplete: pressing Enter now selects the highlighted item instead of sending the message. The first item is highlighted on open and ArrowUp/Down navigate the list while keeping typing focus in the editor. Focus returns to the message editor after completing a mention or emoji.
|
||||
|
||||
Closes #35, #69, #79
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Adding account: show a "Cancel" button next to the "Adding account" label so users can abort the flow.
|
||||
|
||||
Closes #66
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Message editor: add `autoCapitalize="sentences"` to respect the OS/keyboard capitalisation setting on mobile.
|
||||
|
||||
Closes #52
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Notifications: add "Favicon Dot: Mentions Only" setting — when enabled, the favicon badge only changes for mentions/keywords, not plain unreads.
|
||||
|
||||
Closes #168
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Video and audio messages: volume level is now persisted across page loads via `localStorage` and shared between all media players.
|
||||
|
||||
Closes #120
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Reduced-motion: add `animation-iteration-count: 1` so spinners stop after one cycle instead of running indefinitely at near-zero speed.
|
||||
|
||||
Closes #2
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Server picker: prevent iOS from restoring the old server name while the user is actively editing the input.
|
||||
|
||||
Closes #45
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Browser tab/PWA: use the correct light (`#ffffff`) and dark (`#1b1a21`) theme-color values via `media` attribute on the meta tags.
|
||||
|
||||
Closes #103
|
||||
+2
-1
@@ -23,7 +23,8 @@
|
||||
property="og:description"
|
||||
content="A Matrix client where you can enjoy the conversation using (not) simple, elegant and secure interface protected by e2ee with the power of open source. And colorful cosmetics. Because yes."
|
||||
/>
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#ffffff" />
|
||||
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#1b1a21" />
|
||||
|
||||
<link id="favicon" rel="shortcut icon" href="./public/favicon.png" />
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
"display": "standalone",
|
||||
"orientation": "portrait",
|
||||
"start_url": "./",
|
||||
"background_color": "#fff",
|
||||
"theme_color": "#fff",
|
||||
"background_color": "#1b1a21",
|
||||
"theme_color": "#1b1a21",
|
||||
"icons": [
|
||||
{
|
||||
"src": "./public/android/android-chrome-36x36.png",
|
||||
|
||||
@@ -28,7 +28,7 @@ import {
|
||||
VideoContent,
|
||||
} from './message';
|
||||
import { UrlPreviewCard, UrlPreviewHolder } from './url-preview';
|
||||
import { Image, MediaControl, Video } from './media';
|
||||
import { Image, MediaControl, PersistedVolumeVideo } from './media';
|
||||
import { ImageViewer } from './image-viewer';
|
||||
import { PdfViewer } from './Pdf-viewer';
|
||||
import { TextViewer } from './text-viewer';
|
||||
@@ -323,7 +323,7 @@ function RenderMessageContentInternal({
|
||||
)
|
||||
: undefined
|
||||
}
|
||||
renderVideo={(p) => <Video {...p} />}
|
||||
renderVideo={(p) => <PersistedVolumeVideo {...p} />}
|
||||
/>
|
||||
)}
|
||||
outlined={outlineAttachment}
|
||||
|
||||
@@ -160,6 +160,8 @@ export const CustomEditor = forwardRef<HTMLDivElement, CustomEditorProps>(
|
||||
onKeyDown={handleKeydown}
|
||||
onKeyUp={onKeyUp}
|
||||
onPaste={onPaste}
|
||||
// Defer to OS capitalization setting (respects iOS sentence-case toggle).
|
||||
autoCapitalize="sentences"
|
||||
// keeps focus after pressing send.
|
||||
onBlur={() => {
|
||||
if (mobileOrTablet()) ReactEditor.focus(editor);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { style } from '@vanilla-extract/css';
|
||||
import { globalStyle, style } from '@vanilla-extract/css';
|
||||
import { DefaultReset, color, config } from 'folds';
|
||||
|
||||
export const AutocompleteMenuBase = style([
|
||||
@@ -38,3 +38,11 @@ export const AutocompleteNotice = style([
|
||||
AutocompleteMenuHeader,
|
||||
{ color: color.SurfaceVariant.OnContainer },
|
||||
]);
|
||||
|
||||
export const AutocompleteMenuItems = style({});
|
||||
|
||||
globalStyle(`${AutocompleteMenuItems} button[data-selected='true']`, {
|
||||
backgroundColor: color.SurfaceVariant.ContainerHover,
|
||||
outline: `2px solid ${color.Primary.Main}`,
|
||||
outlineOffset: -2,
|
||||
});
|
||||
@@ -1,6 +1,5 @@
|
||||
import { ReactNode } from 'react';
|
||||
import { ReactNode, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { isKeyHotkey } from 'is-hotkey';
|
||||
import { Header, Menu, Scroll, config } from 'folds';
|
||||
|
||||
import { preventScrollWithArrowKey, stopPropagation } from '$utils/keyboard';
|
||||
@@ -8,6 +7,9 @@ import { useAlive } from '$hooks/useAlive';
|
||||
import * as css from './AutocompleteMenu.css';
|
||||
import { BaseAutocompleteMenu } from './BaseAutocompleteMenu';
|
||||
|
||||
export const AUTOCOMPLETE_NAVIGATE_EVENT = 'autocomplete-navigate';
|
||||
export type AutocompleteNavigateDetail = { direction: 1 | -1 };
|
||||
|
||||
type AutocompleteMenuProps = {
|
||||
requestClose: () => void;
|
||||
headerContent: ReactNode;
|
||||
@@ -15,6 +17,9 @@ type AutocompleteMenuProps = {
|
||||
};
|
||||
export function AutocompleteMenu({ headerContent, requestClose, children }: AutocompleteMenuProps) {
|
||||
const alive = useAlive();
|
||||
const itemsRef = useRef<HTMLDivElement>(null);
|
||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||
const prevButtonCountRef = useRef(-1);
|
||||
|
||||
const handleDeactivate = () => {
|
||||
if (alive()) {
|
||||
@@ -23,6 +28,41 @@ export function AutocompleteMenu({ headerContent, requestClose, children }: Auto
|
||||
}
|
||||
};
|
||||
|
||||
// Sync data-selected to DOM; reset to index 0 when the item list changes
|
||||
useLayoutEffect(() => {
|
||||
const buttons = Array.from(
|
||||
itemsRef.current?.querySelectorAll<HTMLButtonElement>('button') ?? []
|
||||
);
|
||||
const count = buttons.length;
|
||||
|
||||
let idx = selectedIndex;
|
||||
if (count !== prevButtonCountRef.current) {
|
||||
prevButtonCountRef.current = count;
|
||||
idx = 0;
|
||||
if (selectedIndex !== 0) setSelectedIndex(0);
|
||||
}
|
||||
|
||||
const safeIdx = Math.max(0, Math.min(idx, count - 1));
|
||||
buttons.forEach((btn, i) => {
|
||||
btn.setAttribute('data-selected', String(i === safeIdx));
|
||||
});
|
||||
}, [selectedIndex]);
|
||||
|
||||
// Listen for navigation events dispatched by the editor key handler
|
||||
useEffect(() => {
|
||||
const container = itemsRef.current?.closest('[data-autocomplete-menu]');
|
||||
if (!container) return undefined;
|
||||
const handler = (e: Event) => {
|
||||
const { direction } = (e as CustomEvent<AutocompleteNavigateDetail>).detail;
|
||||
setSelectedIndex((prev) => {
|
||||
const buttons = itemsRef.current?.querySelectorAll('button') ?? [];
|
||||
return Math.max(0, Math.min(prev + direction, buttons.length - 1));
|
||||
});
|
||||
};
|
||||
container.addEventListener(AUTOCOMPLETE_NAVIGATE_EVENT, handler);
|
||||
return () => container.removeEventListener(AUTOCOMPLETE_NAVIGATE_EVENT, handler);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<BaseAutocompleteMenu>
|
||||
<FocusTrap
|
||||
@@ -32,8 +72,6 @@ export function AutocompleteMenu({ headerContent, requestClose, children }: Auto
|
||||
returnFocusOnDeactivate: false,
|
||||
clickOutsideDeactivates: true,
|
||||
allowOutsideClick: true,
|
||||
isKeyForward: (evt: KeyboardEvent) => isKeyHotkey('arrowdown', evt),
|
||||
isKeyBackward: (evt: KeyboardEvent) => isKeyHotkey('arrowup', evt),
|
||||
escapeDeactivates: stopPropagation,
|
||||
}}
|
||||
>
|
||||
@@ -42,7 +80,13 @@ export function AutocompleteMenu({ headerContent, requestClose, children }: Auto
|
||||
{headerContent}
|
||||
</Header>
|
||||
<Scroll style={{ flexGrow: 1 }} onKeyDown={preventScrollWithArrowKey}>
|
||||
<div style={{ padding: config.space.S200 }}>{children}</div>
|
||||
<div
|
||||
ref={itemsRef}
|
||||
className={css.AutocompleteMenuItems}
|
||||
style={{ padding: config.space.S200 }}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</Scroll>
|
||||
</Menu>
|
||||
</FocusTrap>
|
||||
|
||||
@@ -7,7 +7,9 @@ type BaseAutocompleteMenuProps = {
|
||||
export function BaseAutocompleteMenu({ children }: BaseAutocompleteMenuProps) {
|
||||
return (
|
||||
<div className={css.AutocompleteMenuBase}>
|
||||
<div className={css.AutocompleteMenuContainer}>{children}</div>
|
||||
<div className={css.AutocompleteMenuContainer} data-autocomplete-menu="true">
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { KeyboardEvent as ReactKeyboardEvent, useEffect, useMemo } from 'react';
|
||||
import { Editor } from 'slate';
|
||||
import { ReactEditor } from 'slate-react';
|
||||
import { Box, MenuItem, Text, toRem } from 'folds';
|
||||
import { Room } from '$types/matrix-sdk';
|
||||
|
||||
@@ -88,6 +89,7 @@ export function EmoticonAutocomplete({
|
||||
const emoticonEl = createEmoticonElement(key, shortcode);
|
||||
replaceWithElement(editor, query.range, emoticonEl);
|
||||
moveCursor(editor, true);
|
||||
ReactEditor.focus(editor);
|
||||
requestClose();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { KeyboardEvent as ReactKeyboardEvent, useCallback, useEffect } from 'react';
|
||||
import { Editor } from 'slate';
|
||||
import { ReactEditor } from 'slate-react';
|
||||
import { Avatar, Icon, Icons, MenuItem, Text } from 'folds';
|
||||
import { JoinRule, MatrixClient } from '$types/matrix-sdk';
|
||||
import { useAtomValue } from 'jotai';
|
||||
@@ -115,6 +116,7 @@ export function RoomMentionAutocomplete({
|
||||
);
|
||||
replaceWithElement(editor, query.range, mentionEl);
|
||||
moveCursor(editor, true);
|
||||
ReactEditor.focus(editor);
|
||||
requestClose();
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useEffect, KeyboardEvent as ReactKeyboardEvent } from 'react';
|
||||
import { Editor } from 'slate';
|
||||
import { ReactEditor } from 'slate-react';
|
||||
import { Avatar, Icon, Icons, MenuItem, Text } from 'folds';
|
||||
import { MatrixClient, Room, RoomMember } from '$types/matrix-sdk';
|
||||
|
||||
@@ -113,6 +114,7 @@ export function UserMentionAutocomplete({
|
||||
);
|
||||
replaceWithElement(editor, query.range, mentionEl);
|
||||
moveCursor(editor, true);
|
||||
ReactEditor.focus(editor);
|
||||
requestClose();
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { VideoHTMLAttributes, forwardRef } from 'react';
|
||||
import { VideoHTMLAttributes, forwardRef, useEffect, useRef } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import * as css from './media.css';
|
||||
|
||||
@@ -8,3 +8,31 @@ export const Video = forwardRef<HTMLVideoElement, VideoHTMLAttributes<HTMLVideoE
|
||||
<video className={classNames(css.Video, className)} {...props} ref={ref} />
|
||||
)
|
||||
);
|
||||
|
||||
export const MEDIA_VOLUME_KEY = 'mediaVolume';
|
||||
|
||||
export function PersistedVolumeVideo({
|
||||
onVolumeChange,
|
||||
...props
|
||||
}: VideoHTMLAttributes<HTMLVideoElement>) {
|
||||
const innerRef = useRef<HTMLVideoElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const stored = localStorage.getItem(MEDIA_VOLUME_KEY);
|
||||
if (innerRef.current && stored !== null) {
|
||||
const parsed = parseFloat(stored);
|
||||
if (!Number.isNaN(parsed)) innerRef.current.volume = parsed;
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Video
|
||||
{...props}
|
||||
ref={innerRef}
|
||||
onVolumeChange={(e) => {
|
||||
localStorage.setItem(MEDIA_VOLUME_KEY, String((e.target as HTMLVideoElement).volume));
|
||||
onVolumeChange?.(e);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/* eslint-disable jsx-a11y/media-has-caption */
|
||||
import { ReactNode, useCallback, useRef, useState } from 'react';
|
||||
import { ReactNode, useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { Badge, Chip, Icon, IconButton, Icons, ProgressBar, Spinner, Text, toRem } from 'folds';
|
||||
import { EncryptedAttachmentInfo } from 'browser-encrypt-attachment';
|
||||
import { Range } from 'react-range';
|
||||
@@ -18,6 +18,7 @@ import { useThrottle } from '$hooks/useThrottle';
|
||||
import { secondsToMinutesAndSeconds } from '$utils/common';
|
||||
import { decryptFile, downloadEncryptedMedia, downloadMedia, mxcUrlToHttp } from '$utils/matrix';
|
||||
import { useMediaAuthentication } from '$hooks/useMediaAuthentication';
|
||||
import { MEDIA_VOLUME_KEY } from '$components/media';
|
||||
|
||||
const PLAY_TIME_THROTTLE_OPS = {
|
||||
wait: 500,
|
||||
@@ -60,6 +61,14 @@ export function AudioContent({
|
||||
|
||||
const audioRef = useRef<HTMLAudioElement | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const stored = localStorage.getItem(MEDIA_VOLUME_KEY);
|
||||
if (audioRef.current && stored !== null) {
|
||||
const parsed = parseFloat(stored);
|
||||
if (!Number.isNaN(parsed)) audioRef.current.volume = parsed;
|
||||
}
|
||||
}, []);
|
||||
|
||||
const [currentTime, setCurrentTime] = useState(0);
|
||||
// duration in seconds. (NOTE: info.duration is in milliseconds)
|
||||
const infoDuration = info.duration ?? 0;
|
||||
@@ -197,7 +206,14 @@ export function AudioContent({
|
||||
</>
|
||||
),
|
||||
children: (
|
||||
<audio controls={false} autoPlay ref={audioRef}>
|
||||
<audio
|
||||
controls={false}
|
||||
autoPlay
|
||||
ref={audioRef}
|
||||
onVolumeChange={(e) => {
|
||||
localStorage.setItem(MEDIA_VOLUME_KEY, String((e.target as HTMLAudioElement).volume));
|
||||
}}
|
||||
>
|
||||
{srcState.status === AsyncStatus.Success && <source src={srcState.data} type={mimeType} />}
|
||||
</audio>
|
||||
),
|
||||
|
||||
@@ -742,11 +742,35 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
|
||||
const handleKeyDown: KeyboardEventHandler = useCallback(
|
||||
(evt) => {
|
||||
if (autocompleteQuery && isKeyHotkey('arrowdown', evt)) {
|
||||
evt.preventDefault();
|
||||
document
|
||||
.querySelector('[data-autocomplete-menu]')
|
||||
?.dispatchEvent(new CustomEvent('autocomplete-navigate', { detail: { direction: 1 } }));
|
||||
return;
|
||||
}
|
||||
if (autocompleteQuery && isKeyHotkey('arrowup', evt)) {
|
||||
evt.preventDefault();
|
||||
document
|
||||
.querySelector('[data-autocomplete-menu]')
|
||||
?.dispatchEvent(
|
||||
new CustomEvent('autocomplete-navigate', { detail: { direction: -1 } })
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
(isKeyHotkey('mod+enter', evt) || (!enterForNewline && isKeyHotkey('enter', evt))) &&
|
||||
!isComposing(evt)
|
||||
) {
|
||||
evt.preventDefault();
|
||||
if (autocompleteQuery) {
|
||||
const selectedItem =
|
||||
document.querySelector<HTMLButtonElement>(
|
||||
'[data-autocomplete-menu] button[data-selected]'
|
||||
) ?? document.querySelector<HTMLButtonElement>('[data-autocomplete-menu] button');
|
||||
selectedItem?.click();
|
||||
return;
|
||||
}
|
||||
submit().catch((error) => {
|
||||
log.error('submit failed', { roomId }, error);
|
||||
});
|
||||
|
||||
@@ -189,6 +189,10 @@ export function SystemNotification() {
|
||||
const [showUnreadCounts, setShowUnreadCounts] = useSetting(settingsAtom, 'showUnreadCounts');
|
||||
const [badgeCountDMsOnly, setBadgeCountDMsOnly] = useSetting(settingsAtom, 'badgeCountDMsOnly');
|
||||
const [showPingCounts, setShowPingCounts] = useSetting(settingsAtom, 'showPingCounts');
|
||||
const [faviconForMentionsOnly, setFaviconForMentionsOnly] = useSetting(
|
||||
settingsAtom,
|
||||
'faviconForMentionsOnly'
|
||||
);
|
||||
|
||||
// Describe what the current badge combo actually does so users aren't left guessing.
|
||||
const badgeBehaviourSummary = (): string => {
|
||||
@@ -338,6 +342,24 @@ export function SystemNotification() {
|
||||
<Text size="T300" style={{ opacity: 0.7 }}>
|
||||
{badgeBehaviourSummary()}
|
||||
</Text>
|
||||
<SequenceCard
|
||||
className={SequenceCardStyle}
|
||||
variant="SurfaceVariant"
|
||||
direction="Column"
|
||||
gap="400"
|
||||
>
|
||||
<SettingTile
|
||||
title="Favicon Dot: Mentions Only"
|
||||
description="Only change the browser tab favicon when you have mentions or keywords. Unreads without mentions won't affect the favicon."
|
||||
after={
|
||||
<Switch
|
||||
variant="Primary"
|
||||
value={faviconForMentionsOnly}
|
||||
onChange={setFaviconForMentionsOnly}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard
|
||||
className={SequenceCardStyle}
|
||||
variant="SurfaceVariant"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useCallback, useEffect } from 'react';
|
||||
import { Box, Header, Scroll, Spinner, Text, color } from 'folds';
|
||||
import { Box, Chip, Header, Scroll, Spinner, Text, color } from 'folds';
|
||||
import {
|
||||
Outlet,
|
||||
generatePath,
|
||||
@@ -22,6 +22,7 @@ import { AuthFlowsLoader } from '$components/AuthFlowsLoader';
|
||||
import { AuthFlowsProvider } from '$hooks/useAuthFlows';
|
||||
import { AuthServerProvider } from '$hooks/useAuthServer';
|
||||
import { LOGIN_PATH, REGISTER_PATH, RESET_PASSWORD_PATH } from '$pages/paths';
|
||||
import { getHomePath } from '$pages/pathUtils';
|
||||
import { AutoDiscoveryAction, autoDiscovery } from '../../cs-api';
|
||||
import { ServerPicker } from './ServerPicker';
|
||||
import * as css from './styles.css';
|
||||
@@ -139,9 +140,18 @@ export function AuthLayout() {
|
||||
<Text size="H3">Sable</Text>
|
||||
</Box>
|
||||
{isAddingAccount && (
|
||||
<Text size="T200" priority="300" style={{ marginLeft: 'auto', marginRight: 4 }}>
|
||||
Adding account
|
||||
</Text>
|
||||
<Box gap="200" alignItems="Center" style={{ marginLeft: 'auto' }}>
|
||||
<Text size="T200" priority="300">
|
||||
Adding account
|
||||
</Text>
|
||||
<Chip
|
||||
variant="Surface"
|
||||
radii="300"
|
||||
onClick={() => window.location.assign(getHomePath())}
|
||||
>
|
||||
<Text size="T200">Cancel</Text>
|
||||
</Chip>
|
||||
</Box>
|
||||
)}
|
||||
</Header>
|
||||
<Box className={css.AuthCardContent} direction="Column">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
ChangeEventHandler,
|
||||
FocusEventHandler,
|
||||
KeyboardEventHandler,
|
||||
MouseEventHandler,
|
||||
useEffect,
|
||||
@@ -37,10 +38,16 @@ export function ServerPicker({
|
||||
}) {
|
||||
const [serverMenuAnchor, setServerMenuAnchor] = useState<RectCords>();
|
||||
const serverInputRef = useRef<HTMLInputElement>(null);
|
||||
const inputFocusedRef = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
// sync input with it outside server changes
|
||||
if (serverInputRef.current && serverInputRef.current.value !== server) {
|
||||
// sync input with outside server changes, but only when not focused
|
||||
// (on iOS, syncing while focused causes the deleted text to reappear)
|
||||
if (
|
||||
!inputFocusedRef.current &&
|
||||
serverInputRef.current &&
|
||||
serverInputRef.current.value !== server
|
||||
) {
|
||||
serverInputRef.current.value = server;
|
||||
}
|
||||
}, [server]);
|
||||
@@ -52,6 +59,18 @@ export function ServerPicker({
|
||||
if (inputServer) debounceServerSelect(inputServer);
|
||||
};
|
||||
|
||||
const handleInputFocus: FocusEventHandler<HTMLInputElement> = () => {
|
||||
inputFocusedRef.current = true;
|
||||
};
|
||||
|
||||
const handleInputBlur: FocusEventHandler<HTMLInputElement> = () => {
|
||||
inputFocusedRef.current = false;
|
||||
// restore the server value if the input was cleared without selecting a new one
|
||||
if (serverInputRef.current && serverInputRef.current.value.trim() === '') {
|
||||
serverInputRef.current.value = server;
|
||||
}
|
||||
};
|
||||
|
||||
const handleKeyDown: KeyboardEventHandler<HTMLInputElement> = (evt) => {
|
||||
if (evt.key === 'ArrowDown') {
|
||||
evt.preventDefault();
|
||||
@@ -86,6 +105,8 @@ export function ServerPicker({
|
||||
defaultValue={server}
|
||||
onChange={handleServerChange}
|
||||
onKeyDown={handleKeyDown}
|
||||
onFocus={handleInputFocus}
|
||||
onBlur={handleInputBlur}
|
||||
size="500"
|
||||
readOnly={!allowCustomServer}
|
||||
onClick={allowCustomServer ? undefined : handleOpenServerMenu}
|
||||
|
||||
@@ -95,6 +95,7 @@ function PageZoomFeature() {
|
||||
function FaviconUpdater() {
|
||||
const roomToUnread = useAtomValue(roomToUnreadAtom);
|
||||
const [usePushNotifications] = useSetting(settingsAtom, 'usePushNotifications');
|
||||
const [faviconForMentionsOnly] = useSetting(settingsAtom, 'faviconForMentionsOnly');
|
||||
const registration = useAtomValue(registrationAtom);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -115,8 +116,10 @@ function FaviconUpdater() {
|
||||
}
|
||||
});
|
||||
|
||||
if (notification) {
|
||||
setFavicon(highlight ? LogoHighlightSVG : LogoUnreadSVG);
|
||||
if (highlight) {
|
||||
setFavicon(LogoHighlightSVG);
|
||||
} else if (!faviconForMentionsOnly && notification) {
|
||||
setFavicon(LogoUnreadSVG);
|
||||
} else {
|
||||
setFavicon(LogoSVG);
|
||||
}
|
||||
@@ -149,7 +152,7 @@ function FaviconUpdater() {
|
||||
} catch {
|
||||
// Likely Firefox/Gecko-based and doesn't support badging API
|
||||
}
|
||||
}, [roomToUnread, usePushNotifications, registration]);
|
||||
}, [roomToUnread, usePushNotifications, registration, faviconForMentionsOnly]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { MouseEvent, MouseEventHandler, useCallback, useState } from 'react';
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Dialog,
|
||||
Header,
|
||||
Icon,
|
||||
Icons,
|
||||
Menu,
|
||||
@@ -162,6 +165,9 @@ export function AccountSwitcherTab() {
|
||||
const [menuAnchor, setMenuAnchor] = useState<RectCords>();
|
||||
const [busyUserIds, setBusyUserIds] = useState<Set<string>>(new Set());
|
||||
const [settingsOpen, setSettingsOpen] = useState(false);
|
||||
const [confirmSignOutSession, setConfirmSignOutSession] = useState<Session | undefined>(
|
||||
undefined
|
||||
);
|
||||
|
||||
const activeSession = sessions.find((s) => s.userId === activeSessionId) ?? sessions[0];
|
||||
|
||||
@@ -333,7 +339,10 @@ export function AccountSwitcherTab() {
|
||||
isBusy={busyUserIds.has(session.userId)}
|
||||
unread={!isActive ? backgroundUnreads[session.userId] : undefined}
|
||||
onSwitch={handleSwitch}
|
||||
onSignOut={handleSignOut}
|
||||
onSignOut={(pendingSession) => {
|
||||
setMenuAnchor(undefined);
|
||||
setConfirmSignOutSession(pendingSession);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
@@ -365,6 +374,43 @@ export function AccountSwitcherTab() {
|
||||
<Settings requestClose={() => setSettingsOpen(false)} />
|
||||
</Modal500>
|
||||
)}
|
||||
{confirmSignOutSession && (
|
||||
<Modal500 requestClose={() => setConfirmSignOutSession(undefined)}>
|
||||
<Dialog variant="Surface">
|
||||
<Header
|
||||
style={{
|
||||
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
||||
borderBottomWidth: config.borderWidth.B300,
|
||||
}}
|
||||
variant="Surface"
|
||||
size="500"
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="H4">Sign out</Text>
|
||||
</Box>
|
||||
</Header>
|
||||
<Box style={{ padding: config.space.S400 }} direction="Column" gap="400">
|
||||
<Text priority="400">
|
||||
Are you sure you want to sign out of <b>{confirmSignOutSession.userId}</b>?
|
||||
</Text>
|
||||
<Box direction="Column" gap="200">
|
||||
<Button
|
||||
variant="Critical"
|
||||
onClick={() => {
|
||||
handleSignOut(confirmSignOutSession);
|
||||
setConfirmSignOutSession(undefined);
|
||||
}}
|
||||
>
|
||||
<Text size="B400">Sign out</Text>
|
||||
</Button>
|
||||
<Button variant="Secondary" onClick={() => setConfirmSignOutSession(undefined)}>
|
||||
<Text size="B400">Cancel</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
</Dialog>
|
||||
</Modal500>
|
||||
)}
|
||||
</SidebarItem>
|
||||
);
|
||||
}
|
||||
@@ -46,7 +46,6 @@ export function getSupportedAudioCodec(): string | null {
|
||||
const userAgent = globalThis.navigator?.userAgent ?? '';
|
||||
const isIOS =
|
||||
/iPad|iPhone|iPod/.test(userAgent) ||
|
||||
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
||||
(globalThis.navigator?.platform === 'MacIntel' && globalThis.navigator?.maxTouchPoints > 1);
|
||||
const isSafari = /^((?!chrome|android|crios|fxios|edgios).)*safari/i.test(userAgent) || isIOS;
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ export interface Settings {
|
||||
autoplayEmojis: boolean;
|
||||
saveStickerEmojiBandwidth: boolean;
|
||||
alwaysShowCallButton: boolean;
|
||||
faviconForMentionsOnly: boolean;
|
||||
|
||||
// furry stuff
|
||||
renderAnimals: boolean;
|
||||
@@ -178,6 +179,7 @@ const defaultSettings: Settings = {
|
||||
autoplayEmojis: true,
|
||||
saveStickerEmojiBandwidth: false,
|
||||
alwaysShowCallButton: false,
|
||||
faviconForMentionsOnly: false,
|
||||
|
||||
// furry stuff
|
||||
renderAnimals: true,
|
||||
|
||||
@@ -37,7 +37,6 @@ describe('sanitizeCustomHtml – XSS prevention', () => {
|
||||
});
|
||||
|
||||
it('strips javascript: href on anchor tags', () => {
|
||||
// eslint-disable-next-line no-script-url
|
||||
const result = sanitizeCustomHtml('<a href="javascript:alert(\'xss\')">link</a>');
|
||||
expect(result).not.toMatch(/javascript:/);
|
||||
});
|
||||
|
||||
@@ -187,6 +187,7 @@ pre {
|
||||
|
||||
body.reduced-motion * {
|
||||
animation-duration: 0.001ms !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
transition-duration: 0.001ms !important;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user