mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-21 17:41:25 -08:00
refactor: remove unused exports flagged by fallow
This commit is contained in:
1 parent
f6876a7cd0
commit
90115b5705
151 files changed
+187
-981
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Remove the remaining unused exports flagged by fallow across the codebase.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Remove unused exports flagged by fallow across notification transport, command barrel, and plugin barrels.
|
||||
@@ -7,9 +7,9 @@ import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import { UIAFlowOverlay } from './UIAFlowOverlay';
|
||||
import { OAuthStage, PasswordStage, SSOStage } from './uia-stages';
|
||||
|
||||
export const SUPPORTED_IN_APP_UIA_STAGES = [AuthType.Password, AuthType.Sso, AuthType.OAuth];
|
||||
const SUPPORTED_IN_APP_UIA_STAGES = [AuthType.Password, AuthType.Sso, AuthType.OAuth];
|
||||
|
||||
export const pickUIAFlow = (uiaFlows: UIAFlow[]): UIAFlow | undefined => {
|
||||
const pickUIAFlow = (uiaFlows: UIAFlow[]): UIAFlow | undefined => {
|
||||
const passwordFlow = getUIAFlowForStages(uiaFlows, [AuthType.Password]);
|
||||
if (passwordFlow) return passwordFlow;
|
||||
const oauthFlow = getUIAFlowForStages(uiaFlows, [AuthType.OAuth]);
|
||||
|
||||
@@ -14,7 +14,7 @@ export const FALLBACK_CLIENT_CONFIG: ClientConfig = {
|
||||
hashRouter: { enabled: false, basename: '/' },
|
||||
};
|
||||
|
||||
export const getClientConfig = async (): Promise<ClientConfig> => {
|
||||
const getClientConfig = async (): Promise<ClientConfig> => {
|
||||
const preloaded = takePreloadedConfig();
|
||||
if (preloaded !== undefined) {
|
||||
const data = await preloaded.catch(() => undefined);
|
||||
|
||||
@@ -12,7 +12,7 @@ import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
|
||||
import { SettingTile } from './setting-tile';
|
||||
import { SecretStorageRecoveryKey, SecretStorageRecoveryPassphrase } from './SecretStorage';
|
||||
|
||||
export enum ManualVerificationMethod {
|
||||
enum ManualVerificationMethod {
|
||||
RecoveryPassphrase = 'passphrase',
|
||||
RecoveryKey = 'key',
|
||||
}
|
||||
@@ -20,7 +20,7 @@ type ManualVerificationMethodSwitcherProps = {
|
||||
value: ManualVerificationMethod;
|
||||
onChange: (value: ManualVerificationMethod) => void;
|
||||
};
|
||||
export function ManualVerificationMethodSwitcher({
|
||||
function ManualVerificationMethodSwitcher({
|
||||
value,
|
||||
onChange,
|
||||
}: ManualVerificationMethodSwitcherProps) {
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { useCallback, useState } from 'react';
|
||||
import type { MatrixClient, Room, IHierarchyRoom } from '$types/matrix-sdk';
|
||||
import { useCallback } from 'react';
|
||||
import type { MatrixClient, Room } from '$types/matrix-sdk';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useMatrixClient } from '$hooks/useMatrixClient';
|
||||
import type { LocalRoomSummary } from '$hooks/useLocalRoomSummary';
|
||||
import { useLocalRoomSummary } from '$hooks/useLocalRoomSummary';
|
||||
import type { AsyncState } from '$hooks/useAsyncCallback';
|
||||
import { AsyncStatus } from '$hooks/useAsyncCallback';
|
||||
|
||||
export type IRoomSummary = Awaited<ReturnType<MatrixClient['getRoomSummary']>>;
|
||||
|
||||
@@ -39,54 +37,3 @@ export function LocalRoomSummaryLoader({
|
||||
|
||||
return children(summary);
|
||||
}
|
||||
|
||||
export function HierarchyRoomSummaryLoader({
|
||||
roomId,
|
||||
children,
|
||||
}: {
|
||||
roomId: string;
|
||||
children: (state: AsyncState<IHierarchyRoom, Error>) => ReactNode;
|
||||
}) {
|
||||
const mx = useMatrixClient();
|
||||
|
||||
const fetchSummary = useCallback(() => mx.getRoomHierarchy(roomId, 1, 1), [mx, roomId]);
|
||||
const [errorMemo, setError] = useState<Error>();
|
||||
|
||||
const { data, error } = useQuery({
|
||||
queryKey: [roomId, `hierarchy`],
|
||||
queryFn: fetchSummary,
|
||||
retryOnMount: false,
|
||||
refetchOnWindowFocus: false,
|
||||
retry: (failureCount, err) => {
|
||||
setError(err);
|
||||
if (failureCount > 3) return false;
|
||||
return true;
|
||||
},
|
||||
});
|
||||
|
||||
let state: AsyncState<IHierarchyRoom, Error> = {
|
||||
status: AsyncStatus.Loading,
|
||||
};
|
||||
if (error) {
|
||||
state = {
|
||||
status: AsyncStatus.Error,
|
||||
error,
|
||||
};
|
||||
}
|
||||
if (errorMemo) {
|
||||
state = {
|
||||
status: AsyncStatus.Error,
|
||||
error: errorMemo,
|
||||
};
|
||||
}
|
||||
|
||||
const summary = data?.rooms[0] ?? undefined;
|
||||
if (summary) {
|
||||
state = {
|
||||
status: AsyncStatus.Success,
|
||||
data: summary,
|
||||
};
|
||||
}
|
||||
|
||||
return children(state);
|
||||
}
|
||||
@@ -2,7 +2,6 @@ import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { Box, config, Text } from 'folds';
|
||||
import { AnimatePresence, motion, useReducedMotion, type Variants } from 'framer-motion';
|
||||
import { SyncState } from '$types/matrix-sdk';
|
||||
import { type TitlebarStatusView } from '$state/titlebarStatus';
|
||||
import { ContainerColor } from '$styles/ContainerColor.css';
|
||||
|
||||
@@ -15,30 +14,6 @@ type SyncConnectionStatusProps = {
|
||||
icon?: React.ReactNode;
|
||||
};
|
||||
|
||||
export function getSyncConnectionStatusView(
|
||||
current: SyncState | null,
|
||||
previous: SyncState | null | undefined
|
||||
): TitlebarStatusView | null {
|
||||
if (
|
||||
(current === SyncState.Prepared ||
|
||||
current === SyncState.Syncing ||
|
||||
current === SyncState.Catchup) &&
|
||||
previous !== SyncState.Syncing
|
||||
) {
|
||||
return { text: 'Connecting...', variant: 'Success' };
|
||||
}
|
||||
|
||||
if (current === SyncState.Reconnecting) {
|
||||
return { text: 'Connection Lost! Reconnecting...', variant: 'Warning' };
|
||||
}
|
||||
|
||||
if (current === SyncState.Error) {
|
||||
return { text: 'Connection Lost!', variant: 'Critical' };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export function SyncConnectionStatusBanner({ status }: SyncConnectionStatusProps) {
|
||||
const shouldReduceMotion = useReducedMotion();
|
||||
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
export { AppShell } from './AppShell';
|
||||
export { SystemBarShell } from './SystemBarShell';
|
||||
@@ -1,3 +1,2 @@
|
||||
export type { HighlightCodeDeps, HighlightCodeInput, HighlightResult } from '$plugins/arborium';
|
||||
export { highlightCode, useArboriumThemeStatus } from '$plugins/arborium';
|
||||
export { CodeHighlightRenderer } from './CodeHighlightRenderer';
|
||||
@@ -13,7 +13,7 @@ import { getMxIdServer } from '$utils/mxIdHelper';
|
||||
import { CreateRoomAccess } from './types';
|
||||
import * as prefix from '$unstable/prefixes';
|
||||
|
||||
export const createRoomCreationContent = (
|
||||
const createRoomCreationContent = (
|
||||
type: RoomType | undefined,
|
||||
allowFederation: boolean,
|
||||
additionalCreators: string[] | undefined
|
||||
@@ -32,7 +32,7 @@ export const createRoomCreationContent = (
|
||||
return content;
|
||||
};
|
||||
|
||||
export const createRoomJoinRulesState = (
|
||||
const createRoomJoinRulesState = (
|
||||
access: CreateRoomAccess,
|
||||
parent: Room | undefined,
|
||||
knock: boolean
|
||||
@@ -66,7 +66,7 @@ export const createRoomJoinRulesState = (
|
||||
};
|
||||
};
|
||||
|
||||
export const createRoomParentState = (parent: Room) => ({
|
||||
const createRoomParentState = (parent: Room) => ({
|
||||
type: EventType.SpaceParent,
|
||||
state_key: parent.roomId,
|
||||
content: {
|
||||
@@ -87,13 +87,13 @@ export const createRoomEncryptionState = () => ({
|
||||
},
|
||||
});
|
||||
|
||||
export const createRoomCallState = () => ({
|
||||
const createRoomCallState = () => ({
|
||||
type: prefix.MATRIX_UNSTABLE_ROOM_TYPE_CALL_PROPERTY_NAME,
|
||||
state_key: '',
|
||||
content: {},
|
||||
});
|
||||
|
||||
export const createVoiceRoomPowerLevelsOverride = () => ({
|
||||
const createVoiceRoomPowerLevelsOverride = () => ({
|
||||
events: {
|
||||
[EventType.GroupCallMemberPrefix]: 0,
|
||||
},
|
||||
|
||||
@@ -119,7 +119,3 @@ export const EditorToolbarBase = style({
|
||||
export const EditorToolbar = style({
|
||||
padding: config.space.S100,
|
||||
});
|
||||
|
||||
export const MarkdownBtnBox = style({
|
||||
paddingRight: config.space.S100,
|
||||
});
|
||||
@@ -248,7 +248,7 @@ function MarkdownHeadingButton() {
|
||||
);
|
||||
}
|
||||
|
||||
export function MarkdownToolbar() {
|
||||
function MarkdownToolbar() {
|
||||
const [shortcutOverrides] = useSetting(settingsAtom, 'shortcutOverrides');
|
||||
|
||||
return (
|
||||
|
||||
@@ -39,7 +39,7 @@ export const AutocompleteNotice = style([
|
||||
{ color: color.SurfaceVariant.OnContainer },
|
||||
]);
|
||||
|
||||
export const AutocompleteMenuItems = style({});
|
||||
const AutocompleteMenuItems = style({});
|
||||
|
||||
globalStyle(`${AutocompleteMenuItems} button[data-selected='true']`, {
|
||||
backgroundColor: color.SurfaceVariant.ContainerHover,
|
||||
|
||||
@@ -24,7 +24,7 @@ export type AutocompleteQuery<TPrefix extends string> = {
|
||||
text: string;
|
||||
};
|
||||
|
||||
export const getAutocompletePrefix = <TPrefix extends string>(
|
||||
const getAutocompletePrefix = <TPrefix extends string>(
|
||||
editor: Editor,
|
||||
queryRange: BaseRange,
|
||||
validPrefixes: readonly TPrefix[]
|
||||
@@ -33,11 +33,8 @@ export const getAutocompletePrefix = <TPrefix extends string>(
|
||||
return validPrefixes.find((p) => world.startsWith(p));
|
||||
};
|
||||
|
||||
export const getAutocompleteQueryText = (
|
||||
editor: Editor,
|
||||
queryRange: BaseRange,
|
||||
prefix: string
|
||||
): string => Editor.string(editor, queryRange).slice(prefix.length);
|
||||
const getAutocompleteQueryText = (editor: Editor, queryRange: BaseRange, prefix: string): string =>
|
||||
Editor.string(editor, queryRange).slice(prefix.length);
|
||||
|
||||
export const getAutocompleteQuery = <TPrefix extends string = AutocompletePrefix>(
|
||||
editor: Editor,
|
||||
|
||||
@@ -203,7 +203,7 @@ export const toPlainText = (
|
||||
* Convert slate internal representation to a raw plain text string without any replacements.
|
||||
* This is used for link extraction to ensure we have the full context for markdown blocks.
|
||||
*/
|
||||
export const toRawText = (node: Descendant | Descendant[]): string => {
|
||||
const toRawText = (node: Descendant | Descendant[]): string => {
|
||||
if (Array.isArray(node)) return node.map(toRawText).join('');
|
||||
if (Text.isText(node)) return node.text;
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ export const mentionNameForUserAutocomplete = (
|
||||
};
|
||||
|
||||
/** Same #-prefix rule as {@link RoomMentionAutocomplete}. */
|
||||
export const formatRoomMentionDisplayName = (name: string): string => {
|
||||
const formatRoomMentionDisplayName = (name: string): string => {
|
||||
if (name === '@room') return '@room';
|
||||
return name.startsWith('#') ? name : `#${name}`;
|
||||
};
|
||||
@@ -172,7 +172,7 @@ interface PointUntilCharOptions {
|
||||
match: (char: string) => boolean;
|
||||
reverse?: boolean;
|
||||
}
|
||||
export const getPointUntilChar = (
|
||||
const getPointUntilChar = (
|
||||
editor: Editor,
|
||||
cursorPoint: BasePoint,
|
||||
options: PointUntilCharOptions
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { ReactNode } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import * as css from './styles.css';
|
||||
|
||||
export const getDOMGroupId = (id: string): string => `EmojiBoardGroup-${id}`;
|
||||
const getDOMGroupId = (id: string): string => `EmojiBoardGroup-${id}`;
|
||||
|
||||
export const EmojiGroup = as<
|
||||
'div',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { SmileySadIcon } from '@phosphor-icons/react';
|
||||
import { Box, toRem, config, Text } from 'folds';
|
||||
|
||||
export function GifSearching() {
|
||||
function GifSearching() {
|
||||
return (
|
||||
<Box
|
||||
style={{ padding: `${toRem(60)} ${config.space.S500}` }}
|
||||
@@ -15,7 +15,7 @@ export function GifSearching() {
|
||||
);
|
||||
}
|
||||
|
||||
export function GifSearchError({ error }: { error: string }) {
|
||||
function GifSearchError({ error }: { error: string }) {
|
||||
return (
|
||||
<Box
|
||||
style={{ padding: `${toRem(60)} ${config.space.S500}` }}
|
||||
@@ -29,7 +29,7 @@ export function GifSearchError({ error }: { error: string }) {
|
||||
);
|
||||
}
|
||||
|
||||
export function NoGifResults() {
|
||||
function NoGifResults() {
|
||||
return (
|
||||
<Box
|
||||
style={{ padding: `${toRem(60)} ${config.space.S500}` }}
|
||||
|
||||
@@ -188,21 +188,6 @@ export const StickerImg = style([
|
||||
},
|
||||
]);
|
||||
|
||||
export const GifContainer = style({
|
||||
columnCount: 3,
|
||||
columnGap: toRem(8),
|
||||
padding: toRem(16),
|
||||
|
||||
'@media': {
|
||||
'(max-width: 768px)': {
|
||||
columnCount: 2,
|
||||
},
|
||||
'(max-width: 480px)': {
|
||||
columnCount: 1,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const GifItem = style([
|
||||
DefaultReset,
|
||||
FocusOutline,
|
||||
@@ -222,13 +207,6 @@ export const GifItem = style([
|
||||
},
|
||||
]);
|
||||
|
||||
export const GifImg = style({
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
objectFit: 'cover',
|
||||
borderRadius: config.radii.R400,
|
||||
});
|
||||
|
||||
export const TextLink = style({
|
||||
color: 'var(--tc-link)',
|
||||
cursor: 'pointer',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { style } from '@vanilla-extract/css';
|
||||
import { DefaultReset, color, config, toRem } from 'folds';
|
||||
import { DefaultReset, color, config } from 'folds';
|
||||
|
||||
export const EventHistory = style([
|
||||
DefaultReset,
|
||||
@@ -32,21 +32,6 @@ export const EventItem = style({
|
||||
},
|
||||
},
|
||||
});
|
||||
export const MessageOptionsBase = style([
|
||||
DefaultReset,
|
||||
{
|
||||
position: 'absolute',
|
||||
top: toRem(-30),
|
||||
right: 0,
|
||||
zIndex: 1,
|
||||
},
|
||||
]);
|
||||
export const MessageOptionsBar = style([
|
||||
DefaultReset,
|
||||
{
|
||||
padding: config.space.S100,
|
||||
},
|
||||
]);
|
||||
export const MenuOptions = style({
|
||||
position: 'absolute',
|
||||
right: '0',
|
||||
|
||||
@@ -242,7 +242,7 @@ function renderTombstone(_ctx: MessagePreviewRendererContext, event: MatrixEvent
|
||||
return <Text>{event.getContent().body ?? 'This room has been replaced.'}</Text>;
|
||||
}
|
||||
|
||||
export function useMessagePreviewRenderer(options: MessagePreviewRendererOptions) {
|
||||
function useMessagePreviewRenderer(options: MessagePreviewRendererOptions) {
|
||||
const mx = useMatrixClient();
|
||||
const context = useMemo<MessagePreviewRendererContext>(() => ({ ...options, mx }), [mx, options]);
|
||||
const handlers = useMemo(
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import { recipe } from '@vanilla-extract/recipes';
|
||||
import { style } from '@vanilla-extract/css';
|
||||
import { DefaultReset, config, toRem } from 'folds';
|
||||
|
||||
export const GalleryHolder = style({
|
||||
marginTop: config.space.S200,
|
||||
});
|
||||
|
||||
export const GalleryImageGrid = recipe({
|
||||
base: [
|
||||
DefaultReset,
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import { style } from '@vanilla-extract/css';
|
||||
import { color, config, toRem } from 'folds';
|
||||
|
||||
export const ReplyBend = style({
|
||||
flexShrink: 0,
|
||||
});
|
||||
|
||||
export const LocationRendererBody = style({
|
||||
maxWidth: toRem(500),
|
||||
backgroundColor: color.SurfaceVariant.Container,
|
||||
|
||||
@@ -108,7 +108,7 @@ export function UnsupportedContent({ body }: BrokenContentProps) {
|
||||
);
|
||||
}
|
||||
|
||||
export function BrokenContent({ body }: BrokenContentProps) {
|
||||
function BrokenContent({ body }: BrokenContentProps) {
|
||||
return (
|
||||
<Text>
|
||||
<MessageBrokenContent body={body} />
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import { style } from '@vanilla-extract/css';
|
||||
import { config, toRem } from 'folds';
|
||||
|
||||
export const ReplyBend = style({
|
||||
flexShrink: 0,
|
||||
});
|
||||
|
||||
export const ThreadIndicator = style({
|
||||
opacity: config.opacity.P300,
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ type ReplyLayoutProps = {
|
||||
mentioned: boolean;
|
||||
replyIcon?: JSX.Element;
|
||||
};
|
||||
export const ReplyLayout = as<'div', ReplyLayoutProps>(
|
||||
const ReplyLayout = as<'div', ReplyLayoutProps>(
|
||||
({ username, userColor, icon, className, mentioned, children, replyIcon, ...props }, ref) => (
|
||||
<Box
|
||||
className={classNames(css.Reply, className)}
|
||||
|
||||
@@ -34,7 +34,7 @@ import {
|
||||
} from '../../../theme/themeLibrary';
|
||||
import { decryptFile, downloadEncryptedMedia, downloadMedia, mxcUrlToHttp } from '$utils/matrix';
|
||||
|
||||
export const MAX_SABLE_CSS_ATTACHMENT_BYTES = 1024 * 1024;
|
||||
const MAX_SABLE_CSS_ATTACHMENT_BYTES = 1024 * 1024;
|
||||
|
||||
type UploadedSableCssContentProps = {
|
||||
body: string;
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { RecipeVariants } from '@vanilla-extract/recipes';
|
||||
import { recipe } from '@vanilla-extract/recipes';
|
||||
import { DefaultReset, color, config, toRem } from 'folds';
|
||||
|
||||
export const StickySection = style({
|
||||
const StickySection = style({
|
||||
position: 'sticky',
|
||||
top: config.space.S100,
|
||||
});
|
||||
|
||||
@@ -80,7 +80,7 @@ type MessageQuickReactionsProps = {
|
||||
onReaction: ReactionHandler;
|
||||
count: number;
|
||||
};
|
||||
export const MessageQuickReactions = as<'div', MessageQuickReactionsProps>(
|
||||
const MessageQuickReactions = as<'div', MessageQuickReactionsProps>(
|
||||
({ onReaction, count, ...props }, ref) => {
|
||||
const mx = useMatrixClient();
|
||||
const recentEmojis = useRecentEmoji(mx, count);
|
||||
@@ -179,7 +179,7 @@ const MessageCopyTextItem = as<
|
||||
);
|
||||
});
|
||||
|
||||
export const MessagePinItem = as<
|
||||
const MessagePinItem = as<
|
||||
'button',
|
||||
{
|
||||
room: Room;
|
||||
@@ -219,7 +219,7 @@ export const MessagePinItem = as<
|
||||
);
|
||||
});
|
||||
|
||||
export const MessageBookmarkItem = as<
|
||||
const MessageBookmarkItem = as<
|
||||
'button',
|
||||
{
|
||||
room: Room;
|
||||
@@ -259,7 +259,7 @@ export const MessageBookmarkItem = as<
|
||||
);
|
||||
});
|
||||
|
||||
export const MessageFavoriteGifItem = as<
|
||||
const MessageFavoriteGifItem = as<
|
||||
'button',
|
||||
{
|
||||
room: Room;
|
||||
@@ -335,7 +335,7 @@ export type OptionEmojiMenuProps = {
|
||||
ActualMessage?: ReactNode;
|
||||
dragOpts?: DragOptsProps;
|
||||
};
|
||||
export function OptionsEmojiBoard({
|
||||
function OptionsEmojiBoard({
|
||||
mEvent,
|
||||
onReactionToggle,
|
||||
closeMenu,
|
||||
@@ -567,7 +567,7 @@ export type OptionMenuProps = {
|
||||
dragOpts?: DragOptsProps;
|
||||
};
|
||||
|
||||
export function OptionMenu({
|
||||
function OptionMenu({
|
||||
mEvent,
|
||||
room,
|
||||
closeMenu,
|
||||
|
||||
@@ -112,11 +112,6 @@ export const BannerSubtitle = style({
|
||||
opacity: 0.7,
|
||||
});
|
||||
|
||||
export const BannerRoomName = style({
|
||||
color: color.Primary.Main,
|
||||
fontWeight: 600,
|
||||
});
|
||||
|
||||
// Caps tall previews and fades the bottom edge when content overflows.
|
||||
// Desktop: 25vh, mobile (≤768px): 35vh.
|
||||
export const BannerBody = style({
|
||||
|
||||
@@ -16,7 +16,7 @@ export type DisplayedRoom = {
|
||||
eventId?: string;
|
||||
};
|
||||
|
||||
export function useDisplayedRoom(section: SectionNav | null): DisplayedRoom | undefined {
|
||||
function useDisplayedRoom(section: SectionNav | null): DisplayedRoom | undefined {
|
||||
const location = useLocation();
|
||||
const lastRoom = useAtomValue(lastVisitedRoomAtom);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export const GESTURE_LOCK_THRESHOLD = 8;
|
||||
export const DRAWER_COMMIT_FRACTION = 0.22;
|
||||
export const DRAWER_VELOCITY_THRESHOLD = 0.45;
|
||||
const GESTURE_LOCK_THRESHOLD = 8;
|
||||
const DRAWER_COMMIT_FRACTION = 0.22;
|
||||
const DRAWER_VELOCITY_THRESHOLD = 0.45;
|
||||
|
||||
export type MobileGestureMode = 'pending' | 'vertical' | 'drawer' | 'message' | 'chat' | 'blocked';
|
||||
|
||||
|
||||
@@ -61,13 +61,13 @@ export const RoomCardBase = as<'div'>(({ className, ...props }, ref) => (
|
||||
/>
|
||||
));
|
||||
|
||||
export const RoomCardName = as<'h6'>(({ children, ...props }, ref) => (
|
||||
const RoomCardName = as<'h6'>(({ children, ...props }, ref) => (
|
||||
<Text as="h6" size="H6" truncate {...props} ref={ref}>
|
||||
{children}
|
||||
</Text>
|
||||
));
|
||||
|
||||
export const RoomCardTopic = as<'p'>(({ children, className, ...props }, ref) => (
|
||||
const RoomCardTopic = as<'p'>(({ children, className, ...props }, ref) => (
|
||||
<Text
|
||||
as="p"
|
||||
size="T200"
|
||||
|
||||
@@ -32,7 +32,7 @@ export const SidebarStack = style([
|
||||
]);
|
||||
|
||||
const DropLineDist = createVar();
|
||||
export const DropTarget = style({
|
||||
const DropTarget = style({
|
||||
vars: {
|
||||
[DropLineDist]: toRem(-8),
|
||||
},
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { ComponentProps, ReactNode, RefCallback } from 'react';
|
||||
import { mobileOrTablet } from '$utils/user-agent';
|
||||
import * as css from './Sidebar.css';
|
||||
|
||||
export const SidebarItemBottom = as<'div', css.SidebarItemVariants>(
|
||||
const SidebarItemBottom = as<'div', css.SidebarItemVariants>(
|
||||
({ as: AsSidebarAvatarBox = 'div', className, active, ...props }, ref) => (
|
||||
<AsSidebarAvatarBox
|
||||
className={classNames(css.SidebarItemBottom({ active }), className)}
|
||||
|
||||
@@ -47,7 +47,7 @@ export type EmbedHeaderProps = {
|
||||
source: string;
|
||||
after?: ReactNode;
|
||||
};
|
||||
export const EmbedHeader = as<'div', EmbedHeaderProps>(({ title, source, after }) => (
|
||||
const EmbedHeader = as<'div', EmbedHeaderProps>(({ title, source, after }) => (
|
||||
<AttachmentHeader>
|
||||
<Box alignItems="Center" gap="200" grow="Yes">
|
||||
<Box shrink="No">
|
||||
@@ -70,7 +70,7 @@ export const EmbedHeader = as<'div', EmbedHeaderProps>(({ title, source, after }
|
||||
type EmbedOpenButtonProps = {
|
||||
url: string;
|
||||
};
|
||||
export function EmbedOpenButton({ url }: EmbedOpenButtonProps) {
|
||||
function EmbedOpenButton({ url }: EmbedOpenButtonProps) {
|
||||
return (
|
||||
<IconButton size="300" radii="300" onClick={() => window.open(url, '_blank')}>
|
||||
{sizedIcon(Link, '100')}
|
||||
@@ -83,7 +83,7 @@ type YoutubeElementProps = {
|
||||
embedData: OEmbed;
|
||||
};
|
||||
|
||||
export const YoutubeElement = as<'div', YoutubeElementProps>(({ videoInfo, embedData }) => {
|
||||
const YoutubeElement = as<'div', YoutubeElementProps>(({ videoInfo, embedData }) => {
|
||||
const thumbnailUrl = `https://i.ytimg.com/vi/${videoInfo.videoId}/hqdefault.jpg`;
|
||||
|
||||
const timestamp = videoInfo.timestamp ? `&start=${videoInfo.timestamp}` : '';
|
||||
|
||||
@@ -13,18 +13,6 @@ export const UrlPreview = style([
|
||||
},
|
||||
]);
|
||||
|
||||
export const UrlPreviewImg = style([
|
||||
DefaultReset,
|
||||
{
|
||||
width: toRem(100),
|
||||
height: toRem(100),
|
||||
objectFit: 'cover',
|
||||
objectPosition: 'center',
|
||||
flexShrink: 0,
|
||||
overflow: 'hidden',
|
||||
},
|
||||
]);
|
||||
|
||||
export const UrlPreviewMediaWell = style([
|
||||
DefaultReset,
|
||||
{
|
||||
|
||||
@@ -1,15 +1,6 @@
|
||||
import { style } from '@vanilla-extract/css';
|
||||
import { color, config, toRem } from 'folds';
|
||||
|
||||
export const UserHeader = style({
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
zIndex: 1,
|
||||
padding: config.space.S200,
|
||||
});
|
||||
|
||||
export const UserHero = style({
|
||||
position: 'relative',
|
||||
});
|
||||
|
||||
@@ -17,11 +17,11 @@ export function bookmarkItemEventType(bookmarkId: string): string {
|
||||
return `${MATRIX_SABLE_UNSTABLE_BOOKMARK_ITEM_EVENT_PREFIX}${bookmarkId}`;
|
||||
}
|
||||
|
||||
export function buildMatrixURI(roomId: string, eventId: string): string {
|
||||
function buildMatrixURI(roomId: string, eventId: string): string {
|
||||
return `matrix:roomid/${encodeURIComponent(roomId)}/e/${encodeURIComponent(eventId)}`;
|
||||
}
|
||||
|
||||
export function extractBodyPreview(mEvent: MatrixEvent, maxLength = 120): string {
|
||||
function extractBodyPreview(mEvent: MatrixEvent, maxLength = 120): string {
|
||||
const content = mEvent.getContent();
|
||||
const body = content?.body;
|
||||
if (typeof body !== 'string' || body.length === 0) return '';
|
||||
|
||||
@@ -28,7 +28,7 @@ interface MemberWithMembershipData {
|
||||
type CallMemberCardProps = {
|
||||
member: CallMembership;
|
||||
};
|
||||
export function CallMemberCard({ member }: CallMemberCardProps) {
|
||||
function CallMemberCard({ member }: CallMemberCardProps) {
|
||||
const mx = useMatrixClient();
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
const room = useRoom();
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
SpeakerSlash,
|
||||
VideoCamera,
|
||||
VideoCameraSlash,
|
||||
ScreenShare,
|
||||
} from '$components/icons/phosphor';
|
||||
import { useAtom } from 'jotai';
|
||||
import * as css from './styles.css';
|
||||
@@ -116,38 +115,6 @@ export function VideoButton({ enabled, onToggle }: VideoButtonProps) {
|
||||
);
|
||||
}
|
||||
|
||||
type ScreenShareButtonProps = {
|
||||
enabled: boolean;
|
||||
onToggle: () => void;
|
||||
};
|
||||
export function ScreenShareButton({ enabled, onToggle }: ScreenShareButtonProps) {
|
||||
return (
|
||||
<TooltipProvider
|
||||
position="Top"
|
||||
delay={500}
|
||||
tooltip={
|
||||
<Tooltip>
|
||||
<Text size="T200">{enabled ? 'Stop Screenshare' : 'Start Screenshare'}</Text>
|
||||
</Tooltip>
|
||||
}
|
||||
>
|
||||
{(anchorRef) => (
|
||||
<IconButton
|
||||
ref={anchorRef}
|
||||
variant={enabled ? 'Success' : 'Surface'}
|
||||
fill="Soft"
|
||||
radii="400"
|
||||
size="400"
|
||||
onClick={() => onToggle()}
|
||||
outlined
|
||||
>
|
||||
{sizedIcon(ScreenShare, '300', { filled: enabled })}
|
||||
</IconButton>
|
||||
)}
|
||||
</TooltipProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export function ChatButton() {
|
||||
const [chat, setChat] = useAtom(callChatAtom);
|
||||
|
||||
|
||||
@@ -56,15 +56,3 @@ export const resolveCallToneSources = async (
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export const revokeUnusedCustomToneUrls = (
|
||||
resolved: ResolvedCallToneSources,
|
||||
activeSource: string | null
|
||||
): void => {
|
||||
if (resolved.customRingtoneObjectUrl && resolved.customRingtoneObjectUrl !== activeSource) {
|
||||
URL.revokeObjectURL(resolved.customRingtoneObjectUrl);
|
||||
}
|
||||
if (resolved.customRingbackObjectUrl && resolved.customRingbackObjectUrl !== activeSource) {
|
||||
URL.revokeObjectURL(resolved.customRingbackObjectUrl);
|
||||
}
|
||||
};
|
||||
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
MAX_CALL_NOTIFICATION_LIFETIME_MS,
|
||||
normalizeCallIntent,
|
||||
toCallNotificationType,
|
||||
type CallIntentKind,
|
||||
@@ -13,8 +12,6 @@ export const REFERENCE_REL_TYPE = 'm.reference';
|
||||
export type NotificationType = CallNotificationType;
|
||||
export type NotificationIntentKind = CallIntentKind;
|
||||
|
||||
export { MAX_CALL_NOTIFICATION_LIFETIME_MS };
|
||||
|
||||
export type RtcNotificationEventLike = {
|
||||
type: string;
|
||||
sender: string;
|
||||
|
||||
@@ -47,10 +47,6 @@ export const CallMemberCard = style({
|
||||
padding: config.space.S300,
|
||||
});
|
||||
|
||||
export const CallControlContainer = style({
|
||||
padding: config.space.S400,
|
||||
});
|
||||
|
||||
export const PrescreenMessage = style({
|
||||
padding: config.space.S200,
|
||||
});
|
||||
@@ -61,7 +61,7 @@ type CosmeticsSettingProps = {
|
||||
userId: string;
|
||||
room: Room;
|
||||
};
|
||||
export function CosmeticsAvatar({ profile, member, userId, room }: CosmeticsSettingProps) {
|
||||
function CosmeticsAvatar({ profile, member, userId, room }: CosmeticsSettingProps) {
|
||||
const mx = useMatrixClient();
|
||||
const useAuthentication = useMediaAuthentication();
|
||||
const capabilities = useCapabilities();
|
||||
@@ -184,7 +184,7 @@ export function CosmeticsAvatar({ profile, member, userId, room }: CosmeticsSett
|
||||
);
|
||||
}
|
||||
|
||||
export function CosmeticsNickname({ profile, member, userId, room }: CosmeticsSettingProps) {
|
||||
function CosmeticsNickname({ profile, member, userId, room }: CosmeticsSettingProps) {
|
||||
const mx = useMatrixClient();
|
||||
|
||||
const defaultDisplayName = member?.rawDisplayName ?? fallbackDisplayName(userId);
|
||||
@@ -270,7 +270,7 @@ export function CosmeticsNickname({ profile, member, userId, room }: CosmeticsSe
|
||||
);
|
||||
}
|
||||
|
||||
export function CosmeticsFont({
|
||||
function CosmeticsFont({
|
||||
room,
|
||||
isSpace,
|
||||
font,
|
||||
|
||||
@@ -45,7 +45,7 @@ type RoomProfileEditProps = {
|
||||
isDm: boolean;
|
||||
onClose: () => void;
|
||||
};
|
||||
export function RoomProfileEdit({
|
||||
function RoomProfileEdit({
|
||||
canEditAvatar,
|
||||
canEditName,
|
||||
canEditTopic,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { style } from '@vanilla-extract/css';
|
||||
import { color, config, toRem } from 'folds';
|
||||
import { ContainerColor } from '$styles/ContainerColor.css';
|
||||
|
||||
export const DragHandleWidth = toRem(24);
|
||||
const DragHandleWidth = toRem(24);
|
||||
const ReorderableContentInset = toRem(8);
|
||||
|
||||
export const ReorderableContent = style({
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { style } from '@vanilla-extract/css';
|
||||
import { config } from 'folds';
|
||||
import { MOBILE_BREAKPOINT } from '$hooks/useScreenSize';
|
||||
|
||||
export const Header = style({
|
||||
@@ -15,10 +14,3 @@ export const ActionsBox = style({
|
||||
},
|
||||
},
|
||||
});
|
||||
export const HeaderTopic = style({
|
||||
':hover': {
|
||||
cursor: 'pointer',
|
||||
opacity: config.opacity.P500,
|
||||
textDecoration: 'underline',
|
||||
},
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
import { style } from '@vanilla-extract/css';
|
||||
import { config, toRem } from 'folds';
|
||||
import { config } from 'folds';
|
||||
import { recipe } from '@vanilla-extract/recipes';
|
||||
|
||||
export const SpaceItemCard = recipe({
|
||||
@@ -22,11 +22,3 @@ export const HeaderChip = style({
|
||||
},
|
||||
},
|
||||
});
|
||||
export const HeaderChipPlaceholder = style([
|
||||
{
|
||||
borderRadius: config.radii.R400,
|
||||
paddingLeft: config.space.S100,
|
||||
paddingRight: config.space.S300,
|
||||
height: toRem(32),
|
||||
},
|
||||
]);
|
||||
@@ -309,7 +309,7 @@ const RoomNavItemMenu = forwardRef<HTMLDivElement, RoomNavItemMenuProps>(
|
||||
}
|
||||
);
|
||||
|
||||
export const hideTextStyling = (isHidden: boolean | undefined) =>
|
||||
const hideTextStyling = (isHidden: boolean | undefined) =>
|
||||
isHidden ? { width: '100%', height: '100%', padding: '0', paddingTop: '0px' } : {};
|
||||
|
||||
type RoomNavItemProps = {
|
||||
|
||||
@@ -11,14 +11,6 @@ const SlideOutLeft = keyframes({
|
||||
'100%': { transform: 'translateX(-100%)', opacity: 0 },
|
||||
});
|
||||
|
||||
const Shake = keyframes({
|
||||
'0%, 100%': { transform: 'translateX(0)' },
|
||||
'20%': { transform: 'translateX(-4px)' },
|
||||
'40%': { transform: 'translateX(4px)' },
|
||||
'60%': { transform: 'translateX(-4px)' },
|
||||
'80%': { transform: 'translateX(4px)' },
|
||||
});
|
||||
|
||||
export const Container = style([
|
||||
DefaultReset,
|
||||
{
|
||||
@@ -34,10 +26,6 @@ export const ContainerCanceling = style({
|
||||
animation: `${SlideOutLeft} 200ms ease-out forwards`,
|
||||
});
|
||||
|
||||
export const ContainerShake = style({
|
||||
animation: `${Shake} 300ms ease-out`,
|
||||
});
|
||||
|
||||
export const RecDot = style([
|
||||
DefaultReset,
|
||||
{
|
||||
@@ -83,28 +71,6 @@ export const Timer = style([
|
||||
},
|
||||
]);
|
||||
|
||||
export const CancelHint = style([
|
||||
DefaultReset,
|
||||
{
|
||||
position: 'absolute',
|
||||
left: config.space.S200,
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
color: color.Critical.Main,
|
||||
fontSize: toRem(12),
|
||||
fontWeight: 600,
|
||||
opacity: 0,
|
||||
transition: 'opacity 100ms ease-out',
|
||||
pointerEvents: 'none',
|
||||
},
|
||||
]);
|
||||
|
||||
export const CancelHintVisible = style({
|
||||
opacity: 1,
|
||||
});
|
||||
|
||||
export const SrOnly = style([
|
||||
DefaultReset,
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { keyframes, style } from '@vanilla-extract/css';
|
||||
import { style } from '@vanilla-extract/css';
|
||||
import { config, toRem } from 'folds';
|
||||
|
||||
export const MembersDrawer = style({
|
||||
@@ -20,24 +20,6 @@ export const MemberDrawerContent = style({
|
||||
padding: `${config.space.S200} 0`,
|
||||
});
|
||||
|
||||
const ScrollBtnAnime = keyframes({
|
||||
'0%': {
|
||||
transform: `translate(-50%, -100%) scale(0)`,
|
||||
},
|
||||
'100%': {
|
||||
transform: `translate(-50%, 0) scale(1)`,
|
||||
},
|
||||
});
|
||||
|
||||
export const DrawerScrollTop = style({
|
||||
position: 'absolute',
|
||||
top: config.space.S200,
|
||||
left: '50%',
|
||||
transform: 'translateX(-50%)',
|
||||
zIndex: 1,
|
||||
animation: `${ScrollBtnAnime} 100ms`,
|
||||
});
|
||||
|
||||
export const DrawerGroup = style({
|
||||
paddingLeft: config.space.S200,
|
||||
});
|
||||
|
||||
@@ -220,7 +220,7 @@ const LocationDialog = lazy(() =>
|
||||
|
||||
// Returns the event ID of the most recent non-reaction/non-edit event in a thread,
|
||||
// falling back to the thread root if no replies exist yet.
|
||||
export const getLatestThreadEventId = (room: Room, threadRootId: string): string => {
|
||||
const getLatestThreadEventId = (room: Room, threadRootId: string): string => {
|
||||
const replies = getThreadReplyEvents(room, threadRootId);
|
||||
return replies.at(-1)?.getId() ?? threadRootId;
|
||||
};
|
||||
|
||||
@@ -19,7 +19,7 @@ import markerIconPng from 'leaflet/dist/images/marker-icon.png';
|
||||
import { Icon } from 'leaflet';
|
||||
import { ModalOverlay } from '$components/modal-overlay/ModalOverlay';
|
||||
|
||||
export const markerIcon = new Icon({
|
||||
const markerIcon = new Icon({
|
||||
iconUrl: markerIconPng,
|
||||
iconSize: [25, 41],
|
||||
iconAnchor: [12, 41],
|
||||
|
||||
@@ -79,17 +79,6 @@ export const PreventSelect = style({
|
||||
//I have zero clue where these numbers and vars are from but they should be changed
|
||||
//I just copied the hardcoded value in a more correct place
|
||||
|
||||
export const MessageNickEditor = style({
|
||||
background: 'var(--mx-c-surface)',
|
||||
color: 'var(--mx-c-on-surface)',
|
||||
border: '1px solid var(--mx-c-outline)',
|
||||
borderRadius: '6px',
|
||||
padding: '4px 8px',
|
||||
fontSize: '14px',
|
||||
width: '100%',
|
||||
outline: 'none',
|
||||
});
|
||||
|
||||
export const MessageMobileOptionsWrapped = style({
|
||||
position: 'fixed',
|
||||
top: 0,
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import { style } from '@vanilla-extract/css';
|
||||
import { config, toRem } from 'folds';
|
||||
|
||||
export const SchedulePickerContent = style({
|
||||
padding: config.space.S400,
|
||||
minWidth: toRem(300),
|
||||
});
|
||||
|
||||
export const SplitSendButton = style({
|
||||
borderRadius: `${config.radii.R300} 0 0 ${config.radii.R300}`,
|
||||
});
|
||||
|
||||
@@ -23,10 +23,3 @@ export const ScheduledMessageRow = style({
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const MessagePreview = style({
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
whiteSpace: 'nowrap',
|
||||
maxWidth: toRem(300),
|
||||
});
|
||||
@@ -47,7 +47,7 @@ import { useSettingsLinkBaseUrl } from './useSettingsLinkBaseUrl';
|
||||
import { Desktop } from './desktop';
|
||||
import { isDesktopTauri } from '$utils/platform';
|
||||
|
||||
export enum SettingsPages {
|
||||
enum SettingsPages {
|
||||
GeneralPage,
|
||||
AccountPage,
|
||||
PerMessageProfilesPage,
|
||||
@@ -71,7 +71,7 @@ export type SettingsMenuItem = {
|
||||
activeIcon?: PhosphorIcon;
|
||||
};
|
||||
|
||||
export const settingsMenuIcons: Record<
|
||||
const settingsMenuIcons: Record<
|
||||
SettingsSectionId,
|
||||
Pick<SettingsMenuItem, 'icon' | 'activeIcon'>
|
||||
> = {
|
||||
|
||||
@@ -25,7 +25,7 @@ type VersionResult =
|
||||
| { server: { name?: string; version?: string; compiler?: string } }
|
||||
| undefined;
|
||||
|
||||
export function HomeserverInfo() {
|
||||
function HomeserverInfo() {
|
||||
const mx = useMatrixClient();
|
||||
const [federationUrl, setFederationUrl] = useState<string>(mx.baseUrl);
|
||||
const [version, setVersion] = useState<VersionResult>(undefined);
|
||||
|
||||
@@ -9,7 +9,7 @@ export type LanguageSpecificPronounsConfig = {
|
||||
languages?: string[];
|
||||
};
|
||||
|
||||
export const resolveLanguageSpecificPronounsEnabled = (
|
||||
const resolveLanguageSpecificPronounsEnabled = (
|
||||
enabled: LanguageSpecificPronounsConfig['enabled']
|
||||
): boolean => {
|
||||
if (enabled === undefined) return false;
|
||||
|
||||
@@ -10,7 +10,7 @@ type ThemeCatalogOnboardingProps = {
|
||||
onDecline: () => void;
|
||||
};
|
||||
|
||||
export function ThemeCatalogOnboarding({ open, onEnable, onDecline }: ThemeCatalogOnboardingProps) {
|
||||
function ThemeCatalogOnboarding({ open, onEnable, onDecline }: ThemeCatalogOnboardingProps) {
|
||||
const suppressDeactivateDecline = useRef(false);
|
||||
|
||||
const handleEnableClick = useCallback(() => {
|
||||
|
||||
@@ -101,8 +101,6 @@ export type LocalTweakRow = ThemeRemoteTweakFavorite & {
|
||||
|
||||
export type ThemeCatalogSettingsMode = 'local' | 'appearance';
|
||||
|
||||
export { usePatchSettings } from './themeSettingsPatch';
|
||||
|
||||
type ThemeCatalogSettingsProps = {
|
||||
mode: ThemeCatalogSettingsMode;
|
||||
onBrowseOpenChange?: (open: boolean) => void;
|
||||
|
||||
@@ -15,7 +15,7 @@ export type CustomToneMetadata = {
|
||||
durationMs: number;
|
||||
};
|
||||
|
||||
export function CustomToneMeta({
|
||||
function CustomToneMeta({
|
||||
metadata,
|
||||
emptyLabel,
|
||||
}: {
|
||||
|
||||
@@ -113,7 +113,7 @@ export async function ensureNativePushRegistered(
|
||||
};
|
||||
}
|
||||
|
||||
export async function ensureNativePushUnregistered(): Promise<void> {
|
||||
async function ensureNativePushUnregistered(): Promise<void> {
|
||||
const api = await getNativePushNotificationsApi();
|
||||
await api.unregisterForPushNotifications();
|
||||
}
|
||||
|
||||
@@ -44,14 +44,7 @@ export type {
|
||||
NativePushRegistrationResult,
|
||||
} from './NativePushNotifications';
|
||||
|
||||
export {
|
||||
disableNativePush,
|
||||
enableNativePush,
|
||||
ensureNativePushRegistered,
|
||||
ensureNativePushUnregistered,
|
||||
isNativePushPermissionGranted,
|
||||
requestNativePushPermission,
|
||||
} from './NativePushNotifications';
|
||||
export { disableNativePush, enableNativePush } from './NativePushNotifications';
|
||||
|
||||
export function getSupportedNotificationTransportModes(
|
||||
platform: NotificationTransportPlatform
|
||||
|
||||
@@ -76,10 +76,7 @@ function getBackgroundPushPlatform(isTauriRuntime: boolean): BackgroundPushPlatf
|
||||
return 'desktop';
|
||||
}
|
||||
|
||||
export function deriveLegacyPushSync(input: {
|
||||
enabled: boolean;
|
||||
provider: BackgroundPushKind | null;
|
||||
}): {
|
||||
function deriveLegacyPushSync(input: { enabled: boolean; provider: BackgroundPushKind | null }): {
|
||||
usePushNotifications: boolean;
|
||||
useUnifiedPush: boolean;
|
||||
} {
|
||||
|
||||
@@ -65,7 +65,7 @@ const transitionActionListener = (invokeFn: typeof invoke, active: boolean): Pro
|
||||
return actionListenerTransition;
|
||||
};
|
||||
|
||||
export async function subscribeToNativeNotificationActions(
|
||||
async function subscribeToNativeNotificationActions(
|
||||
listener: (event: NotificationActionEvent) => void,
|
||||
dependencies: ActionListenerDependencies = { addListener: addPluginListener, invoke }
|
||||
): Promise<NotificationPluginListener> {
|
||||
@@ -115,7 +115,7 @@ export async function getTauriNotificationsApi(): Promise<TauriNotificationsApi>
|
||||
|
||||
let permissionPromise: Promise<boolean> | null = null;
|
||||
|
||||
export async function ensureTauriNotificationPermission(): Promise<boolean> {
|
||||
async function ensureTauriNotificationPermission(): Promise<boolean> {
|
||||
if (!permissionPromise) {
|
||||
permissionPromise = (async () => {
|
||||
const api = await getTauriNotificationsApi();
|
||||
|
||||
@@ -13,10 +13,7 @@ import { getMxIdLocalPart } from '$utils/matrix';
|
||||
import { getStateEvent, getMemberAvatarMxc } from '$utils/room';
|
||||
import { createDebugLogger } from '$utils/debugLogger';
|
||||
import {
|
||||
getUnifiedPushDistributor,
|
||||
getUnifiedPushDistributors,
|
||||
registerUnifiedPushTransport,
|
||||
saveUnifiedPushDistributor,
|
||||
type UnifiedPushRegistrationResult,
|
||||
unregisterUnifiedPushTransport,
|
||||
} from './UnifiedPushTransport';
|
||||
@@ -37,8 +34,6 @@ import {
|
||||
type PushPusherSettings,
|
||||
} from './PushPusherConfig';
|
||||
|
||||
export { getUnifiedPushDistributors, getUnifiedPushDistributor, saveUnifiedPushDistributor };
|
||||
|
||||
const UP_PUBLIC_GATEWAY = 'https://matrix.gateway.unifiedpush.org/_matrix/push/v1/notify';
|
||||
export const DEFAULT_UNIFIED_PUSH_APP_ID = 'moe.sable.up';
|
||||
const unifiedPushLog = createDebugLogger('unifiedpush');
|
||||
|
||||
@@ -115,17 +115,17 @@ export async function isUnifiedPushPermissionGranted(): Promise<boolean | null>
|
||||
return api.isPermissionGranted();
|
||||
}
|
||||
|
||||
export async function getUnifiedPushDistributors(): Promise<string[]> {
|
||||
async function getUnifiedPushDistributors(): Promise<string[]> {
|
||||
const api = await getUnifiedPushTransportApi();
|
||||
return api.listDistributors();
|
||||
}
|
||||
|
||||
export async function getUnifiedPushDistributor(): Promise<{ distributor: string }> {
|
||||
async function getUnifiedPushDistributor(): Promise<{ distributor: string }> {
|
||||
const distributor = localStorage.getItem(DISTRIBUTUTOR_STORAGE_KEY) ?? '';
|
||||
return { distributor };
|
||||
}
|
||||
|
||||
export async function saveUnifiedPushDistributor(distributor: string): Promise<void> {
|
||||
async function saveUnifiedPushDistributor(distributor: string): Promise<void> {
|
||||
localStorage.setItem(DISTRIBUTUTOR_STORAGE_KEY, distributor);
|
||||
const api = await getUnifiedPushTransportApi();
|
||||
await api.setDistributor(distributor);
|
||||
|
||||
@@ -22,7 +22,7 @@ const getAllTextNodes = (root: Node): Node[] =>
|
||||
[]
|
||||
);
|
||||
|
||||
export const rainbowify = (htmlInput: string): string => {
|
||||
const rainbowify = (htmlInput: string): string => {
|
||||
const div = document.createElement('div');
|
||||
div.innerHTML = htmlInput;
|
||||
const textNodes = getAllTextNodes(div);
|
||||
|
||||
@@ -1,40 +1,6 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
export type MediaPlaybackRateData = {
|
||||
playbackRate: number;
|
||||
};
|
||||
export type MediaPlaybackRateControl = {
|
||||
setPlaybackRate: (rate: number) => void;
|
||||
};
|
||||
|
||||
export const useMediaPlaybackRate = (
|
||||
getTargetElement: () => HTMLMediaElement | null
|
||||
): MediaPlaybackRateData & MediaPlaybackRateControl => {
|
||||
const [rate, setRate] = useState(1.0);
|
||||
|
||||
const setPlaybackRate = useCallback(
|
||||
(playbackRate: number) => {
|
||||
const targetEl = getTargetElement();
|
||||
if (!targetEl) return;
|
||||
targetEl.playbackRate = playbackRate;
|
||||
},
|
||||
[getTargetElement]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const targetEl = getTargetElement();
|
||||
const handleChange = () => {
|
||||
if (!targetEl) return;
|
||||
setRate(targetEl.playbackRate);
|
||||
};
|
||||
targetEl?.addEventListener('ratechange', handleChange);
|
||||
return () => {
|
||||
targetEl?.removeEventListener('ratechange', handleChange);
|
||||
};
|
||||
}, [getTargetElement]);
|
||||
|
||||
return {
|
||||
playbackRate: rate,
|
||||
setPlaybackRate,
|
||||
};
|
||||
};
|
||||
@@ -51,12 +51,6 @@ export const useResolvedRoomIdOrAlias = (roomIdOrAlias?: string): ResolvedRoomId
|
||||
return { resolving: true };
|
||||
};
|
||||
|
||||
export const useResolvedSelectedRoom = (): ResolvedRoomId => {
|
||||
const { roomIdOrAlias: encodedRoomIdOrAlias } = useParams();
|
||||
const roomIdOrAlias = encodedRoomIdOrAlias && decodeURIComponent(encodedRoomIdOrAlias);
|
||||
return useResolvedRoomIdOrAlias(roomIdOrAlias);
|
||||
};
|
||||
|
||||
export const useResolvedSelectedSpace = (): ResolvedRoomId => {
|
||||
const { spaceIdOrAlias: encodedSpaceIdOrAlias } = useParams();
|
||||
const spaceIdOrAlias = encodedSpaceIdOrAlias && decodeURIComponent(encodedSpaceIdOrAlias);
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
getDirectPath,
|
||||
getExploreFeaturedPath,
|
||||
getExplorePath,
|
||||
getHomeJoinPath,
|
||||
getHomePath,
|
||||
getHomeSearchPath,
|
||||
getInboxBookmarksPath,
|
||||
@@ -32,7 +31,6 @@ export const useExploreServer = (): string | undefined => useParams().server;
|
||||
|
||||
export const useHomeSelected = (): boolean => useRouteSelected(getHomePath());
|
||||
export const useHomeCreateSelected = (): boolean => useRouteSelected(CREATE_ROOM_PATH);
|
||||
export const useHomeJoinSelected = (): boolean => useRouteSelected(getHomeJoinPath());
|
||||
export const useHomeSearchSelected = (): boolean => useRouteSelected(getHomeSearchPath());
|
||||
|
||||
export const useInboxSelected = (): boolean => useRouteSelected(getInboxPath());
|
||||
|
||||
@@ -27,7 +27,7 @@ import {
|
||||
PAGINATION_LIMIT,
|
||||
} from '$utils/timeline';
|
||||
|
||||
export const EVENT_TIMELINE_LOAD_TIMEOUT_MS = 12000;
|
||||
const EVENT_TIMELINE_LOAD_TIMEOUT_MS = 12000;
|
||||
|
||||
export type PaginationStatus = 'idle' | 'loading' | 'error';
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ const performMatch = (
|
||||
return matches ? normalizedTargetStr : undefined;
|
||||
};
|
||||
|
||||
export const orderSearchItems = <TSearchItem extends object | string | number>(
|
||||
const orderSearchItems = <TSearchItem extends object | string | number>(
|
||||
query: string,
|
||||
items: TSearchItem[],
|
||||
getItemStr: SearchItemStrGetter<TSearchItem>,
|
||||
|
||||
@@ -24,10 +24,6 @@ export function useBookmarkLoading(): boolean {
|
||||
return useAtomValue(bookmarkLoadingAtom);
|
||||
}
|
||||
|
||||
export function useBookmarkRefreshError(): Error | undefined {
|
||||
return useAtomValue(bookmarkRefreshErrorAtom);
|
||||
}
|
||||
|
||||
export function useIsBookmarked(roomId: string, eventId: string): boolean {
|
||||
const idSet = useAtomValue(bookmarkIdSetAtom);
|
||||
return idSet.has(computeBookmarkId(roomId, eventId));
|
||||
|
||||
@@ -30,7 +30,7 @@ export const useCallEmbed = (): CallEmbed | undefined => {
|
||||
|
||||
const CallEmbedRefContext = createContext<RefObject<HTMLDivElement> | undefined>(undefined);
|
||||
export const CallEmbedRefContextProvider = CallEmbedRefContext.Provider;
|
||||
export const useCallEmbedRef = (): RefObject<HTMLDivElement> => {
|
||||
const useCallEmbedRef = (): RefObject<HTMLDivElement> => {
|
||||
const ref = useContext(CallEmbedRefContext);
|
||||
if (!ref) {
|
||||
throw new Error('CallEmbedRef is not provided!');
|
||||
@@ -38,7 +38,7 @@ export const useCallEmbedRef = (): RefObject<HTMLDivElement> => {
|
||||
return ref;
|
||||
};
|
||||
|
||||
export const createCallEmbed = (
|
||||
const createCallEmbed = (
|
||||
mx: MatrixClient,
|
||||
room: Room,
|
||||
dm: boolean,
|
||||
|
||||
@@ -22,14 +22,6 @@ import { createMiscCommands } from './commands/misc';
|
||||
export type { CommandExe, CommandContent, CommandRecord } from './commands/types';
|
||||
export { Command } from './commands/types';
|
||||
export { SHRUG, TABLEFLIP, UNFLIP } from './commands/fun';
|
||||
export { rainbowify } from './commands/rainbow';
|
||||
export {
|
||||
parseFlags,
|
||||
parseServers,
|
||||
parseTimestampFlag,
|
||||
parseUsers,
|
||||
splitPayloadContentAndFlags,
|
||||
} from './commands/parsing';
|
||||
|
||||
export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
|
||||
const { navigateRoom } = useRoomNavigate();
|
||||
|
||||
@@ -1,16 +1,7 @@
|
||||
import type { DragEventHandler, RefObject } from 'react';
|
||||
import { useCallback, useState, useEffect, useRef } from 'react';
|
||||
import type { RefObject } from 'react';
|
||||
import { useState, useEffect, useRef } from 'react';
|
||||
import { getDataTransferFiles } from '$utils/dom';
|
||||
|
||||
export const useFileDropHandler = (onDrop: (file: File[]) => void): DragEventHandler =>
|
||||
useCallback(
|
||||
(evt) => {
|
||||
const files = getDataTransferFiles(evt.dataTransfer);
|
||||
if (files) onDrop(files);
|
||||
},
|
||||
[onDrop]
|
||||
);
|
||||
|
||||
export const useFileDropZone = (
|
||||
zoneRef: RefObject<HTMLElement>,
|
||||
onDrop: (file: File[]) => void
|
||||
|
||||
@@ -10,9 +10,7 @@ import * as Sentry from '@sentry/react';
|
||||
import { useMatrixClient } from './useMatrixClient';
|
||||
import { useAlive } from './useAlive';
|
||||
|
||||
export const useKeyBackupStatusChange = (
|
||||
onChange: CryptoEventHandlerMap[CryptoEvent.KeyBackupStatus]
|
||||
) => {
|
||||
const useKeyBackupStatusChange = (onChange: CryptoEventHandlerMap[CryptoEvent.KeyBackupStatus]) => {
|
||||
const mx = useMatrixClient();
|
||||
|
||||
useEffect(() => {
|
||||
@@ -40,7 +38,7 @@ export const useKeyBackupStatus = (crypto: CryptoApi): boolean => {
|
||||
return status;
|
||||
};
|
||||
|
||||
export const useKeyBackupSessionsRemainingChange = (
|
||||
const useKeyBackupSessionsRemainingChange = (
|
||||
onChange: CryptoEventHandlerMap[CryptoEvent.KeyBackupSessionsRemaining]
|
||||
) => {
|
||||
const mx = useMatrixClient();
|
||||
@@ -53,9 +51,7 @@ export const useKeyBackupSessionsRemainingChange = (
|
||||
}, [mx, onChange]);
|
||||
};
|
||||
|
||||
export const useKeyBackupFailedChange = (
|
||||
onChange: CryptoEventHandlerMap[CryptoEvent.KeyBackupFailed]
|
||||
) => {
|
||||
const useKeyBackupFailedChange = (onChange: CryptoEventHandlerMap[CryptoEvent.KeyBackupFailed]) => {
|
||||
const mx = useMatrixClient();
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useMemo } from 'react';
|
||||
import type { RoomMember } from '$types/matrix-sdk';
|
||||
import { KnownMembership } from '$types/matrix-sdk';
|
||||
|
||||
export const MembershipFilter = {
|
||||
const MembershipFilter = {
|
||||
filterJoined: (m: RoomMember) => m.membership === KnownMembership.Join,
|
||||
filterInvited: (m: RoomMember) => m.membership === KnownMembership.Invite,
|
||||
filterLeaved: (m: RoomMember) =>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { RoomMember } from '$types/matrix-sdk';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
|
||||
export const MemberSort = {
|
||||
const MemberSort = {
|
||||
Ascending: (a: RoomMember, b: RoomMember) =>
|
||||
a.name.toLowerCase() < b.name.toLowerCase() ? -1 : 1,
|
||||
Descending: (a: RoomMember, b: RoomMember) =>
|
||||
|
||||
@@ -2,11 +2,6 @@ import { useEffect, useMemo } from 'react';
|
||||
|
||||
export type OnMutationCallback = (mutations: MutationRecord[]) => void;
|
||||
|
||||
export const getMutationRecord = (
|
||||
target: Node,
|
||||
mutations: MutationRecord[]
|
||||
): MutationRecord | undefined => mutations.find((mutation) => mutation.target === target);
|
||||
|
||||
export const useMutationObserver = (
|
||||
onMutationCallback: OnMutationCallback,
|
||||
observeElement?: Node | null | (() => Node | null),
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useMemo } from 'react';
|
||||
import type { ILoginFlow, IPasswordFlow, ISSOFlow, LoginFlow } from '$types/matrix-sdk';
|
||||
import { OAUTH_AWARE_PREFERRED_FLOW_FIELD } from '$types/matrix-sdk';
|
||||
|
||||
export const getSSOFlow = (loginFlows: LoginFlow[]): ISSOFlow | undefined =>
|
||||
const getSSOFlow = (loginFlows: LoginFlow[]): ISSOFlow | undefined =>
|
||||
loginFlows.find((flow) => flow.type === 'm.login.sso' || flow.type === 'm.login.cas') as
|
||||
| ISSOFlow
|
||||
| undefined;
|
||||
@@ -13,9 +13,9 @@ export const isOauthAwarePreferred = (ssoFlow: ISSOFlow | undefined): boolean =>
|
||||
ssoFlow?.[OAUTH_AWARE_PREFERRED_FLOW_FIELD.altName]
|
||||
);
|
||||
|
||||
export const getPasswordFlow = (loginFlows: LoginFlow[]): IPasswordFlow | undefined =>
|
||||
const getPasswordFlow = (loginFlows: LoginFlow[]): IPasswordFlow | undefined =>
|
||||
loginFlows.find((flow) => flow.type === 'm.login.password') as IPasswordFlow;
|
||||
export const getTokenFlow = (loginFlows: LoginFlow[]): LoginFlow | undefined =>
|
||||
const getTokenFlow = (loginFlows: LoginFlow[]): LoginFlow | undefined =>
|
||||
loginFlows.find((flow) => flow.type === 'm.login.token') as ILoginFlow & {
|
||||
type: 'm.login.token';
|
||||
};
|
||||
|
||||
@@ -465,27 +465,6 @@ export async function associateProxyWithProfile(
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* get a profile based on a proxy
|
||||
* @param mx the matrix client
|
||||
* @param proxy the proxy to look for
|
||||
* @returns the profile, if any, associated with the prefix
|
||||
*/
|
||||
export async function getProfileAssociatedWithProxy(
|
||||
mx: MatrixClient,
|
||||
proxy: string
|
||||
): Promise<PerMessageProfile | undefined> {
|
||||
const profileId = getProxyAssociationMap(
|
||||
mx
|
||||
.getAccountData(
|
||||
`${ACCOUNT_DATA_PREFIX}.proxyassociation` as Parameters<typeof mx.getAccountData>[0]
|
||||
)
|
||||
?.getContent()
|
||||
).get(proxy)?.profileId;
|
||||
if (!profileId) return undefined;
|
||||
return getPerMessageProfileById(mx, profileId);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
@@ -584,13 +563,6 @@ export async function renamePerMessageProfile(mx: MatrixClient, oldId: string, n
|
||||
await deletePerMessageProfile(mx, oldId);
|
||||
}
|
||||
|
||||
export async function getListOfRoomsUsingProfile(
|
||||
mx: MatrixClient,
|
||||
profileId: string
|
||||
): Promise<string[]> {
|
||||
return getRoomsUsingProfile(mx, profileId);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the per message profile to be used for messages in a room
|
||||
* @param mx matrix client
|
||||
|
||||
@@ -75,7 +75,7 @@ export function usePowerLevels(room: Room): IPowerLevels {
|
||||
return powerLevels;
|
||||
}
|
||||
|
||||
export const PowerLevelsContext = createContext<IPowerLevels | null>(null);
|
||||
const PowerLevelsContext = createContext<IPowerLevels | null>(null);
|
||||
|
||||
export const PowerLevelsContextProvider = PowerLevelsContext.Provider;
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ export const makePushRuleData = (
|
||||
},
|
||||
});
|
||||
|
||||
export const orderedPushRuleKinds: PushRuleKind[] = [
|
||||
const orderedPushRuleKinds: PushRuleKind[] = [
|
||||
PushRuleKind.Override,
|
||||
PushRuleKind.ContentSpecific,
|
||||
PushRuleKind.RoomSpecific,
|
||||
@@ -41,10 +41,7 @@ export const orderedPushRuleKinds: PushRuleKind[] = [
|
||||
PushRuleKind.Underride,
|
||||
];
|
||||
|
||||
export const getPushRule = (
|
||||
pushRules: IPushRules,
|
||||
ruleId: RuleId | string
|
||||
): PushRuleData | undefined => {
|
||||
const getPushRule = (pushRules: IPushRules, ruleId: RuleId | string): PushRuleData | undefined => {
|
||||
const { global } = pushRules;
|
||||
|
||||
let ruleData: PushRuleData | undefined;
|
||||
|
||||
@@ -6,7 +6,7 @@ import { creatorsSupported } from '$utils/roomSupport';
|
||||
import { useStateEvent } from './useStateEvent';
|
||||
import { EventType } from '$types/matrix-sdk';
|
||||
|
||||
export const getRoomCreators = (createEvent: MatrixEvent): Set<string> => {
|
||||
const getRoomCreators = (createEvent: MatrixEvent): Set<string> => {
|
||||
const createContent = createEvent.getContent<IRoomCreateContent>();
|
||||
|
||||
const creators: Set<string> = new Set();
|
||||
|
||||
@@ -7,7 +7,7 @@ import { mDirectAtom } from '$state/mDirectList';
|
||||
import { useStateEvent } from './useStateEvent';
|
||||
import { useNickname } from './useNickname';
|
||||
|
||||
export const getRoomDisplayName = (
|
||||
const getRoomDisplayName = (
|
||||
roomName: string,
|
||||
stateName: unknown,
|
||||
isDmTagged: boolean,
|
||||
|
||||
@@ -95,13 +95,6 @@ export const getRoomNotificationMode = (
|
||||
|
||||
return RoomNotificationMode.Unset;
|
||||
};
|
||||
|
||||
export const useRoomNotificationPreference = (
|
||||
preferences: RoomsNotificationPreferences,
|
||||
roomId: string
|
||||
): RoomNotificationMode =>
|
||||
useMemo(() => getRoomNotificationMode(preferences, roomId), [preferences, roomId]);
|
||||
|
||||
export const roomNotificationModeIcon = (
|
||||
mode?: RoomNotificationMode,
|
||||
props?: IconProps
|
||||
@@ -121,7 +114,7 @@ export const roomNotificationModeChipIcon = (mode?: RoomNotificationMode): React
|
||||
return chipIcon(Bell);
|
||||
};
|
||||
|
||||
export const setRoomNotificationPreference = async (
|
||||
const setRoomNotificationPreference = async (
|
||||
mx: MatrixClient,
|
||||
roomId: string,
|
||||
mode: RoomNotificationMode,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createContext, useCallback, useContext, useState } from 'react';
|
||||
import { useElementSizeObserver } from './useElementSizeObserver';
|
||||
|
||||
export const TABLET_BREAKPOINT = 1124;
|
||||
const TABLET_BREAKPOINT = 1124;
|
||||
export const MOBILE_BREAKPOINT = 750;
|
||||
|
||||
export enum ScreenSize {
|
||||
@@ -10,7 +10,7 @@ export enum ScreenSize {
|
||||
Mobile = 'Mobile',
|
||||
}
|
||||
|
||||
export const getScreenSize = (width: number): ScreenSize => {
|
||||
const getScreenSize = (width: number): ScreenSize => {
|
||||
if (width > TABLET_BREAKPOINT) return ScreenSize.Desktop;
|
||||
if (width > MOBILE_BREAKPOINT) return ScreenSize.Tablet;
|
||||
return ScreenSize.Mobile;
|
||||
|
||||
@@ -5,7 +5,7 @@ import type {
|
||||
|
||||
import { useAccountData } from './useAccountData';
|
||||
|
||||
export const getSecretStorageKeyEventType = (key: string): string => `m.secret_storage.key.${key}`;
|
||||
const getSecretStorageKeyEventType = (key: string): string => `m.secret_storage.key.${key}`;
|
||||
|
||||
export const useSecretStorageDefaultKeyId = (): string | undefined => {
|
||||
const defaultKeyEvent = useAccountData('m.secret_storage.default_key');
|
||||
|
||||
@@ -30,7 +30,7 @@ const decodeRoomRef = (value: string | undefined): string | undefined => {
|
||||
return isRoomId(decoded) || isRoomAlias(decoded) ? decoded : undefined;
|
||||
};
|
||||
|
||||
export const getRouteRoomRefs = (pathname: string): RouteRoomRefs => {
|
||||
const getRouteRoomRefs = (pathname: string): RouteRoomRefs => {
|
||||
const homeRoomMatch = matchPath(HOME_ROOM_PATH, pathname);
|
||||
const directRoomMatch = matchPath(DIRECT_ROOM_PATH, pathname);
|
||||
const nonSpaceRoomMatch = homeRoomMatch ?? directRoomMatch;
|
||||
@@ -76,7 +76,7 @@ const useAvailableSlidingSyncManager = () => {
|
||||
return manager;
|
||||
};
|
||||
|
||||
export const useSlidingSyncRouteRooms = (): void => {
|
||||
const useSlidingSyncRouteRooms = (): void => {
|
||||
const manager = useAvailableSlidingSyncManager();
|
||||
const { pathname } = useLocation();
|
||||
const { roomIdOrAlias, spaceIdOrAlias } = getRouteRoomRefs(pathname);
|
||||
@@ -98,7 +98,7 @@ export const useSlidingSyncRouteRooms = (): void => {
|
||||
}, [manager]);
|
||||
};
|
||||
|
||||
export const useSlidingSyncSpaceSubscriptions = (): void => {
|
||||
const useSlidingSyncSpaceSubscriptions = (): void => {
|
||||
const manager = useAvailableSlidingSyncManager();
|
||||
const mx = useMatrixClient();
|
||||
const spaces = useSpaces(mx, allRoomsAtom);
|
||||
@@ -112,7 +112,7 @@ export const useSlidingSyncSpaceSubscriptions = (): void => {
|
||||
|
||||
// Subscribe pack rooms before the emoji board first opens so their
|
||||
// pack state is already available.
|
||||
export const useSlidingSyncImagePackSubscriptions = (): void => {
|
||||
const useSlidingSyncImagePackSubscriptions = (): void => {
|
||||
const manager = useAvailableSlidingSyncManager();
|
||||
const mx = useMatrixClient();
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { IAuthData, MatrixError, UIAFlow } from '$types/matrix-sdk';
|
||||
import { AuthType } from '$types/matrix-sdk';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import {
|
||||
getSupportedUIAFlows,
|
||||
@@ -10,16 +9,6 @@ import {
|
||||
getUIASession,
|
||||
} from '$utils/matrix-uia';
|
||||
|
||||
export const SUPPORTED_FLOW_TYPES = [
|
||||
AuthType.Dummy,
|
||||
AuthType.Password,
|
||||
AuthType.Email,
|
||||
AuthType.Terms,
|
||||
AuthType.Recaptcha,
|
||||
AuthType.RegistrationToken,
|
||||
AuthType.OAuth,
|
||||
] as const;
|
||||
|
||||
export const useSupportedUIAFlows = (uiaFlows: UIAFlow[], supportedStages: string[]): UIAFlow[] =>
|
||||
useMemo(() => getSupportedUIAFlows(uiaFlows, supportedStages), [uiaFlows, supportedStages]);
|
||||
|
||||
@@ -29,14 +18,12 @@ export const useUIACompleted = (authData: IAuthData): string[] =>
|
||||
export const useUIAParams = (authData: IAuthData) =>
|
||||
useMemo(() => getUIAParams(authData), [authData]);
|
||||
|
||||
export const useUIASession = (authData: IAuthData) =>
|
||||
useMemo(() => getUIASession(authData), [authData]);
|
||||
const useUIASession = (authData: IAuthData) => useMemo(() => getUIASession(authData), [authData]);
|
||||
|
||||
export const useUIAErrorCode = (authData: IAuthData) =>
|
||||
const useUIAErrorCode = (authData: IAuthData) =>
|
||||
useMemo(() => getUIAErrorCode(authData), [authData]);
|
||||
|
||||
export const useUIAError = (authData: IAuthData) =>
|
||||
useMemo(() => getUIAError(authData), [authData]);
|
||||
const useUIAError = (authData: IAuthData) => useMemo(() => getUIAError(authData), [authData]);
|
||||
|
||||
export type StageInfo = Record<string, unknown>;
|
||||
export type AuthStageData = {
|
||||
|
||||
@@ -23,7 +23,7 @@ export const useVerificationRequestReceived = (
|
||||
}, [mx, onRequest]);
|
||||
};
|
||||
|
||||
export const useVerificationRequestChange = (
|
||||
const useVerificationRequestChange = (
|
||||
request: VerificationRequest,
|
||||
onChange: VerificationRequestEventHandlerMap[VerificationRequestEvent.Change]
|
||||
) => {
|
||||
@@ -71,15 +71,3 @@ export const useVerifierShowSas = (
|
||||
};
|
||||
}, [verifier, onCallback]);
|
||||
};
|
||||
|
||||
export const useVerifierShowReciprocateQr = (
|
||||
verifier: Verifier,
|
||||
onCallback: VerifierEventHandlerMap[VerifierEvent.ShowReciprocateQr]
|
||||
) => {
|
||||
useEffect(() => {
|
||||
verifier.on(VerifierEvent.ShowReciprocateQr, onCallback);
|
||||
return () => {
|
||||
verifier.removeListener(VerifierEvent.ShowReciprocateQr, onCallback);
|
||||
};
|
||||
}, [verifier, onCallback]);
|
||||
};
|
||||
@@ -225,8 +225,8 @@ export const SHORTCUTS: readonly ShortcutDefinition[] = [
|
||||
},
|
||||
] as const;
|
||||
|
||||
export const SHORTCUT_IDS = new Set<ShortcutId>(SHORTCUTS.map(({ id }) => id));
|
||||
export const SHORTCUT_BY_ID = new Map(SHORTCUTS.map((shortcut) => [shortcut.id, shortcut]));
|
||||
const SHORTCUT_IDS = new Set<ShortcutId>(SHORTCUTS.map(({ id }) => id));
|
||||
const SHORTCUT_BY_ID = new Map(SHORTCUTS.map((shortcut) => [shortcut.id, shortcut]));
|
||||
|
||||
export const getShortcutBinding = (id: ShortcutId, overrides: ShortcutOverrides): string | null => {
|
||||
const override = overrides[id];
|
||||
|
||||
@@ -23,7 +23,7 @@ import { autoDiscovery, specVersions } from '../../../cs-api';
|
||||
const log = createLogger('loginUtil');
|
||||
const debugLog = createDebugLogger('loginUtil');
|
||||
|
||||
export enum GetBaseUrlError {
|
||||
enum GetBaseUrlError {
|
||||
NotAllow = 'NotAllow',
|
||||
NotFound = 'NotFound',
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ export const persistOauthContext = (state: string, ctx: OauthLoginContext): void
|
||||
sessionStorage.setItem(oauthContextKey(state), JSON.stringify(ctx));
|
||||
};
|
||||
|
||||
export const consumeOauthContext = (state: string): OauthLoginContext | undefined => {
|
||||
const consumeOauthContext = (state: string): OauthLoginContext | undefined => {
|
||||
const key = oauthContextKey(state);
|
||||
const raw = sessionStorage.getItem(key);
|
||||
if (!raw) return undefined;
|
||||
@@ -137,7 +137,7 @@ export const expiresInMsFromToken = (token: BearerTokenResponse): number | undef
|
||||
return undefined;
|
||||
};
|
||||
|
||||
export const requireRefreshToken = (token: BearerTokenResponse): string => {
|
||||
const requireRefreshToken = (token: BearerTokenResponse): string => {
|
||||
if (!token.refresh_token) {
|
||||
throw new OidcLoginFailure(OidcLoginError.MissingRefreshToken);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ type AddServerProps = {
|
||||
onAddServer: (server: string) => Promise<boolean>;
|
||||
};
|
||||
|
||||
export function AddServer({ hideText, onAddServer }: AddServerProps) {
|
||||
function AddServer({ hideText, onAddServer }: AddServerProps) {
|
||||
const mx = useMatrixClient();
|
||||
const navigate = useNavigate();
|
||||
const [dialog, setDialog] = useState(false);
|
||||
|
||||
@@ -106,7 +106,7 @@ export type InviteData = {
|
||||
isEncrypted: boolean;
|
||||
};
|
||||
|
||||
export const makeInviteData = (
|
||||
const makeInviteData = (
|
||||
mx: MatrixClient,
|
||||
room: Room,
|
||||
useAuthentication: boolean,
|
||||
@@ -394,7 +394,7 @@ function InviteCard({
|
||||
);
|
||||
}
|
||||
|
||||
export enum InviteFilter {
|
||||
enum InviteFilter {
|
||||
Known,
|
||||
Unknown,
|
||||
Spam,
|
||||
|
||||
Loaded 100 of 151 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user