Apply the auto-fixable lint rules and the formatter, and drop the Vite build artifacts.
This commit is contained in:
@@ -12,8 +12,8 @@ import {
|
||||
OverlayCenter,
|
||||
Text,
|
||||
} from 'folds';
|
||||
import { Icon, Icons, IconSrc } from '../../components/icons';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { Icon, Icons, IconSrc } from '../../components/icons';
|
||||
import { General } from './general';
|
||||
import { PageNav, PageNavContent, PageNavHeader, PageRoot } from '../../components/page';
|
||||
import { ScreenSize, useScreenSizeContext } from '../../hooks/useScreenSize';
|
||||
@@ -39,10 +39,7 @@ import { SETTINGS_SEARCH_CATALOG } from './settingsSearchCatalog';
|
||||
import { SettingsPages } from './SettingsPages';
|
||||
import { SettingsSearchResult } from './styles.css';
|
||||
import { BreakWord } from '../../styles/Text.css';
|
||||
import {
|
||||
SettingsFocusProvider,
|
||||
settingAnchorId,
|
||||
} from '../../components/setting-tile';
|
||||
import { SettingsFocusProvider, settingAnchorId } from '../../components/setting-tile';
|
||||
|
||||
export { SettingsPages };
|
||||
|
||||
@@ -101,7 +98,7 @@ const useSettingsMenuItems = (): SettingsMenuItem[] =>
|
||||
icon: Icons.Info,
|
||||
},
|
||||
],
|
||||
[]
|
||||
[],
|
||||
);
|
||||
|
||||
type SettingsProps = {
|
||||
@@ -115,7 +112,7 @@ export function Settings({ initialPage, requestClose }: SettingsProps) {
|
||||
const profile = useUserProfile(userId);
|
||||
const displayName = profile.displayName ?? getMxIdLocalPart(userId) ?? userId;
|
||||
const avatarUrl = profile.avatarUrl
|
||||
? mxcUrlToHttp(mx, profile.avatarUrl, useAuthentication, 96, 96, 'crop') ?? undefined
|
||||
? (mxcUrlToHttp(mx, profile.avatarUrl, useAuthentication, 96, 96, 'crop') ?? undefined)
|
||||
: undefined;
|
||||
|
||||
const screenSize = useScreenSizeContext();
|
||||
@@ -152,7 +149,7 @@ export function Settings({ initialPage, requestClose }: SettingsProps) {
|
||||
anchorId: focusAnchorId,
|
||||
setAnchorId: setFocusAnchorId,
|
||||
}),
|
||||
[focusAnchorId]
|
||||
[focusAnchorId],
|
||||
);
|
||||
|
||||
const handlePageRequestClose = () => {
|
||||
@@ -175,7 +172,7 @@ export function Settings({ initialPage, requestClose }: SettingsProps) {
|
||||
setActivePage(page);
|
||||
setSearchQuery('');
|
||||
},
|
||||
[pageNameByPage]
|
||||
[pageNameByPage],
|
||||
);
|
||||
|
||||
// Fallback scroll if the page just mounted and tiles need a moment to render.
|
||||
@@ -384,9 +381,7 @@ export function Settings({ initialPage, requestClose }: SettingsProps) {
|
||||
{activePage === SettingsPages.NotificationPage && (
|
||||
<Notifications requestClose={handlePageRequestClose} />
|
||||
)}
|
||||
{activePage === SettingsPages.AudioPage && (
|
||||
<Audio requestClose={handlePageRequestClose} />
|
||||
)}
|
||||
{activePage === SettingsPages.AudioPage && <Audio requestClose={handlePageRequestClose} />}
|
||||
{activePage === SettingsPages.DevicesPage && (
|
||||
<Devices requestClose={handlePageRequestClose} />
|
||||
)}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import { Box, Text, IconButton, Scroll, Button, config, toRem } from 'folds';
|
||||
import { getAppVersion } from '../../../utils/appVersion';
|
||||
import { useOpenReleaseNotesDialog } from '../../../components/updates-dialog/UpdatesDialogHost';
|
||||
import { getCurrentUpdatePreview } from '../../../data/updateNotes';
|
||||
import { Box, Text, IconButton, Scroll, Button, config, toRem } from 'folds';
|
||||
import { Icon, Icons } from '../../../components/icons';
|
||||
import { Page, PageContent, PageHeader } from '../../../components/page';
|
||||
import { SequenceCard } from '../../../components/sequence-card';
|
||||
@@ -19,39 +19,44 @@ export function About({ requestClose }: AboutProps) {
|
||||
const mx = useMatrixClient();
|
||||
const openReleaseNotes = useOpenReleaseNotesDialog();
|
||||
const [version, setVersion] = useState<string>('');
|
||||
const [protocolStatus, setProtocolStatus] = useState<string>('Checking desktop protocol integration...');
|
||||
const [protocolStatus, setProtocolStatus] = useState<string>(
|
||||
'Checking desktop protocol integration...',
|
||||
);
|
||||
const [protocolBusy, setProtocolBusy] = useState<boolean>(false);
|
||||
const [updatePreview, setUpdatePreview] = useState<{ title: string; description: string } | null>(
|
||||
null
|
||||
null,
|
||||
);
|
||||
|
||||
const formatProtocolStatus = useCallback((data: {
|
||||
scheme: string;
|
||||
platform: string;
|
||||
isDefault: boolean;
|
||||
registerCall: boolean;
|
||||
error: string | null;
|
||||
windows: null | {
|
||||
userChoiceProgId: string | null;
|
||||
userChoiceCommand: string | null;
|
||||
hkcuCommand: string | null;
|
||||
hklmCommand: string | null;
|
||||
};
|
||||
}): string => {
|
||||
const state = data.isDefault ? 'registered' : 'not registered';
|
||||
const startupState = data.registerCall ? 'ok' : 'no-change';
|
||||
const owner =
|
||||
data.platform === 'win32' && data.windows?.userChoiceProgId
|
||||
? ` Current default ProgId=${data.windows.userChoiceProgId}.`
|
||||
: '';
|
||||
const missingHint =
|
||||
data.platform === 'win32' && !data.windows?.hkcuCommand && !data.windows?.hklmCommand
|
||||
? ` ${data.scheme} link type is missing from Windows registry. Use Repair to create it.`
|
||||
: '';
|
||||
const errorPart = data.error ? ` Error: ${data.error}` : '';
|
||||
const formatProtocolStatus = useCallback(
|
||||
(data: {
|
||||
scheme: string;
|
||||
platform: string;
|
||||
isDefault: boolean;
|
||||
registerCall: boolean;
|
||||
error: string | null;
|
||||
windows: null | {
|
||||
userChoiceProgId: string | null;
|
||||
userChoiceCommand: string | null;
|
||||
hkcuCommand: string | null;
|
||||
hklmCommand: string | null;
|
||||
};
|
||||
}): string => {
|
||||
const state = data.isDefault ? 'registered' : 'not registered';
|
||||
const startupState = data.registerCall ? 'ok' : 'no-change';
|
||||
const owner =
|
||||
data.platform === 'win32' && data.windows?.userChoiceProgId
|
||||
? ` Current default ProgId=${data.windows.userChoiceProgId}.`
|
||||
: '';
|
||||
const missingHint =
|
||||
data.platform === 'win32' && !data.windows?.hkcuCommand && !data.windows?.hklmCommand
|
||||
? ` ${data.scheme} link type is missing from Windows registry. Use Repair to create it.`
|
||||
: '';
|
||||
const errorPart = data.error ? ` Error: ${data.error}` : '';
|
||||
|
||||
return `${data.scheme} is ${state} (startup=${startupState}) on ${data.platform}.${owner}${missingHint}${errorPart}`;
|
||||
}, []);
|
||||
return `${data.scheme} is ${state} (startup=${startupState}) on ${data.platform}.${owner}${missingHint}${errorPart}`;
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
const refreshProtocolStatus = useCallback(() => {
|
||||
if (!window.electron?.protocol?.getStatus) {
|
||||
@@ -70,7 +75,9 @@ export function About({ requestClose }: AboutProps) {
|
||||
setProtocolStatus(formatProtocolStatus(result.data));
|
||||
})
|
||||
.catch((error) => {
|
||||
setProtocolStatus(`Protocol diagnostics failed: ${error instanceof Error ? error.message : String(error)}`);
|
||||
setProtocolStatus(
|
||||
`Protocol diagnostics failed: ${error instanceof Error ? error.message : String(error)}`,
|
||||
);
|
||||
});
|
||||
}, [formatProtocolStatus]);
|
||||
|
||||
@@ -93,15 +100,21 @@ export function About({ requestClose }: AboutProps) {
|
||||
setProtocolBusy(false);
|
||||
})
|
||||
.catch((error) => {
|
||||
setProtocolStatus(`Protocol repair failed: ${error instanceof Error ? error.message : String(error)}`);
|
||||
setProtocolStatus(
|
||||
`Protocol repair failed: ${error instanceof Error ? error.message : String(error)}`,
|
||||
);
|
||||
setProtocolBusy(false);
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
getAppVersion().then(setVersion).catch(() => setVersion('unknown'));
|
||||
getAppVersion()
|
||||
.then(setVersion)
|
||||
.catch(() => setVersion('unknown'));
|
||||
refreshProtocolStatus();
|
||||
getCurrentUpdatePreview().then(setUpdatePreview).catch(() => setUpdatePreview(null));
|
||||
getCurrentUpdatePreview()
|
||||
.then(setUpdatePreview)
|
||||
.catch(() => setUpdatePreview(null));
|
||||
}, [refreshProtocolStatus]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -11,7 +11,8 @@ export const NAMEPLATE_ASPECT_RATIO = '448 / 84';
|
||||
export const PROFILE_HERO_PREVIEW_WIDTH = 260;
|
||||
export const PROFILE_HERO_CONTENT_HEIGHT = 235;
|
||||
export const PROFILE_HERO_PREVIEW_EXTRA_HEIGHT = Math.round(PROFILE_HERO_CONTENT_HEIGHT * 0.5);
|
||||
export const PROFILE_HERO_PREVIEW_HEIGHT = PROFILE_HERO_CONTENT_HEIGHT + PROFILE_HERO_PREVIEW_EXTRA_HEIGHT;
|
||||
export const PROFILE_HERO_PREVIEW_HEIGHT =
|
||||
PROFILE_HERO_CONTENT_HEIGHT + PROFILE_HERO_PREVIEW_EXTRA_HEIGHT;
|
||||
export const PROFILE_HERO_PREVIEW_ASPECT_RATIO = `${PROFILE_HERO_PREVIEW_WIDTH} / ${PROFILE_HERO_PREVIEW_HEIGHT}`;
|
||||
|
||||
export const CollectibleGroupGrid = style({
|
||||
|
||||
@@ -192,12 +192,7 @@ function VariantChip({
|
||||
/>
|
||||
</div>
|
||||
{thumbUrl && (
|
||||
<img
|
||||
className={AvatarDecorationOverlay}
|
||||
src={thumbUrl}
|
||||
alt=""
|
||||
draggable={false}
|
||||
/>
|
||||
<img className={AvatarDecorationOverlay} src={thumbUrl} alt="" draggable={false} />
|
||||
)}
|
||||
</div>
|
||||
</button>
|
||||
@@ -265,7 +260,7 @@ function CollectibleVariantGroupCard({
|
||||
className={classNames(
|
||||
css.CollectibleGroupPreview,
|
||||
applyingId && css.CollectibleGroupPreviewDisabled,
|
||||
applyingId && applyingId !== selectedItem.id && css.CollectibleGroupPreviewDimmed
|
||||
applyingId && applyingId !== selectedItem.id && css.CollectibleGroupPreviewDimmed,
|
||||
)}
|
||||
onMouseEnter={handlePreviewHover}
|
||||
onClick={() => onApply(selectedItem)}
|
||||
@@ -277,7 +272,7 @@ function CollectibleVariantGroupCard({
|
||||
className={classNames(
|
||||
css.CollectiblePreviewFrame,
|
||||
kind === 'avatar_decoration' && css.CollectiblePreviewFrameDecoration,
|
||||
kind === 'profile_effect' && css.CollectiblePreviewFrameProfileEffect
|
||||
kind === 'profile_effect' && css.CollectiblePreviewFrameProfileEffect,
|
||||
)}
|
||||
style={{
|
||||
aspectRatio: kind === 'nameplate' ? undefined : aspectRatio,
|
||||
@@ -327,14 +322,13 @@ export function CollectiblesSection({ collectibles, onApply }: CollectiblesSecti
|
||||
const previewAvatarUrl = useMemo(
|
||||
() =>
|
||||
profile.avatarUrl
|
||||
? mxcUrlToHttp(mx, profile.avatarUrl, useAuthentication, 96, 96, 'crop') ?? undefined
|
||||
? (mxcUrlToHttp(mx, profile.avatarUrl, useAuthentication, 96, 96, 'crop') ?? undefined)
|
||||
: undefined,
|
||||
[mx, profile.avatarUrl, useAuthentication]
|
||||
[mx, profile.avatarUrl, useAuthentication],
|
||||
);
|
||||
const previewBannerUrl = useMemo(
|
||||
() =>
|
||||
bannerMxc ? mxcUrlToHttp(mx, bannerMxc, useAuthentication) ?? undefined : undefined,
|
||||
[bannerMxc, mx, useAuthentication]
|
||||
() => (bannerMxc ? (mxcUrlToHttp(mx, bannerMxc, useAuthentication) ?? undefined) : undefined),
|
||||
[bannerMxc, mx, useAuthentication],
|
||||
);
|
||||
const previewDisplayName = profile.displayName;
|
||||
const [kind, setKind] = useState<CollectibleKind>('profile_effect');
|
||||
@@ -430,14 +424,14 @@ export function CollectiblesSection({ collectibles, onApply }: CollectiblesSecti
|
||||
css.CollectibleGroupGrid,
|
||||
kind === 'nameplate' && css.CollectibleGroupGridNameplate,
|
||||
kind === 'profile_effect' && css.CollectibleGroupGridEffects,
|
||||
kind === 'avatar_decoration' && css.CollectibleGroupGridDecorations
|
||||
kind === 'avatar_decoration' && css.CollectibleGroupGridDecorations,
|
||||
);
|
||||
|
||||
return (
|
||||
<Box direction="Column" gap="300">
|
||||
<Text size="T200" style={{ opacity: 0.8 }}>
|
||||
Browse a community-published Discord collectibles catalog, then download and upload only what
|
||||
you pick to Matrix.
|
||||
Browse a community-published Discord collectibles catalog, then download and upload only
|
||||
what you pick to Matrix.
|
||||
</Text>
|
||||
|
||||
<Box gap="200" alignItems="Center" wrap="Wrap">
|
||||
@@ -454,89 +448,97 @@ export function CollectiblesSection({ collectibles, onApply }: CollectiblesSecti
|
||||
</Box>
|
||||
|
||||
<>
|
||||
<Box gap="200" wrap="Wrap">
|
||||
{KIND_TABS.map((tab) => (
|
||||
<Button
|
||||
key={tab}
|
||||
size="300"
|
||||
variant={tab === kind ? 'Primary' : 'Secondary'}
|
||||
fill={tab === kind ? 'Solid' : 'Soft'}
|
||||
radii="300"
|
||||
onClick={() => setKind(tab)}
|
||||
>
|
||||
<Text size="B300">{collectibleKindLabel(tab)}</Text>
|
||||
</Button>
|
||||
))}
|
||||
<Box gap="200" wrap="Wrap">
|
||||
{KIND_TABS.map((tab) => (
|
||||
<Button
|
||||
key={tab}
|
||||
size="300"
|
||||
variant={tab === kind ? 'Primary' : 'Secondary'}
|
||||
fill={tab === kind ? 'Solid' : 'Soft'}
|
||||
radii="300"
|
||||
onClick={() => setKind(tab)}
|
||||
>
|
||||
<Text size="B300">{collectibleKindLabel(tab)}</Text>
|
||||
</Button>
|
||||
))}
|
||||
</Box>
|
||||
|
||||
<Input
|
||||
size="300"
|
||||
variant="Secondary"
|
||||
style={{ width: '100%' }}
|
||||
placeholder={`Search ${collectibleKindLabel(kind).toLowerCase()}s…`}
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
/>
|
||||
|
||||
{current && (
|
||||
<Box gap="200" alignItems="Center" wrap="Wrap">
|
||||
<Text size="T300">Active: {current.name}</Text>
|
||||
<Button size="300" variant="Critical" fill="Soft" radii="300" onClick={handleRemove}>
|
||||
<Text size="B300">Remove</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
<Input
|
||||
size="300"
|
||||
variant="Secondary"
|
||||
style={{ width: '100%' }}
|
||||
placeholder={`Search ${collectibleKindLabel(kind).toLowerCase()}s…`}
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
/>
|
||||
{catalogLoading && (
|
||||
<Box gap="200" alignItems="Center">
|
||||
<Spinner size="100" variant="Secondary" />
|
||||
<Text size="T200">Loading collectibles catalog…</Text>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{current && (
|
||||
<Box gap="200" alignItems="Center" wrap="Wrap">
|
||||
<Text size="T300">Active: {current.name}</Text>
|
||||
<Button size="300" variant="Critical" fill="Soft" radii="300" onClick={handleRemove}>
|
||||
<Text size="B300">Remove</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
)}
|
||||
{catalogError && !catalogLoading && (
|
||||
<Text size="T200" style={{ color: color.Critical.Main }}>
|
||||
{catalogError}
|
||||
</Text>
|
||||
)}
|
||||
|
||||
{catalogLoading && (
|
||||
<Box gap="200" alignItems="Center">
|
||||
<Spinner size="100" variant="Secondary" />
|
||||
<Text size="T200">Loading collectibles catalog…</Text>
|
||||
</Box>
|
||||
)}
|
||||
{applyProgress && (
|
||||
<Box gap="200" alignItems="Center">
|
||||
<Spinner size="100" variant="Secondary" />
|
||||
<Text size="T200">{applyProgress}</Text>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{catalogError && !catalogLoading && (
|
||||
<Text size="T200" style={{ color: color.Critical.Main }}>{catalogError}</Text>
|
||||
)}
|
||||
{error && (
|
||||
<Text size="T200" style={{ color: color.Critical.Main }}>
|
||||
{error}
|
||||
</Text>
|
||||
)}
|
||||
|
||||
{applyProgress && (
|
||||
<Box gap="200" alignItems="Center">
|
||||
<Spinner size="100" variant="Secondary" />
|
||||
<Text size="T200">{applyProgress}</Text>
|
||||
</Box>
|
||||
)}
|
||||
<div className={gridClassName}>
|
||||
{filteredGroups.map((group) => {
|
||||
const selectedSku = selectedByGroup[group.id] ?? group.items[0]?.skuId;
|
||||
const selectedItem =
|
||||
group.items.find((item) => item.skuId === selectedSku) ?? group.items[0];
|
||||
if (!selectedItem) return null;
|
||||
|
||||
{error && <Text size="T200" style={{ color: color.Critical.Main }}>{error}</Text>}
|
||||
return (
|
||||
<CollectibleVariantGroupCard
|
||||
key={group.id}
|
||||
group={group}
|
||||
kind={kind}
|
||||
selectedItem={selectedItem}
|
||||
onSelectItem={(item) =>
|
||||
setSelectedByGroup((prev) => ({ ...prev, [group.id]: item.skuId }))
|
||||
}
|
||||
applyingId={applyingId}
|
||||
onApply={handleApply}
|
||||
previewAvatarUrl={previewAvatarUrl}
|
||||
previewBannerUrl={previewBannerUrl}
|
||||
previewDisplayName={previewDisplayName}
|
||||
previewUserId={userId}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
<div className={gridClassName}>
|
||||
{filteredGroups.map((group) => {
|
||||
const selectedSku = selectedByGroup[group.id] ?? group.items[0]?.skuId;
|
||||
const selectedItem =
|
||||
group.items.find((item) => item.skuId === selectedSku) ?? group.items[0];
|
||||
if (!selectedItem) return null;
|
||||
|
||||
return (
|
||||
<CollectibleVariantGroupCard
|
||||
key={group.id}
|
||||
group={group}
|
||||
kind={kind}
|
||||
selectedItem={selectedItem}
|
||||
onSelectItem={(item) =>
|
||||
setSelectedByGroup((prev) => ({ ...prev, [group.id]: item.skuId }))
|
||||
}
|
||||
applyingId={applyingId}
|
||||
onApply={handleApply}
|
||||
previewAvatarUrl={previewAvatarUrl}
|
||||
previewBannerUrl={previewBannerUrl}
|
||||
previewDisplayName={previewDisplayName}
|
||||
previewUserId={userId}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{!catalogLoading && filteredGroups.length === 0 && (
|
||||
<Text size="T200" style={{ opacity: 0.7 }}>No items match your search.</Text>
|
||||
)}
|
||||
{!catalogLoading && filteredGroups.length === 0 && (
|
||||
<Text size="T200" style={{ opacity: 0.7 }}>
|
||||
No items match your search.
|
||||
</Text>
|
||||
)}
|
||||
</>
|
||||
</Box>
|
||||
);
|
||||
|
||||
@@ -9,7 +9,7 @@ import { AsyncStatus, useAsyncCallback } from '../../../hooks/useAsyncCallback';
|
||||
export function ContactInformation() {
|
||||
const mx = useMatrixClient();
|
||||
const [threePIdsState, loadThreePIds] = useAsyncCallback(
|
||||
useCallback(() => mx.getThreePids(), [mx])
|
||||
useCallback(() => mx.getThreePids(), [mx]),
|
||||
);
|
||||
const threePIds =
|
||||
threePIdsState.status === AsyncStatus.Success ? threePIdsState.data.threepids : undefined;
|
||||
|
||||
@@ -20,8 +20,8 @@ function IgnoreUserInput({ userList }: { userList: string[] }) {
|
||||
async (uId: string) => {
|
||||
await mx.setIgnoredUsers([...userList, uId]);
|
||||
},
|
||||
[mx, userList]
|
||||
)
|
||||
[mx, userList],
|
||||
),
|
||||
);
|
||||
const ignoring = ignoreState.status === AsyncStatus.Loading;
|
||||
|
||||
@@ -101,8 +101,8 @@ function IgnoredUserChip({ userId, userList }: { userId: string; userList: strin
|
||||
const [unignoreState, unignore] = useAsyncCallback(
|
||||
useCallback(
|
||||
() => mx.setIgnoredUsers(userList.filter((uId) => uId !== userId)),
|
||||
[mx, userId, userList]
|
||||
)
|
||||
[mx, userId, userList],
|
||||
),
|
||||
);
|
||||
|
||||
const handleUnignore = () => unignore();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -53,7 +53,12 @@ export function ProfileEffectHeroPreview({
|
||||
<img className={css.ProfileEffectHeroBanner} src={bannerUrl} alt="" draggable={false} />
|
||||
) : (
|
||||
avatarUrl && (
|
||||
<img className={css.ProfileEffectHeroCoverBlur} src={avatarUrl} alt="" draggable={false} />
|
||||
<img
|
||||
className={css.ProfileEffectHeroCoverBlur}
|
||||
src={avatarUrl}
|
||||
alt=""
|
||||
draggable={false}
|
||||
/>
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,24 @@
|
||||
/* eslint-disable no-console */
|
||||
import React, { useCallback, useEffect, useRef, useState, MouseEventHandler } from 'react';
|
||||
import { Box, Button, color, config, Header, IconButton, Input, Menu, MenuItem, PopOut, RectCords, Scroll, Switch, Text, toRem } from 'folds';
|
||||
import { Icon, Icons } from '../../../components/icons';
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
color,
|
||||
config,
|
||||
Header,
|
||||
IconButton,
|
||||
Input,
|
||||
Menu,
|
||||
MenuItem,
|
||||
PopOut,
|
||||
RectCords,
|
||||
Scroll,
|
||||
Switch,
|
||||
Text,
|
||||
toRem,
|
||||
} from 'folds';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { Icon, Icons } from '../../../components/icons';
|
||||
import { Page, PageContent, PageHeader } from '../../../components/page';
|
||||
import { SequenceCard } from '../../../components/sequence-card';
|
||||
import { SettingTile } from '../../../components/setting-tile';
|
||||
@@ -22,24 +38,28 @@ interface AudioDevice {
|
||||
export type ScreenShareResolution = '720p' | '1080p' | '1440p' | '4k' | 'source';
|
||||
|
||||
/** Screen share resolution configs */
|
||||
export const SCREEN_SHARE_RESOLUTIONS: Record<ScreenShareResolution, { width: number; height: number; label: string }> = {
|
||||
export const SCREEN_SHARE_RESOLUTIONS: Record<
|
||||
ScreenShareResolution,
|
||||
{ width: number; height: number; label: string }
|
||||
> = {
|
||||
'720p': { width: 1280, height: 720, label: '720p (HD)' },
|
||||
'1080p': { width: 1920, height: 1080, label: '1080p (Full HD)' },
|
||||
'1440p': { width: 2560, height: 1440, label: '1440p (2K)' },
|
||||
'4k': { width: 3840, height: 2160, label: '4K (Ultra HD)' },
|
||||
'source': { width: 0, height: 0, label: 'Source Resolution' },
|
||||
source: { width: 0, height: 0, label: 'Source Resolution' },
|
||||
};
|
||||
|
||||
/** Screen share bitrate presets in kbps */
|
||||
export type ScreenShareBitrate = 'low' | 'medium' | 'high' | 'ultra';
|
||||
|
||||
/** Screen share bitrate configs */
|
||||
export const SCREEN_SHARE_BITRATES: Record<ScreenShareBitrate, { bitrate: number; label: string }> = {
|
||||
'low': { bitrate: 1000, label: 'Low (1 Mbps)' },
|
||||
'medium': { bitrate: 2500, label: 'Medium (2.5 Mbps)' },
|
||||
'high': { bitrate: 5000, label: 'High (5 Mbps)' },
|
||||
'ultra': { bitrate: 10000, label: 'Ultra (10 Mbps)' },
|
||||
};
|
||||
export const SCREEN_SHARE_BITRATES: Record<ScreenShareBitrate, { bitrate: number; label: string }> =
|
||||
{
|
||||
low: { bitrate: 1000, label: 'Low (1 Mbps)' },
|
||||
medium: { bitrate: 2500, label: 'Medium (2.5 Mbps)' },
|
||||
high: { bitrate: 5000, label: 'High (5 Mbps)' },
|
||||
ultra: { bitrate: 10000, label: 'Ultra (10 Mbps)' },
|
||||
};
|
||||
|
||||
/** Stored audio device settings */
|
||||
interface AudioSettings {
|
||||
@@ -235,11 +255,7 @@ function DeviceSelectButton({ devices, selectedId, onSelect }: DeviceSelectButto
|
||||
escapeDeactivates: stopPropagation,
|
||||
}}
|
||||
>
|
||||
<DeviceSelector
|
||||
devices={devices}
|
||||
selectedId={selectedId}
|
||||
onSelect={handleSelect}
|
||||
/>
|
||||
<DeviceSelector devices={devices} selectedId={selectedId} onSelect={handleSelect} />
|
||||
</FocusTrap>
|
||||
}
|
||||
/>
|
||||
@@ -471,10 +487,14 @@ export function Audio({ requestClose }: AudioProps) {
|
||||
const [microphones, setMicrophones] = useState<AudioDevice[]>([]);
|
||||
const [speakers, setSpeakers] = useState<AudioDevice[]>([]);
|
||||
const [settings, setSettings] = useState<AudioSettings>(loadAudioSettings);
|
||||
const [permissionStatus, setPermissionStatus] = useState<'granted' | 'denied' | 'prompt'>('prompt');
|
||||
const [permissionStatus, setPermissionStatus] = useState<'granted' | 'denied' | 'prompt'>(
|
||||
'prompt',
|
||||
);
|
||||
const [micTestState, setMicTestState] = useState<'idle' | 'testing' | 'done' | 'error'>('idle');
|
||||
const [micLevel, setMicLevel] = useState(0);
|
||||
const [speakerTestState, setSpeakerTestState] = useState<'idle' | 'testing' | 'done' | 'error'>('idle');
|
||||
const [speakerTestState, setSpeakerTestState] = useState<'idle' | 'testing' | 'done' | 'error'>(
|
||||
'idle',
|
||||
);
|
||||
const [micMonitoring, setMicMonitoring] = useState(false);
|
||||
const micAnimFrameRef = useRef<number | null>(null);
|
||||
const micMonitorContextRef = useRef<AudioContext | null>(null);
|
||||
@@ -490,7 +510,7 @@ export function Audio({ requestClose }: AudioProps) {
|
||||
setPermissionStatus('granted');
|
||||
|
||||
const devices = await navigator.mediaDevices.enumerateDevices();
|
||||
|
||||
|
||||
const mics = devices
|
||||
.filter((d) => d.kind === 'audioinput')
|
||||
.map((d) => ({
|
||||
@@ -498,7 +518,7 @@ export function Audio({ requestClose }: AudioProps) {
|
||||
label: d.label,
|
||||
kind: d.kind,
|
||||
}));
|
||||
|
||||
|
||||
const spks = devices
|
||||
.filter((d) => d.kind === 'audiooutput')
|
||||
.map((d) => ({
|
||||
@@ -682,10 +702,10 @@ export function Audio({ requestClose }: AudioProps) {
|
||||
const dataArray = new Uint8Array(analyser.frequencyBinCount);
|
||||
const microphone = audioContext.createMediaStreamSource(stream);
|
||||
const gainNode = audioContext.createGain();
|
||||
|
||||
|
||||
// Connect microphone to analyser for level monitoring
|
||||
microphone.connect(analyser);
|
||||
|
||||
|
||||
// Connect microphone to speakers for playback
|
||||
microphone.connect(gainNode);
|
||||
gainNode.connect(audioContext.destination);
|
||||
@@ -708,11 +728,17 @@ export function Audio({ requestClose }: AudioProps) {
|
||||
console.error('Microphone monitoring failed:', e);
|
||||
}
|
||||
}
|
||||
}, [micMonitoring, settings.microphoneId, settings.noiseSuppression, settings.echoCancellation, settings.autoGainControl]);
|
||||
}, [
|
||||
micMonitoring,
|
||||
settings.microphoneId,
|
||||
settings.noiseSuppression,
|
||||
settings.echoCancellation,
|
||||
settings.autoGainControl,
|
||||
]);
|
||||
|
||||
// Cleanup monitoring on unmount
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
useEffect(
|
||||
() => () => {
|
||||
if (micAnimFrameRef.current !== null) {
|
||||
cancelAnimationFrame(micAnimFrameRef.current);
|
||||
}
|
||||
@@ -722,8 +748,9 @@ export function Audio({ requestClose }: AudioProps) {
|
||||
if (micMonitorContextRef.current) {
|
||||
micMonitorContextRef.current.close();
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
// Apply processing toggles to the live monitor track without tearing it down.
|
||||
useEffect(() => {
|
||||
@@ -807,14 +834,26 @@ export function Audio({ requestClose }: AudioProps) {
|
||||
<Box gap="200" alignItems="Center">
|
||||
<Button
|
||||
size="300"
|
||||
variant={micTestState === 'error' ? 'Critical' : micTestState === 'done' ? 'Success' : 'Secondary'}
|
||||
variant={
|
||||
micTestState === 'error'
|
||||
? 'Critical'
|
||||
: micTestState === 'done'
|
||||
? 'Success'
|
||||
: 'Secondary'
|
||||
}
|
||||
fill="Soft"
|
||||
radii="300"
|
||||
onClick={handleTestMicrophone}
|
||||
disabled={micTestState === 'testing' || micMonitoring}
|
||||
>
|
||||
<Text size="T300">
|
||||
{micTestState === 'testing' ? 'Testing...' : micTestState === 'done' ? 'Done ✓' : micTestState === 'error' ? 'Failed' : 'Test'}
|
||||
{micTestState === 'testing'
|
||||
? 'Testing...'
|
||||
: micTestState === 'done'
|
||||
? 'Done ✓'
|
||||
: micTestState === 'error'
|
||||
? 'Failed'
|
||||
: 'Test'}
|
||||
</Text>
|
||||
</Button>
|
||||
<Button
|
||||
@@ -825,14 +864,27 @@ export function Audio({ requestClose }: AudioProps) {
|
||||
onClick={handleMicMonitoringToggle}
|
||||
disabled={micTestState === 'testing'}
|
||||
>
|
||||
<Text size="T300">
|
||||
{micMonitoring ? 'Stop' : 'Monitor'}
|
||||
</Text>
|
||||
<Text size="T300">{micMonitoring ? 'Stop' : 'Monitor'}</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
{(micTestState === 'testing' || micMonitoring) && (
|
||||
<Box style={{ width: toRem(160), height: toRem(6), background: color.Surface.Container, borderRadius: toRem(3), overflow: 'hidden' }}>
|
||||
<Box style={{ width: `${micLevel}%`, height: '100%', background: micMonitoring ? color.Success.Main : color.Primary.Main, transition: 'width 0.05s ease' }} />
|
||||
<Box
|
||||
style={{
|
||||
width: toRem(160),
|
||||
height: toRem(6),
|
||||
background: color.Surface.Container,
|
||||
borderRadius: toRem(3),
|
||||
overflow: 'hidden',
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
style={{
|
||||
width: `${micLevel}%`,
|
||||
height: '100%',
|
||||
background: micMonitoring ? color.Success.Main : color.Primary.Main,
|
||||
transition: 'width 0.05s ease',
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
@@ -864,14 +916,26 @@ export function Audio({ requestClose }: AudioProps) {
|
||||
/>
|
||||
<Button
|
||||
size="300"
|
||||
variant={speakerTestState === 'error' ? 'Critical' : speakerTestState === 'done' ? 'Success' : 'Secondary'}
|
||||
variant={
|
||||
speakerTestState === 'error'
|
||||
? 'Critical'
|
||||
: speakerTestState === 'done'
|
||||
? 'Success'
|
||||
: 'Secondary'
|
||||
}
|
||||
fill="Soft"
|
||||
radii="300"
|
||||
onClick={handleTestSpeaker}
|
||||
disabled={speakerTestState === 'testing'}
|
||||
>
|
||||
<Text size="T300">
|
||||
{speakerTestState === 'testing' ? 'Playing...' : speakerTestState === 'done' ? 'Done ✓' : speakerTestState === 'error' ? 'Failed' : 'Test'}
|
||||
{speakerTestState === 'testing'
|
||||
? 'Playing...'
|
||||
: speakerTestState === 'done'
|
||||
? 'Done ✓'
|
||||
: speakerTestState === 'error'
|
||||
? 'Failed'
|
||||
: 'Test'}
|
||||
</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
@@ -992,10 +1056,12 @@ export function Audio({ requestClose }: AudioProps) {
|
||||
</Header>
|
||||
<Box direction="Column" gap="200" style={{ padding: `0 ${config.space.S300}` }}>
|
||||
<Text size="T300">
|
||||
• If you don't see your devices, make sure they are connected and permissions are granted.
|
||||
• If you don't see your devices, make sure they are connected and
|
||||
permissions are granted.
|
||||
</Text>
|
||||
<Text size="T300">
|
||||
• The "Test" button will help verify your devices are working correctly.
|
||||
• The "Test" button will help verify your devices are working
|
||||
correctly.
|
||||
</Text>
|
||||
<Text size="T300">
|
||||
• Changes are saved automatically and will apply to your next call.
|
||||
|
||||
@@ -16,14 +16,14 @@ type AccountDataProps = {
|
||||
export function AccountData({ expand, onExpandToggle, onSelect }: AccountDataProps) {
|
||||
const mx = useMatrixClient();
|
||||
const [accountDataTypes, setAccountDataKeys] = useState(() =>
|
||||
Array.from(mx.store.accountData.keys())
|
||||
Array.from(mx.store.accountData.keys()),
|
||||
);
|
||||
|
||||
useAccountDataCallback(
|
||||
mx,
|
||||
useCallback(() => {
|
||||
setAccountDataKeys(Array.from(mx.store.accountData.keys()));
|
||||
}, [mx])
|
||||
}, [mx]),
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
import React, { useCallback, useState } from 'react';
|
||||
import { Box, Text, IconButton, Scroll, Switch, Button, Modal, Overlay, OverlayBackdrop, OverlayCenter } from 'folds';
|
||||
import {
|
||||
Box,
|
||||
Text,
|
||||
IconButton,
|
||||
Scroll,
|
||||
Switch,
|
||||
Button,
|
||||
Modal,
|
||||
Overlay,
|
||||
OverlayBackdrop,
|
||||
OverlayCenter,
|
||||
} from 'folds';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { Icon, Icons } from '../../../components/icons';
|
||||
import { Page, PageContent, PageHeader } from '../../../components/page';
|
||||
@@ -36,23 +47,26 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) {
|
||||
|
||||
const profileEditable = profileSupported && profileUserId.trim() === mx.getUserId();
|
||||
|
||||
const fetchProfileFields = useCallback(async (userId: string) => {
|
||||
if (!userId) return;
|
||||
const fetchProfileFields = useCallback(
|
||||
async (userId: string) => {
|
||||
if (!userId) return;
|
||||
|
||||
try {
|
||||
const supported = await mx.doesServerSupportExtendedProfiles();
|
||||
setProfileSupported(supported);
|
||||
setProfileFields(
|
||||
supported
|
||||
? await mx.getExtendedProfile(userId)
|
||||
: ((await mx.getProfileInfo(userId)) as Record<string, unknown>),
|
||||
);
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch profile fields:', err);
|
||||
setProfileSupported(false);
|
||||
setProfileFields({});
|
||||
}
|
||||
}, [mx]);
|
||||
try {
|
||||
const supported = await mx.doesServerSupportExtendedProfiles();
|
||||
setProfileSupported(supported);
|
||||
setProfileFields(
|
||||
supported
|
||||
? await mx.getExtendedProfile(userId)
|
||||
: ((await mx.getProfileInfo(userId)) as Record<string, unknown>),
|
||||
);
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch profile fields:', err);
|
||||
setProfileSupported(false);
|
||||
setProfileFields({});
|
||||
}
|
||||
},
|
||||
[mx],
|
||||
);
|
||||
|
||||
const submitProfileField: AccountDataSubmitCallback = useCallback(
|
||||
async (key, content) => {
|
||||
@@ -61,7 +75,7 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) {
|
||||
// The rest of the client reads through the shared profile cache
|
||||
clearProfileCache(profileUserId.trim());
|
||||
},
|
||||
[mx, profileUserId]
|
||||
[mx, profileUserId],
|
||||
);
|
||||
|
||||
const deleteProfileField = useCallback(
|
||||
@@ -79,7 +93,7 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) {
|
||||
console.error('Failed to delete profile field:', err);
|
||||
}
|
||||
},
|
||||
[mx, profileUserId]
|
||||
[mx, profileUserId],
|
||||
);
|
||||
|
||||
const handleProfileExpand = useCallback(
|
||||
@@ -87,14 +101,14 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) {
|
||||
setProfileExpand(expand);
|
||||
if (expand) fetchProfileFields(profileUserId.trim());
|
||||
},
|
||||
[fetchProfileFields, profileUserId]
|
||||
[fetchProfileFields, profileUserId],
|
||||
);
|
||||
|
||||
const submitAccountData: AccountDataSubmitCallback = useCallback(
|
||||
async (type, content) => {
|
||||
await mx.setAccountData(type, content);
|
||||
},
|
||||
[mx]
|
||||
[mx],
|
||||
);
|
||||
|
||||
if (accountDataType !== undefined) {
|
||||
|
||||
@@ -69,37 +69,39 @@ export function ProfileFields({
|
||||
<Text size="L400">Total: {Object.keys(fields).length}</Text>
|
||||
</Box>
|
||||
<CutoutCard>
|
||||
{Object.keys(fields).sort().map((key) => (
|
||||
<MenuItem
|
||||
key={key}
|
||||
variant="Surface"
|
||||
fill="None"
|
||||
size="300"
|
||||
radii="0"
|
||||
after={
|
||||
<Box gap="100" alignItems="Center">
|
||||
{editable && (
|
||||
<IconButton
|
||||
size="200"
|
||||
radii="Round"
|
||||
title={`Delete ${key}`}
|
||||
onClick={() => onDelete(key)}
|
||||
>
|
||||
<Icon size="50" src={Icons.Cross} />
|
||||
</IconButton>
|
||||
)}
|
||||
<Icon size="50" src={Icons.ChevronRight} />
|
||||
{Object.keys(fields)
|
||||
.sort()
|
||||
.map((key) => (
|
||||
<MenuItem
|
||||
key={key}
|
||||
variant="Surface"
|
||||
fill="None"
|
||||
size="300"
|
||||
radii="0"
|
||||
after={
|
||||
<Box gap="100" alignItems="Center">
|
||||
{editable && (
|
||||
<IconButton
|
||||
size="200"
|
||||
radii="Round"
|
||||
title={`Delete ${key}`}
|
||||
onClick={() => onDelete(key)}
|
||||
>
|
||||
<Icon size="50" src={Icons.Cross} />
|
||||
</IconButton>
|
||||
)}
|
||||
<Icon size="50" src={Icons.ChevronRight} />
|
||||
</Box>
|
||||
}
|
||||
onClick={() => onSelect(key)}
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="T200" truncate>
|
||||
{key}
|
||||
</Text>
|
||||
</Box>
|
||||
}
|
||||
onClick={() => onSelect(key)}
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="T200" truncate>
|
||||
{key}
|
||||
</Text>
|
||||
</Box>
|
||||
</MenuItem>
|
||||
))}
|
||||
</MenuItem>
|
||||
))}
|
||||
</CutoutCard>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
@@ -1,9 +1,22 @@
|
||||
import React, { FormEventHandler, ReactNode, useCallback, useEffect, useState } from 'react';
|
||||
import { Box, Text, IconButton, Chip, Input, Button, color, Spinner, toRem, Overlay, OverlayBackdrop, OverlayCenter } from 'folds';
|
||||
import { Icon, Icons } from '../../../components/icons';
|
||||
import {
|
||||
Box,
|
||||
Text,
|
||||
IconButton,
|
||||
Chip,
|
||||
Input,
|
||||
Button,
|
||||
color,
|
||||
Spinner,
|
||||
toRem,
|
||||
Overlay,
|
||||
OverlayBackdrop,
|
||||
OverlayCenter,
|
||||
} from 'folds';
|
||||
import { CryptoApi } from 'matrix-js-sdk/lib/crypto-api';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { IMyDevice, MatrixError } from 'matrix-js-sdk';
|
||||
import { Icon, Icons } from '../../../components/icons';
|
||||
import { SettingTile } from '../../../components/setting-tile';
|
||||
import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
||||
import { timeDayMonYear, timeHourMinute, today, yesterday } from '../../../utils/time';
|
||||
@@ -72,7 +85,7 @@ export function DeviceKeyDetails({ crypto }: DeviceKeyDetailsProps) {
|
||||
useCallback(() => {
|
||||
const keys = crypto.getOwnDeviceKeys();
|
||||
return keys;
|
||||
}, [crypto])
|
||||
}, [crypto]),
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -104,8 +117,8 @@ function DeviceRename({ device, onCancel, onRename, refreshDeviceList }: DeviceR
|
||||
await mx.setDeviceDetails(device.device_id, { display_name: name });
|
||||
await refreshDeviceList();
|
||||
},
|
||||
[mx, device.device_id, refreshDeviceList]
|
||||
)
|
||||
[mx, device.device_id, refreshDeviceList],
|
||||
),
|
||||
);
|
||||
|
||||
const renaming = renameState.status === AsyncStatus.Loading;
|
||||
|
||||
@@ -50,19 +50,19 @@ export function Devices({ requestClose }: DevicesProps) {
|
||||
const verificationStatus = useDeviceVerificationStatus(
|
||||
crypto,
|
||||
mx.getSafeUserId(),
|
||||
currentDevice?.device_id
|
||||
currentDevice?.device_id,
|
||||
);
|
||||
|
||||
const otherDevicesId = useDeviceIds(otherDevices);
|
||||
const unverifiedDeviceCount = useUnverifiedDeviceCount(
|
||||
crypto,
|
||||
mx.getSafeUserId(),
|
||||
otherDevicesId
|
||||
otherDevicesId,
|
||||
);
|
||||
|
||||
const defaultSecretStorageKeyId = useSecretStorageDefaultKeyId();
|
||||
const defaultSecretStorageKeyContent = useSecretStorageKeyContent(
|
||||
defaultSecretStorageKeyId ?? ''
|
||||
defaultSecretStorageKeyId ?? '',
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { FormEventHandler, useCallback, useEffect, useState } from 'react';
|
||||
import { Box, Button, color, Spinner, Text, toRem } from 'folds';
|
||||
import { Icon, Icons } from '../../../components/icons';
|
||||
import FileSaver from 'file-saver';
|
||||
import { Icon, Icons } from '../../../components/icons';
|
||||
import { SequenceCard } from '../../../components/sequence-card';
|
||||
import { SettingTile } from '../../../components/setting-tile';
|
||||
import { SequenceCardStyle } from '../styles.css';
|
||||
@@ -31,8 +31,8 @@ function ExportKeys() {
|
||||
});
|
||||
FileSaver.saveAs(blob, 'paarrot-keys.txt');
|
||||
},
|
||||
[mx]
|
||||
)
|
||||
[mx],
|
||||
),
|
||||
);
|
||||
|
||||
const exporting = exportState.status === AsyncStatus.Loading;
|
||||
@@ -175,8 +175,8 @@ function ImportKeys({ file, onDone }: ImportKeysProps) {
|
||||
|
||||
await crypto.importRoomKeysAsJson(keys);
|
||||
},
|
||||
[file, mx]
|
||||
)
|
||||
[file, mx],
|
||||
),
|
||||
);
|
||||
|
||||
const decrypting = decryptState.status === AsyncStatus.Loading;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useCallback, useState } from 'react';
|
||||
import { openExternalUrl } from '../../../utils/tauri';
|
||||
import { Box, Button, config, Menu, Spinner, Text } from 'folds';
|
||||
import { AuthDict, IMyDevice, MatrixError } from 'matrix-js-sdk';
|
||||
import { openExternalUrl } from '../../../utils/tauri';
|
||||
import { SequenceCard } from '../../../components/sequence-card';
|
||||
import { SequenceCardStyle } from '../styles.css';
|
||||
import { ActionUIA, ActionUIAFlowsLoader } from '../../../components/ActionUIA';
|
||||
@@ -37,7 +37,7 @@ export function OtherDevices({ devices, refreshDeviceList, showVerification }: O
|
||||
openExternalUrl(
|
||||
withSearchParam(authUrl, {
|
||||
action: accountManagementActions.sessionsList,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}, [authMetadata, accountManagementActions]);
|
||||
|
||||
@@ -50,10 +50,10 @@ export function OtherDevices({ devices, refreshDeviceList, showVerification }: O
|
||||
withSearchParam(authUrl, {
|
||||
action: accountManagementActions.sessionEnd,
|
||||
device_id: deviceId,
|
||||
})
|
||||
}),
|
||||
);
|
||||
},
|
||||
[authMetadata, accountManagementActions]
|
||||
[authMetadata, accountManagementActions],
|
||||
);
|
||||
|
||||
const handleToggleDelete = useCallback((deviceId: string) => {
|
||||
@@ -77,7 +77,7 @@ export function OtherDevices({ devices, refreshDeviceList, showVerification }: O
|
||||
async (authDict?: AuthDict) => {
|
||||
await mx.deleteMultipleDevices(Array.from(deleted), authDict);
|
||||
},
|
||||
[mx, deleted]
|
||||
[mx, deleted],
|
||||
),
|
||||
useCallback(
|
||||
(state: typeof deleteState) => {
|
||||
@@ -87,11 +87,11 @@ export function OtherDevices({ devices, refreshDeviceList, showVerification }: O
|
||||
}
|
||||
setDeleteState(state);
|
||||
},
|
||||
[refreshDeviceList]
|
||||
)
|
||||
[refreshDeviceList],
|
||||
),
|
||||
);
|
||||
const [authData, deleteError] = useUIAMatrixError(
|
||||
deleteState.status === AsyncStatus.Error ? deleteState.error : undefined
|
||||
deleteState.status === AsyncStatus.Error ? deleteState.error : undefined,
|
||||
);
|
||||
const deleting = deleteState.status === AsyncStatus.Loading || authData !== undefined;
|
||||
|
||||
|
||||
@@ -1,8 +1,24 @@
|
||||
import React, { MouseEventHandler, useCallback, useState } from 'react';
|
||||
import { Badge, Box, Button, Chip, config, Spinner, Text, Overlay, OverlayBackdrop, OverlayCenter, IconButton, RectCords, PopOut, Menu, MenuItem } from 'folds';
|
||||
import { Icon, Icons } from '../../../components/icons';
|
||||
import {
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
Chip,
|
||||
config,
|
||||
Spinner,
|
||||
Text,
|
||||
Overlay,
|
||||
OverlayBackdrop,
|
||||
OverlayCenter,
|
||||
IconButton,
|
||||
RectCords,
|
||||
PopOut,
|
||||
Menu,
|
||||
MenuItem,
|
||||
} from 'folds';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { CryptoApi, VerificationRequest } from 'matrix-js-sdk/lib/crypto-api';
|
||||
import { Icon, Icons } from '../../../components/icons';
|
||||
import { VerificationStatus } from '../../../hooks/useDeviceVerificationStatus';
|
||||
import { InfoCard } from '../../../components/info-card';
|
||||
import { ManualVerificationTile } from '../../../components/ManualVerification';
|
||||
@@ -161,7 +177,7 @@ export function VerifyOtherDeviceTile({ crypto, deviceId }: VerifyOtherDeviceTil
|
||||
const requestPromise = crypto.requestDeviceVerification(mx.getSafeUserId(), deviceId);
|
||||
return requestPromise;
|
||||
}, [mx, crypto, deviceId]),
|
||||
setRequestState
|
||||
setRequestState,
|
||||
);
|
||||
|
||||
const handleExit = useCallback(() => {
|
||||
@@ -260,7 +276,7 @@ export function DeviceVerificationOptions() {
|
||||
openExternalUrl(
|
||||
withSearchParam(authUrl, {
|
||||
action: accountManagementActions.crossSigningReset,
|
||||
})
|
||||
}),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,10 @@ type EmojisStickersProps = {
|
||||
};
|
||||
export function EmojisStickers({ requestClose }: EmojisStickersProps) {
|
||||
const [imagePack, setImagePack] = useState<ImagePack>();
|
||||
const [autoConvertEmoticons, setAutoConvertEmoticons] = useSetting(settingsAtom, 'autoConvertEmoticons');
|
||||
const [autoConvertEmoticons, setAutoConvertEmoticons] = useSetting(
|
||||
settingsAtom,
|
||||
'autoConvertEmoticons',
|
||||
);
|
||||
|
||||
const handleImagePackViewClose = () => {
|
||||
setImagePack(undefined);
|
||||
|
||||
@@ -1,9 +1,27 @@
|
||||
import React, { MouseEventHandler, useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { Box, Text, Button, IconButton, Avatar, AvatarFallback, config, Spinner, Menu, RectCords, PopOut, Checkbox, toRem, Scroll, Header, Line, Chip } from 'folds';
|
||||
import { Icon, Icons } from '../../../components/icons';
|
||||
import {
|
||||
Box,
|
||||
Text,
|
||||
Button,
|
||||
IconButton,
|
||||
Avatar,
|
||||
AvatarFallback,
|
||||
config,
|
||||
Spinner,
|
||||
Menu,
|
||||
RectCords,
|
||||
PopOut,
|
||||
Checkbox,
|
||||
toRem,
|
||||
Scroll,
|
||||
Header,
|
||||
Line,
|
||||
Chip,
|
||||
} from 'folds';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { Room } from 'matrix-js-sdk';
|
||||
import { Icon, Icons } from '../../../components/icons';
|
||||
import { useGlobalImagePacks, useRoomsImagePacks } from '../../../hooks/useImagePacks';
|
||||
import { SequenceCardStyle } from '../styles.css';
|
||||
import { SequenceCard } from '../../../components/sequence-card';
|
||||
@@ -76,7 +94,7 @@ function GlobalPackSelector({
|
||||
const removeSelected = (adds: PackAddress[]) => {
|
||||
setSelected((addresses) => {
|
||||
const newAddresses = addresses.filter(
|
||||
(addr) => !adds.find((address) => packAddressEqual(addr, address))
|
||||
(addr) => !adds.find((address) => packAddressEqual(addr, address)),
|
||||
);
|
||||
return newAddresses;
|
||||
});
|
||||
@@ -122,7 +140,7 @@ function GlobalPackSelector({
|
||||
.map((pack) => pack.address)
|
||||
.filter((addr) => addr !== undefined);
|
||||
const allSelected = roomPackAddresses.every((addr) =>
|
||||
selected.find((address) => packAddressEqual(addr, address))
|
||||
selected.find((address) => packAddressEqual(addr, address)),
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -171,7 +189,10 @@ function GlobalPackSelector({
|
||||
<Box alignItems="Center" gap="300">
|
||||
<Avatar size="300" radii="300">
|
||||
{avatarUrl ? (
|
||||
<AuthenticatedAvatarImage style={{ objectFit: 'contain' }} src={avatarUrl} />
|
||||
<AuthenticatedAvatarImage
|
||||
style={{ objectFit: 'contain' }}
|
||||
src={avatarUrl}
|
||||
/>
|
||||
) : (
|
||||
<AvatarFallback>
|
||||
<Icon size="400" src={Icons.Sticker} filled />
|
||||
@@ -250,9 +271,9 @@ export function GlobalPacks({ onViewPack }: GlobalPacksProps) {
|
||||
const nonGlobalPacks = useMemo(
|
||||
() =>
|
||||
roomsImagePack.filter(
|
||||
(pack) => !globalPacks.find((p) => packAddressEqual(pack.address, p.address))
|
||||
(pack) => !globalPacks.find((p) => packAddressEqual(pack.address, p.address)),
|
||||
),
|
||||
[roomsImagePack, globalPacks]
|
||||
[roomsImagePack, globalPacks],
|
||||
);
|
||||
|
||||
const [selectedPacks, setSelectedPacks] = useState<PackAddress[]>([]);
|
||||
@@ -261,9 +282,9 @@ export function GlobalPacks({ onViewPack }: GlobalPacksProps) {
|
||||
const unselectedGlobalPacks = useMemo(
|
||||
() =>
|
||||
nonGlobalPacks.filter(
|
||||
(pack) => !selectedPacks.find((addr) => packAddressEqual(pack.address, addr))
|
||||
(pack) => !selectedPacks.find((addr) => packAddressEqual(pack.address, addr)),
|
||||
),
|
||||
[selectedPacks, nonGlobalPacks]
|
||||
[selectedPacks, nonGlobalPacks],
|
||||
);
|
||||
|
||||
const handleRemove = (address: PackAddress) => {
|
||||
@@ -302,7 +323,7 @@ export function GlobalPacks({ onViewPack }: GlobalPacksProps) {
|
||||
});
|
||||
|
||||
await mx.setAccountData(AccountDataEvent.PoniesEmoteRooms, updatedContent);
|
||||
}, [mx, selectedPacks, removedPacks])
|
||||
}, [mx, selectedPacks, removedPacks]),
|
||||
);
|
||||
|
||||
const resetChanges = useCallback(() => {
|
||||
|
||||
@@ -1,21 +1,10 @@
|
||||
import React, { useState, useCallback } from 'react';
|
||||
import {
|
||||
Box,
|
||||
Text,
|
||||
Button,
|
||||
Input,
|
||||
Spinner,
|
||||
color,
|
||||
toRem,
|
||||
} from 'folds';
|
||||
import { Box, Text, Button, Input, Spinner, color, toRem } from 'folds';
|
||||
import { SequenceCard } from '../../../components/sequence-card';
|
||||
import { SequenceCardStyle } from '../styles.css';
|
||||
import { SettingTile } from '../../../components/setting-tile';
|
||||
import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
||||
import {
|
||||
extractPackName,
|
||||
importTelegramStickerPack,
|
||||
} from '../../../utils/telegramStickerImport';
|
||||
import { extractPackName, importTelegramStickerPack } from '../../../utils/telegramStickerImport';
|
||||
import { getUserImagePack, ImagePack } from '../../../plugins/custom-emoji';
|
||||
|
||||
const TELEGRAM_BOT_TOKEN_KEY = 'cinny_telegram_bot_token';
|
||||
@@ -29,8 +18,8 @@ type TelegramImportProps = {
|
||||
*/
|
||||
export function TelegramImport({ onViewPack }: TelegramImportProps) {
|
||||
const mx = useMatrixClient();
|
||||
const [botToken, setBotToken] = useState(() =>
|
||||
localStorage.getItem(TELEGRAM_BOT_TOKEN_KEY) || ''
|
||||
const [botToken, setBotToken] = useState(
|
||||
() => localStorage.getItem(TELEGRAM_BOT_TOKEN_KEY) || '',
|
||||
);
|
||||
const [packUrl, setPackUrl] = useState('');
|
||||
const [importing, setImporting] = useState(false);
|
||||
@@ -74,7 +63,7 @@ export function TelegramImport({ onViewPack }: TelegramImportProps) {
|
||||
packUrl.trim(),
|
||||
(current, total, status) => {
|
||||
setProgress(status);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
const count = Object.keys(result.content.images || {}).length;
|
||||
@@ -145,7 +134,9 @@ export function TelegramImport({ onViewPack }: TelegramImportProps) {
|
||||
{importing && progress && (
|
||||
<Box gap="200" alignItems="Center">
|
||||
<Spinner size="200" variant="Secondary" />
|
||||
<Text size="T200" priority="300">{progress}</Text>
|
||||
<Text size="T200" priority="300">
|
||||
{progress}
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
|
||||
@@ -7,17 +7,42 @@ import React, {
|
||||
useState,
|
||||
} from 'react';
|
||||
import dayjs from 'dayjs';
|
||||
import { as, Box, Button, Chip, color, config, Header, IconButton, Input, Menu, MenuItem, PopOut, RectCords, Scroll, Switch, Text, toRem } from 'folds';
|
||||
import {
|
||||
as,
|
||||
Box,
|
||||
Button,
|
||||
Chip,
|
||||
color,
|
||||
config,
|
||||
Header,
|
||||
IconButton,
|
||||
Input,
|
||||
Menu,
|
||||
MenuItem,
|
||||
PopOut,
|
||||
RectCords,
|
||||
Scroll,
|
||||
Switch,
|
||||
Text,
|
||||
toRem,
|
||||
} from 'folds';
|
||||
import { useSetAtom } from 'jotai';
|
||||
import { Range } from 'react-range';
|
||||
import { Icon, Icons } from '../../../components/icons';
|
||||
import { HexColorPicker } from 'react-colorful';
|
||||
import { isKeyHotkey } from 'is-hotkey';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { Icon, Icons } from '../../../components/icons';
|
||||
import { Page, PageContent, PageHeader } from '../../../components/page';
|
||||
import { SequenceCard } from '../../../components/sequence-card';
|
||||
import { useSetting } from '../../../state/hooks/settings';
|
||||
import { DateFormat, EmojiStyle, MessageLayout, MessageSpacing, ScrollToLatestBehavior, settingsAtom } from '../../../state/settings';
|
||||
import {
|
||||
DateFormat,
|
||||
EmojiStyle,
|
||||
MessageLayout,
|
||||
MessageSpacing,
|
||||
ScrollToLatestBehavior,
|
||||
settingsAtom,
|
||||
} from '../../../state/settings';
|
||||
import { SettingTile } from '../../../components/setting-tile';
|
||||
import { KeySymbol } from '../../../utils/key-symbol';
|
||||
import { isMacOS } from '../../../utils/user-agent';
|
||||
@@ -51,18 +76,14 @@ const ThemeSelector = as<'div', ThemeSelectorProps>(
|
||||
() => () => {
|
||||
setPreviewId(undefined);
|
||||
},
|
||||
[setPreviewId]
|
||||
[setPreviewId],
|
||||
);
|
||||
|
||||
const clearPreview = () => setPreviewId(undefined);
|
||||
const previewTheme = (theme: Theme) => setPreviewId(theme.id);
|
||||
|
||||
return (
|
||||
<Menu
|
||||
{...props}
|
||||
ref={ref}
|
||||
onMouseLeave={clearPreview}
|
||||
>
|
||||
<Menu {...props} ref={ref} onMouseLeave={clearPreview}>
|
||||
<Box direction="Column" gap="100" style={{ padding: config.space.S100 }}>
|
||||
{themes.map((theme) => (
|
||||
<MenuItem
|
||||
@@ -80,7 +101,7 @@ const ThemeSelector = as<'div', ThemeSelectorProps>(
|
||||
</Box>
|
||||
</Menu>
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
function SelectTheme({ disabled }: { disabled?: boolean }) {
|
||||
@@ -338,7 +359,7 @@ const emojiStyleNames: Record<EmojiStyle, string> = {
|
||||
function SidebarNameplate() {
|
||||
const [sidebarNameplateOpacity, setSidebarNameplateOpacity] = useSetting(
|
||||
settingsAtom,
|
||||
'sidebarNameplateOpacity'
|
||||
'sidebarNameplateOpacity',
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -416,7 +437,7 @@ const EmojiStyleSelector = as<'div', EmojiStyleSelectorProps>(
|
||||
))}
|
||||
</Box>
|
||||
</Menu>
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
function Appearance() {
|
||||
@@ -907,7 +928,7 @@ function Editor() {
|
||||
function Spaces() {
|
||||
const [autoJoinSpaceRooms, setAutoJoinSpaceRooms] = useSetting(
|
||||
settingsAtom,
|
||||
'autoJoinSpaceRooms'
|
||||
'autoJoinSpaceRooms',
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -918,11 +939,7 @@ function Spaces() {
|
||||
title="Auto-Join Space Rooms"
|
||||
description="Automatically join all accessible rooms when joining a space, with notifications set to Mentions & Keywords."
|
||||
after={
|
||||
<Switch
|
||||
variant="Primary"
|
||||
value={autoJoinSpaceRooms}
|
||||
onChange={setAutoJoinSpaceRooms}
|
||||
/>
|
||||
<Switch variant="Primary" value={autoJoinSpaceRooms} onChange={setAutoJoinSpaceRooms} />
|
||||
}
|
||||
/>
|
||||
</SequenceCard>
|
||||
@@ -1072,7 +1089,7 @@ function SelectScrollToLatestBehavior() {
|
||||
const [menuCords, setMenuCords] = useState<RectCords>();
|
||||
const [scrollToLatestBehavior, setScrollToLatestBehavior] = useSetting(
|
||||
settingsAtom,
|
||||
'scrollToLatestBehavior'
|
||||
'scrollToLatestBehavior',
|
||||
);
|
||||
|
||||
const behaviors = [
|
||||
@@ -1148,15 +1165,15 @@ function SelectScrollToLatestBehavior() {
|
||||
function Messages() {
|
||||
const [legacyUsernameColor, setLegacyUsernameColor] = useSetting(
|
||||
settingsAtom,
|
||||
'legacyUsernameColor'
|
||||
'legacyUsernameColor',
|
||||
);
|
||||
const [hideMembershipEvents, setHideMembershipEvents] = useSetting(
|
||||
settingsAtom,
|
||||
'hideMembershipEvents'
|
||||
'hideMembershipEvents',
|
||||
);
|
||||
const [hideNickAvatarEvents, setHideNickAvatarEvents] = useSetting(
|
||||
settingsAtom,
|
||||
'hideNickAvatarEvents'
|
||||
'hideNickAvatarEvents',
|
||||
);
|
||||
const [mediaAutoLoad, setMediaAutoLoad] = useSetting(settingsAtom, 'mediaAutoLoad');
|
||||
const [urlPreview, setUrlPreview] = useSetting(settingsAtom, 'urlPreview');
|
||||
@@ -1227,18 +1244,53 @@ function Messages() {
|
||||
/>
|
||||
</SequenceCard>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Url Preview"
|
||||
after={<Switch variant="Primary" value={urlPreview} onChange={setUrlPreview} />}
|
||||
/>
|
||||
<Box style={{ marginLeft: '2.5rem', marginTop: '0.5rem', marginBottom: '1rem', background: 'rgba(255,255,255,0.045)', borderRadius: '8px', padding: '1.1rem 1.3rem', maxWidth: '36rem', boxShadow: '0 1px 4px 0 rgba(0,0,0,0.07)' }}>
|
||||
<Text size="T200" style={{ color: '#d0d0d0', display: 'block', marginBottom: '0.5rem', lineHeight: 1.6, fontWeight: 400 }}>
|
||||
For ad-free YouTube streaming, install <b>yt-dlp</b> (required for direct playback):
|
||||
</Text>
|
||||
<Box as="pre" style={{ background: '#232323', color: '#fff', borderRadius: '5px', padding: '0.6rem 1rem', fontSize: '1.08em', margin: 0, fontFamily: 'JetBrains Mono, Fira Mono, Menlo, monospace', overflowX: 'auto', width: '100%', textAlign: 'center', letterSpacing: '0.01em' }}>
|
||||
winget install yt-dlp
|
||||
</Box>
|
||||
<SettingTile
|
||||
title="Url Preview"
|
||||
after={<Switch variant="Primary" value={urlPreview} onChange={setUrlPreview} />}
|
||||
/>
|
||||
<Box
|
||||
style={{
|
||||
marginLeft: '2.5rem',
|
||||
marginTop: '0.5rem',
|
||||
marginBottom: '1rem',
|
||||
background: 'rgba(255,255,255,0.045)',
|
||||
borderRadius: '8px',
|
||||
padding: '1.1rem 1.3rem',
|
||||
maxWidth: '36rem',
|
||||
boxShadow: '0 1px 4px 0 rgba(0,0,0,0.07)',
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
size="T200"
|
||||
style={{
|
||||
color: '#d0d0d0',
|
||||
display: 'block',
|
||||
marginBottom: '0.5rem',
|
||||
lineHeight: 1.6,
|
||||
fontWeight: 400,
|
||||
}}
|
||||
>
|
||||
For ad-free YouTube streaming, install <b>yt-dlp</b> (required for direct playback):
|
||||
</Text>
|
||||
<Box
|
||||
as="pre"
|
||||
style={{
|
||||
background: '#232323',
|
||||
color: '#fff',
|
||||
borderRadius: '5px',
|
||||
padding: '0.6rem 1rem',
|
||||
fontSize: '1.08em',
|
||||
margin: 0,
|
||||
fontFamily: 'JetBrains Mono, Fira Mono, Menlo, monospace',
|
||||
overflowX: 'auto',
|
||||
width: '100%',
|
||||
textAlign: 'center',
|
||||
letterSpacing: '0.01em',
|
||||
}}
|
||||
>
|
||||
winget install yt-dlp
|
||||
</Box>
|
||||
</Box>
|
||||
</SequenceCard>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
|
||||
@@ -18,7 +18,7 @@ import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
||||
const getAllMessageDefaultRule = (
|
||||
ruleId: RuleId,
|
||||
encrypted: boolean,
|
||||
oneToOne: boolean
|
||||
oneToOne: boolean,
|
||||
): PushRuleData => {
|
||||
const conditions: PushRuleCondition[] = [];
|
||||
if (oneToOne)
|
||||
@@ -66,7 +66,7 @@ function AllMessagesModeSwitcher({
|
||||
const actions = getModeActions(mode);
|
||||
await mx.setPushRuleActions('global', kind, ruleId, actions);
|
||||
},
|
||||
[mx, getModeActions, kind, ruleId]
|
||||
[mx, getModeActions, kind, ruleId],
|
||||
);
|
||||
|
||||
return <NotificationModeSwitcher pushRule={pushRule} onChange={handleChange} />;
|
||||
@@ -76,7 +76,7 @@ export function AllMessagesNotifications() {
|
||||
const pushRulesEvt = useAccountData(AccountDataEvent.PushRules);
|
||||
const pushRules = useMemo(
|
||||
() => pushRulesEvt?.getContent<IPushRules>() ?? { global: {} },
|
||||
[pushRulesEvt]
|
||||
[pushRulesEvt],
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
@@ -34,8 +34,8 @@ function KeywordInput() {
|
||||
});
|
||||
setKeyword('');
|
||||
},
|
||||
[mx]
|
||||
)
|
||||
[mx],
|
||||
),
|
||||
);
|
||||
const addingKeyword = keywordState.status === AsyncStatus.Loading;
|
||||
|
||||
@@ -113,8 +113,8 @@ function KeywordCross({ pushRule }: PushRulesProps) {
|
||||
const [removeState, remove] = useAsyncCallback(
|
||||
useCallback(
|
||||
() => mx.deletePushRule('global', PushRuleKind.ContentSpecific, pushRule.rule_id),
|
||||
[mx, pushRule]
|
||||
)
|
||||
[mx, pushRule],
|
||||
),
|
||||
);
|
||||
|
||||
const removing = removeState.status === AsyncStatus.Loading;
|
||||
@@ -137,10 +137,10 @@ function KeywordModeSwitcher({ pushRule }: PushRulesProps) {
|
||||
'global',
|
||||
PushRuleKind.ContentSpecific,
|
||||
pushRule.rule_id,
|
||||
actions
|
||||
actions,
|
||||
);
|
||||
},
|
||||
[mx, getModeActions, pushRule]
|
||||
[mx, getModeActions, pushRule],
|
||||
);
|
||||
|
||||
return <NotificationModeSwitcher pushRule={pushRule} onChange={handleChange} />;
|
||||
@@ -150,13 +150,13 @@ export function KeywordMessagesNotifications() {
|
||||
const pushRulesEvt = useAccountData(AccountDataEvent.PushRules);
|
||||
const pushRules = useMemo(
|
||||
() => pushRulesEvt?.getContent<IPushRules>() ?? { global: {} },
|
||||
[pushRulesEvt]
|
||||
[pushRulesEvt],
|
||||
);
|
||||
|
||||
const keywordPushRules = useMemo(() => {
|
||||
const content = pushRules.global.content ?? [];
|
||||
return content.filter(
|
||||
(pushRule) => pushRule.default === false && typeof pushRule.pattern === 'string'
|
||||
(pushRule) => pushRule.default === false && typeof pushRule.pattern === 'string',
|
||||
);
|
||||
}, [pushRules]);
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Box, Button, config, Menu, MenuItem, PopOut, RectCords, Spinner, Text } from 'folds';
|
||||
import { Icon, Icons } from '../../../components/icons';
|
||||
import { IPushRule } from 'matrix-js-sdk';
|
||||
import React, { MouseEventHandler, useMemo, useState } from 'react';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { Icon, Icons } from '../../../components/icons';
|
||||
import { NotificationMode, useNotificationActionsMode } from '../../../hooks/useNotificationMode';
|
||||
import { stopPropagation } from '../../../utils/keyboard';
|
||||
import { AsyncStatus, useAsyncCallback } from '../../../hooks/useAsyncCallback';
|
||||
@@ -17,7 +17,7 @@ const useNotificationModeStr = (): Record<NotificationMode, string> =>
|
||||
[NotificationMode.Notify]: 'Notify Silent',
|
||||
[NotificationMode.NotifyLoud]: 'Notify Loud',
|
||||
}),
|
||||
[]
|
||||
[],
|
||||
);
|
||||
|
||||
type NotificationModeSwitcherProps = {
|
||||
|
||||
@@ -46,9 +46,7 @@ export function Notifications({ requestClose }: NotificationsProps) {
|
||||
direction="Column"
|
||||
gap="400"
|
||||
>
|
||||
<SettingTile
|
||||
description={'This option has been moved to "Account > Block Users" section.'}
|
||||
/>
|
||||
<SettingTile description='This option has been moved to "Account > Block Users" section.' />
|
||||
</SequenceCard>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
@@ -32,7 +32,7 @@ const getDefaultIsUserMention = (userId: string): PushRuleData =>
|
||||
key: 'content.m\\.mentions.user_ids',
|
||||
value: userId,
|
||||
},
|
||||
]
|
||||
],
|
||||
);
|
||||
|
||||
const DefaultContainsDisplayName = makePushRuleData(
|
||||
@@ -43,7 +43,7 @@ const DefaultContainsDisplayName = makePushRuleData(
|
||||
{
|
||||
kind: ConditionKind.ContainsDisplayName,
|
||||
},
|
||||
]
|
||||
],
|
||||
);
|
||||
|
||||
const getDefaultContainsUsername = (username: string) =>
|
||||
@@ -52,7 +52,7 @@ const getDefaultContainsUsername = (username: string) =>
|
||||
RuleId.ContainsUserName,
|
||||
getNotificationModeActions(NotificationMode.NotifyLoud, { highlight: true }),
|
||||
undefined,
|
||||
username
|
||||
username,
|
||||
);
|
||||
|
||||
const DefaultIsRoomMention = makePushRuleData(
|
||||
@@ -69,7 +69,7 @@ const DefaultIsRoomMention = makePushRuleData(
|
||||
kind: ConditionKind.SenderNotificationPermission,
|
||||
key: 'room',
|
||||
},
|
||||
]
|
||||
],
|
||||
);
|
||||
|
||||
const DefaultAtRoomNotification = makePushRuleData(
|
||||
@@ -86,7 +86,7 @@ const DefaultAtRoomNotification = makePushRuleData(
|
||||
kind: ConditionKind.SenderNotificationPermission,
|
||||
key: 'room',
|
||||
},
|
||||
]
|
||||
],
|
||||
);
|
||||
|
||||
type PushRulesProps = {
|
||||
@@ -105,7 +105,7 @@ function MentionModeSwitcher({ ruleId, pushRules, defaultPushRuleData }: PushRul
|
||||
const actions = getModeActions(mode);
|
||||
await mx.setPushRuleActions('global', kind, ruleId, actions);
|
||||
},
|
||||
[mx, getModeActions, kind, ruleId]
|
||||
[mx, getModeActions, kind, ruleId],
|
||||
);
|
||||
|
||||
return <NotificationModeSwitcher pushRule={pushRule} onChange={handleChange} />;
|
||||
@@ -118,7 +118,7 @@ export function SpecialMessagesNotifications() {
|
||||
const pushRulesEvt = useAccountData(AccountDataEvent.PushRules);
|
||||
const pushRules = useMemo(
|
||||
() => pushRulesEvt?.getContent<IPushRules>() ?? { global: {} },
|
||||
[pushRulesEvt]
|
||||
[pushRulesEvt],
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
@@ -46,8 +46,8 @@ function EmailNotification() {
|
||||
kind: null,
|
||||
} as unknown as IPusherRequest);
|
||||
},
|
||||
[mx]
|
||||
)
|
||||
[mx],
|
||||
),
|
||||
);
|
||||
|
||||
const handleChange = (value: boolean) => {
|
||||
@@ -97,7 +97,7 @@ export function SystemNotification() {
|
||||
const [showNotifications, setShowNotifications] = useSetting(settingsAtom, 'showNotifications');
|
||||
const [isNotificationSounds, setIsNotificationSounds] = useSetting(
|
||||
settingsAtom,
|
||||
'isNotificationSounds'
|
||||
'isNotificationSounds',
|
||||
);
|
||||
|
||||
const requestNotificationPermission = async () => {
|
||||
@@ -199,7 +199,7 @@ function AndroidPushNotifications() {
|
||||
lastFailure: s.lastFailure || '',
|
||||
autoStartBlocked: Boolean(s.autoStartBlocked),
|
||||
}
|
||||
: undefined
|
||||
: undefined,
|
||||
);
|
||||
setLoading(false);
|
||||
}, []);
|
||||
@@ -215,16 +215,16 @@ function AndroidPushNotifications() {
|
||||
await refresh();
|
||||
if (!result.success) {
|
||||
setLastError(
|
||||
'Selected distributor but did not get a push endpoint. In ntfy: enable UnifiedPush, allow unrestricted battery, then try Reset again.'
|
||||
'Selected distributor but did not get a push endpoint. In ntfy: enable UnifiedPush, allow unrestricted battery, then try Reset again.',
|
||||
);
|
||||
}
|
||||
}, [refresh])
|
||||
}, [refresh]),
|
||||
);
|
||||
|
||||
const [pingState, ping] = useAsyncCallback(
|
||||
useCallback(async () => {
|
||||
await triggerBackgroundSyncPing('manual-test');
|
||||
}, [])
|
||||
}, []),
|
||||
);
|
||||
|
||||
const isBusy =
|
||||
@@ -251,7 +251,8 @@ function AndroidPushNotifications() {
|
||||
if (status.lastFailure === 'AUTO_START_BLOCKED' || status.autoStartBlocked) {
|
||||
return (
|
||||
<Text as="span" style={{ color: color.Critical.Main }} size="T200">
|
||||
Phone is blocking auto-start for Paarrot. Open App Boot / Auto-start settings, allow Paarrot (and ntfy), then tap Reset.
|
||||
Phone is blocking auto-start for Paarrot. Open App Boot / Auto-start settings, allow
|
||||
Paarrot (and ntfy), then tap Reset.
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
@@ -265,7 +266,8 @@ function AndroidPushNotifications() {
|
||||
if (status.distributors.length === 0) {
|
||||
return (
|
||||
<Text as="span" style={{ color: color.Critical.Main }} size="T200">
|
||||
No UnifiedPush distributor found. Install ntfy from Play Store/F-Droid and enable UnifiedPush in ntfy settings.
|
||||
No UnifiedPush distributor found. Install ntfy from Play Store/F-Droid and enable
|
||||
UnifiedPush in ntfy settings.
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
@@ -291,7 +293,11 @@ function AndroidPushNotifications() {
|
||||
<>
|
||||
{statusDescription}
|
||||
{lastError ? (
|
||||
<Text as="span" style={{ color: color.Critical.Main, display: 'block' }} size="T200">
|
||||
<Text
|
||||
as="span"
|
||||
style={{ color: color.Critical.Main, display: 'block' }}
|
||||
size="T200"
|
||||
>
|
||||
{lastError}
|
||||
</Text>
|
||||
) : null}
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
## Plugin Structure
|
||||
|
||||
Each plugin must be a directory containing at least:
|
||||
|
||||
- `index.js` - Main entry point
|
||||
- `plugin-metadata.json` - Plugin metadata
|
||||
|
||||
### Example Directory Structure
|
||||
|
||||
```
|
||||
my-plugin/
|
||||
├── index.js
|
||||
@@ -38,22 +40,22 @@ Your `index.js` must export a default plugin object with an `onLoad` function:
|
||||
```javascript
|
||||
// index.js
|
||||
module.exports = {
|
||||
name: "My Plugin",
|
||||
version: "1.0.0",
|
||||
name: 'My Plugin',
|
||||
version: '1.0.0',
|
||||
dependencies: {
|
||||
"paarrot.utils": "^1.0.0" // Optional: depend on other plugins
|
||||
'paarrot.utils': '^1.0.0', // Optional: depend on other plugins
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Called when the plugin is loaded
|
||||
* @param {PluginContext} ctx - The plugin context
|
||||
*/
|
||||
onLoad: async (ctx) => {
|
||||
ctx.log('Plugin loaded!');
|
||||
|
||||
|
||||
// Your plugin code here
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Called when the plugin is unloaded (optional)
|
||||
*/
|
||||
@@ -61,13 +63,15 @@ module.exports = {
|
||||
ctx.log('Plugin unloaded!');
|
||||
// Cleanup resources here
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Exports for other plugins to use (optional)
|
||||
*/
|
||||
exports: {
|
||||
myFunction: () => { /* ... */ }
|
||||
}
|
||||
myFunction: () => {
|
||||
/* ... */
|
||||
},
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
@@ -82,32 +86,32 @@ Register slash commands with argument parsing:
|
||||
```javascript
|
||||
// Simple command
|
||||
ctx.commands.register({
|
||||
name: "shrug",
|
||||
run: () => "¯\\_(ツ)_/¯"
|
||||
name: 'shrug',
|
||||
run: () => '¯\\_(ツ)_/¯',
|
||||
});
|
||||
|
||||
// Command with args
|
||||
ctx.commands.register({
|
||||
name: "echo",
|
||||
args: ["text"],
|
||||
run: ({ text }) => text
|
||||
name: 'echo',
|
||||
args: ['text'],
|
||||
run: ({ text }) => text,
|
||||
});
|
||||
|
||||
// Advanced command
|
||||
ctx.commands.register({
|
||||
name: "greet",
|
||||
description: "Greet someone",
|
||||
args: ["name", "greeting"],
|
||||
name: 'greet',
|
||||
description: 'Greet someone',
|
||||
args: ['name', 'greeting'],
|
||||
run: ({ name, greeting }) => {
|
||||
return `${greeting || 'Hello'}, ${name || 'stranger'}!`;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// Execute commands programmatically
|
||||
ctx.commands.execute("shrug", {});
|
||||
ctx.commands.execute('shrug', {});
|
||||
|
||||
// Unregister a command
|
||||
ctx.commands.unregister("mycommand");
|
||||
ctx.commands.unregister('mycommand');
|
||||
```
|
||||
|
||||
### 💬 Messages API
|
||||
@@ -117,26 +121,27 @@ Intercept and modify messages:
|
||||
```javascript
|
||||
// Before send interceptor
|
||||
ctx.messages.onBeforeSend((msg) => {
|
||||
if (msg.content === "brb") {
|
||||
msg.content = "be right back!";
|
||||
if (msg.content === 'brb') {
|
||||
msg.content = 'be right back!';
|
||||
}
|
||||
|
||||
|
||||
// Add prefix
|
||||
msg.content = `[Bot] ${msg.content}`;
|
||||
|
||||
|
||||
// Access metadata
|
||||
msg.metadata = { processed: true };
|
||||
});
|
||||
|
||||
// Receive interceptor
|
||||
ctx.messages.onReceive((msg) => {
|
||||
if (msg.content.includes("@bot")) {
|
||||
if (msg.content.includes('@bot')) {
|
||||
ctx.log('Bot was mentioned!');
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
MessageContext interface:
|
||||
|
||||
```typescript
|
||||
interface MessageContext {
|
||||
content: string;
|
||||
@@ -162,8 +167,8 @@ ctx.ui.registerRenderer('message', (msg, defaultRenderer) => {
|
||||
Register custom renderers:
|
||||
|
||||
```javascript
|
||||
ctx.ui.registerRenderer("message", (msg, defaultRenderer) => {
|
||||
if (msg.type === "image") {
|
||||
ctx.ui.registerRenderer('message', (msg, defaultRenderer) => {
|
||||
if (msg.type === 'image') {
|
||||
return `<img src="${msg.url}" style="border-radius:12px"/>`;
|
||||
}
|
||||
// Fall back to default
|
||||
@@ -171,7 +176,7 @@ ctx.ui.registerRenderer("message", (msg, defaultRenderer) => {
|
||||
});
|
||||
|
||||
// Unregister renderer
|
||||
ctx.ui.unregisterRenderer("message");
|
||||
ctx.ui.unregisterRenderer('message');
|
||||
```
|
||||
|
||||
### ⚙️ Settings API
|
||||
@@ -181,36 +186,36 @@ Define plugin settings with UI:
|
||||
```javascript
|
||||
ctx.settings.define({
|
||||
theme: {
|
||||
type: "select",
|
||||
label: "Theme",
|
||||
description: "Choose your theme",
|
||||
type: 'select',
|
||||
label: 'Theme',
|
||||
description: 'Choose your theme',
|
||||
options: [
|
||||
{ value: "dark", label: "Dark" },
|
||||
{ value: "light", label: "Light" }
|
||||
{ value: 'dark', label: 'Dark' },
|
||||
{ value: 'light', label: 'Light' },
|
||||
],
|
||||
default: "dark"
|
||||
default: 'dark',
|
||||
},
|
||||
spamFilter: {
|
||||
type: "boolean",
|
||||
label: "Spam Filter",
|
||||
description: "Enable spam filtering",
|
||||
default: true
|
||||
type: 'boolean',
|
||||
label: 'Spam Filter',
|
||||
description: 'Enable spam filtering',
|
||||
default: true,
|
||||
},
|
||||
prefix: {
|
||||
type: "string",
|
||||
label: "Command Prefix",
|
||||
default: "!"
|
||||
type: 'string',
|
||||
label: 'Command Prefix',
|
||||
default: '!',
|
||||
},
|
||||
maxMessages: {
|
||||
type: "number",
|
||||
label: "Max Messages",
|
||||
default: 100
|
||||
type: 'number',
|
||||
label: 'Max Messages',
|
||||
default: 100,
|
||||
},
|
||||
accentColor: {
|
||||
type: "color",
|
||||
label: "Accent Color",
|
||||
default: "#6366f1"
|
||||
}
|
||||
type: 'color',
|
||||
label: 'Accent Color',
|
||||
default: '#6366f1',
|
||||
},
|
||||
});
|
||||
|
||||
// Get/set settings
|
||||
@@ -223,22 +228,23 @@ ctx.settings.set('theme', 'light');
|
||||
Listen to raw Matrix events:
|
||||
|
||||
```javascript
|
||||
ctx.matrix.on("m.room.message", (event) => {
|
||||
ctx.matrix.on('m.room.message', (event) => {
|
||||
const content = event.getContent();
|
||||
ctx.log('Message received:', content.body);
|
||||
});
|
||||
|
||||
ctx.matrix.on("Room.timeline", (event) => {
|
||||
ctx.matrix.on('Room.timeline', (event) => {
|
||||
if (event.getType() === 'm.room.member') {
|
||||
ctx.log('Member event:', event.getSender());
|
||||
}
|
||||
});
|
||||
|
||||
// Remove listener
|
||||
ctx.matrix.off("m.room.message", handler);
|
||||
ctx.matrix.off('m.room.message', handler);
|
||||
```
|
||||
|
||||
Common events:
|
||||
|
||||
- `"m.room.message"` - Room messages
|
||||
- `"m.room.member"` - Membership changes
|
||||
- `"Room.timeline"` - Timeline events
|
||||
@@ -274,22 +280,22 @@ Show notifications to users:
|
||||
|
||||
```javascript
|
||||
// Simple notification
|
||||
ctx.notify("Plugin loaded!");
|
||||
ctx.notify('Plugin loaded!');
|
||||
|
||||
// Advanced notification
|
||||
ctx.notify({
|
||||
title: "New Message",
|
||||
body: "You have a new message from Steve",
|
||||
type: "info", // info, success, error, warning
|
||||
title: 'New Message',
|
||||
body: 'You have a new message from Steve',
|
||||
type: 'info', // info, success, error, warning
|
||||
duration: 5000,
|
||||
actions: [
|
||||
{
|
||||
label: "View",
|
||||
label: 'View',
|
||||
action: () => {
|
||||
// Handle action
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
@@ -312,12 +318,12 @@ Use other plugins:
|
||||
|
||||
```javascript
|
||||
// Require another plugin's exports
|
||||
const utils = ctx.require("paarrot.utils");
|
||||
const utils = ctx.require('paarrot.utils');
|
||||
utils.formatDate(new Date());
|
||||
|
||||
// Check if plugin exists
|
||||
try {
|
||||
const plugin = ctx.require("optional.plugin");
|
||||
const plugin = ctx.require('optional.plugin');
|
||||
} catch (err) {
|
||||
ctx.warn('Optional plugin not available');
|
||||
}
|
||||
@@ -339,7 +345,7 @@ const rooms = mx.getRooms();
|
||||
const room = mx.getRoom(roomId);
|
||||
|
||||
// Send messages
|
||||
await mx.sendTextMessage(roomId, "Hello!");
|
||||
await mx.sendTextMessage(roomId, 'Hello!');
|
||||
|
||||
// Full Matrix.js SDK available
|
||||
```
|
||||
@@ -354,9 +360,13 @@ const { useState, useEffect } = ctx.React;
|
||||
// Create custom UI components
|
||||
const MyComponent = () => {
|
||||
const [count, setCount] = useState(0);
|
||||
return ctx.React.createElement('button', {
|
||||
onClick: () => setCount(count + 1)
|
||||
}, `Count: ${count}`);
|
||||
return ctx.React.createElement(
|
||||
'button',
|
||||
{
|
||||
onClick: () => setCount(count + 1),
|
||||
},
|
||||
`Count: ${count}`,
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
@@ -366,54 +376,55 @@ See [`example-plugin/index.js`](../../../../example-plugin/index.js) for a full-
|
||||
|
||||
```javascript
|
||||
module.exports = {
|
||||
name: "Awesome Plugin",
|
||||
version: "1.0.0",
|
||||
|
||||
name: 'Awesome Plugin',
|
||||
version: '1.0.0',
|
||||
|
||||
onLoad: async (ctx) => {
|
||||
// Register commands
|
||||
ctx.commands.register({
|
||||
name: "shrug",
|
||||
run: () => "¯\\_(ツ)_/¯"
|
||||
name: 'shrug',
|
||||
run: () => '¯\\_(ツ)_/¯',
|
||||
});
|
||||
|
||||
|
||||
// Message interceptors
|
||||
ctx.messages.onBeforeSend((msg) => {
|
||||
if (msg.content === "brb") {
|
||||
msg.content = "be right back!";
|
||||
if (msg.content === 'brb') {
|
||||
msg.content = 'be right back!';
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Settings
|
||||
ctx.settings.define({
|
||||
enabled: { type: "boolean", default: true }
|
||||
enabled: { type: 'boolean', default: true },
|
||||
});
|
||||
|
||||
|
||||
// Matrix events
|
||||
ctx.matrix.on("m.room.message", (event) => {
|
||||
ctx.matrix.on('m.room.message', (event) => {
|
||||
ctx.log('Message:', event.getContent().body);
|
||||
});
|
||||
|
||||
|
||||
// Background task
|
||||
ctx.timers.setInterval(() => {
|
||||
ctx.log('Checking for updates...');
|
||||
}, 60000);
|
||||
|
||||
ctx.notify("Plugin loaded!");
|
||||
|
||||
ctx.notify('Plugin loaded!');
|
||||
},
|
||||
|
||||
|
||||
onUnload: async () => {
|
||||
// Cleanup happens automatically
|
||||
},
|
||||
|
||||
|
||||
exports: {
|
||||
version: "1.0.0"
|
||||
}
|
||||
version: '1.0.0',
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
### 1. Error Handling
|
||||
|
||||
Always wrap your code in try-catch blocks:
|
||||
|
||||
```javascript
|
||||
@@ -423,24 +434,28 @@ onLoad: async (ctx) => {
|
||||
} catch (error) {
|
||||
ctx.error('Failed to load:', error);
|
||||
}
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
### 2. Cleanup Resources
|
||||
|
||||
Timers and Matrix handlers are auto-cleaned, but clean up other resources:
|
||||
|
||||
```javascript
|
||||
onUnload: async () => {
|
||||
// Close connections, save state, etc.
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
### 3. Performance
|
||||
|
||||
Don't block the main thread:
|
||||
|
||||
```javascript
|
||||
// Bad
|
||||
for (let i = 0; i < 1000000; i++) { /* ... */ }
|
||||
for (let i = 0; i < 1000000; i++) {
|
||||
/* ... */
|
||||
}
|
||||
|
||||
// Good
|
||||
ctx.timers.setTimeout(() => {
|
||||
@@ -449,26 +464,28 @@ ctx.timers.setTimeout(() => {
|
||||
```
|
||||
|
||||
### 4. Settings Best Practices
|
||||
|
||||
Provide defaults and descriptions:
|
||||
|
||||
```javascript
|
||||
ctx.settings.define({
|
||||
maxRetries: {
|
||||
type: "number",
|
||||
label: "Max Retries",
|
||||
description: "Number of retry attempts",
|
||||
default: 3
|
||||
}
|
||||
type: 'number',
|
||||
label: 'Max Retries',
|
||||
description: 'Number of retry attempts',
|
||||
default: 3,
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
### 5. Logging
|
||||
|
||||
Use ctx.log() instead of console.log():
|
||||
|
||||
```javascript
|
||||
ctx.log('Info'); // Shows in plugin logs panel
|
||||
ctx.log('Info'); // Shows in plugin logs panel
|
||||
ctx.warn('Warning'); // Highlighted as warning
|
||||
ctx.error('Error'); // Highlighted as error
|
||||
ctx.error('Error'); // Highlighted as error
|
||||
```
|
||||
|
||||
## Advanced Patterns
|
||||
@@ -480,13 +497,13 @@ Require and use other plugins:
|
||||
```javascript
|
||||
onLoad: async (ctx) => {
|
||||
try {
|
||||
const utils = ctx.require("paarrot.utils");
|
||||
const utils = ctx.require('paarrot.utils');
|
||||
const formatted = utils.formatDate(new Date());
|
||||
ctx.log('Using utils:', formatted);
|
||||
} catch (err) {
|
||||
ctx.warn('Utils plugin not available, using fallback');
|
||||
}
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
### Conditional Features
|
||||
@@ -496,7 +513,7 @@ Enable features based on settings:
|
||||
```javascript
|
||||
const autoReply = ctx.settings.get('autoReply');
|
||||
if (autoReply) {
|
||||
ctx.matrix.on("m.room.message", (event) => {
|
||||
ctx.matrix.on('m.room.message', (event) => {
|
||||
// Auto-reply logic
|
||||
});
|
||||
}
|
||||
@@ -520,10 +537,10 @@ const lastRun = ctx.settings.get('lastRun');
|
||||
Create multiple commands for the same function:
|
||||
|
||||
```javascript
|
||||
const shrugFn = () => "¯\\_(ツ)_/¯";
|
||||
const shrugFn = () => '¯\\_(ツ)_/¯';
|
||||
|
||||
ctx.commands.register({ name: "shrug", run: shrugFn });
|
||||
ctx.commands.register({ name: "dunno", run: shrugFn });
|
||||
ctx.commands.register({ name: 'shrug', run: shrugFn });
|
||||
ctx.commands.register({ name: 'dunno', run: shrugFn });
|
||||
```
|
||||
|
||||
### Hot Reload Support
|
||||
@@ -581,26 +598,32 @@ To list your plugin in the marketplace:
|
||||
## Debugging
|
||||
|
||||
### Browser Console
|
||||
|
||||
Check the browser console (F12) for plugin logs:
|
||||
|
||||
- `[PluginLoader]` - Plugin loading messages
|
||||
- `[Plugin yourplugin]` - Your plugin's logs
|
||||
|
||||
### Plugin Logs Panel
|
||||
|
||||
View per-plugin logs in Settings → Plugins → Logs (coming soon)
|
||||
|
||||
### Common Issues
|
||||
|
||||
**Plugin won't load:**
|
||||
|
||||
- Check `index.js` exists
|
||||
- Verify `module.exports` is correct
|
||||
- Look for JavaScript syntax errors
|
||||
|
||||
**Command not working:**
|
||||
|
||||
- Ensure command is registered in onLoad
|
||||
- Check command name doesn't conflict
|
||||
- Verify run function returns a value
|
||||
|
||||
**Settings not saving:**
|
||||
|
||||
- Use ctx.settings.set() not localStorage
|
||||
- Check setting key matches defined schema
|
||||
|
||||
|
||||
@@ -5,6 +5,12 @@
|
||||
* All other modules in this folder should import from here rather than
|
||||
* directly from the package so the singleton is guaranteed to be shared.
|
||||
*/
|
||||
import {
|
||||
PluginMarketplaceClient,
|
||||
PluginMarketplaceManager,
|
||||
PluginRegistry,
|
||||
} from '@paarrot/plugin-manager';
|
||||
|
||||
export {
|
||||
PluginMarketplaceClient,
|
||||
PluginMarketplaceManager,
|
||||
@@ -49,15 +55,9 @@ export type {
|
||||
|
||||
export { PluginTab } from '@paarrot/plugin-manager';
|
||||
|
||||
import {
|
||||
PluginMarketplaceClient,
|
||||
PluginMarketplaceManager,
|
||||
PluginRegistry,
|
||||
} from '@paarrot/plugin-manager';
|
||||
|
||||
const PLUGIN_INDEX_URL =
|
||||
import.meta.env.VITE_PLUGIN_INDEX_URL ||
|
||||
`https://raw.githubusercontent.com/Paarrot/Plugin-Directory/refs/heads/main/plugins/index.json?cache_burst=${(Math.random()*256).toString()}`;
|
||||
`https://raw.githubusercontent.com/Paarrot/Plugin-Directory/refs/heads/main/plugins/index.json?cache_burst=${(Math.random() * 256).toString()}`;
|
||||
const PLUGIN_BASE_URL =
|
||||
import.meta.env.VITE_PLUGIN_BASE_URL ||
|
||||
'https://raw.githubusercontent.com/Paarrot/Plugin-Directory/refs/heads/main/plugins/';
|
||||
@@ -79,8 +79,7 @@ function removeThemeStyle(styleId: string): void {
|
||||
/** Shared singleton registry for the entire application. */
|
||||
export const pluginRegistry = new PluginRegistry({
|
||||
storage: localStorage,
|
||||
onThemeRegistered: (themeId, _className, css) =>
|
||||
injectThemeStyle(`plugin-theme-${themeId}`, css),
|
||||
onThemeRegistered: (themeId, _className, css) => injectThemeStyle(`plugin-theme-${themeId}`, css),
|
||||
onThemeUnregistered: (themeId) => removeThemeStyle(`plugin-theme-${themeId}`),
|
||||
});
|
||||
|
||||
@@ -126,7 +125,11 @@ export const pluginMarketplaceManager = new PluginMarketplaceManager({
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await window.electron.plugins.download(plugin.id, plugin.downloadUrl, plugin.name);
|
||||
const result = await window.electron.plugins.download(
|
||||
plugin.id,
|
||||
plugin.downloadUrl,
|
||||
plugin.name,
|
||||
);
|
||||
if (!result.success) {
|
||||
throw new Error(result.error ?? 'Failed to install plugin');
|
||||
}
|
||||
@@ -142,4 +145,4 @@ export const pluginMarketplaceManager = new PluginMarketplaceManager({
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -40,10 +40,7 @@ interface PluginButtonSlotProps {
|
||||
location: UILocation;
|
||||
}
|
||||
|
||||
function renderPluginButtonIcon(button: {
|
||||
icon?: string;
|
||||
lucideIcon?: string;
|
||||
}): React.ReactNode {
|
||||
function renderPluginButtonIcon(button: { icon?: string; lucideIcon?: string }): React.ReactNode {
|
||||
const lucideName =
|
||||
button.lucideIcon ??
|
||||
(typeof button.icon === 'string' && button.icon.startsWith('lucide:')
|
||||
@@ -55,9 +52,12 @@ function renderPluginButtonIcon(button: {
|
||||
}
|
||||
|
||||
if (lucideName) {
|
||||
const IconComponent = (lucide as Record<string, React.ComponentType<{ size?: number; strokeWidth?: number }> | undefined>)[
|
||||
lucideName
|
||||
];
|
||||
const IconComponent = (
|
||||
lucide as Record<
|
||||
string,
|
||||
React.ComponentType<{ size?: number; strokeWidth?: number }> | undefined
|
||||
>
|
||||
)[lucideName];
|
||||
if (IconComponent) {
|
||||
return <IconComponent size={18} strokeWidth={2} aria-hidden />;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ interface PluginLoaderProps {
|
||||
*/
|
||||
export function PluginLoader({ matrixClient, children }: PluginLoaderProps) {
|
||||
console.log('[PluginLoader] Component rendering, matrixClient:', !!matrixClient);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
const loadPlugins = async () => {
|
||||
try {
|
||||
@@ -33,7 +33,10 @@ export function PluginLoader({ matrixClient, children }: PluginLoaderProps) {
|
||||
const pluginsToLoad = await pluginMarketplaceManager.listEnabledPlugins();
|
||||
|
||||
console.log('[PluginLoader] Plugins to load:', pluginsToLoad.length);
|
||||
console.log('[PluginLoader] Plugin list:', pluginsToLoad.map(p => p.id));
|
||||
console.log(
|
||||
'[PluginLoader] Plugin list:',
|
||||
pluginsToLoad.map((p) => p.id),
|
||||
);
|
||||
|
||||
for (const installedPlugin of pluginsToLoad) {
|
||||
try {
|
||||
@@ -44,14 +47,14 @@ export function PluginLoader({ matrixClient, children }: PluginLoaderProps) {
|
||||
|
||||
if (!plugin || typeof plugin !== 'object') {
|
||||
console.error(
|
||||
`[PluginLoader] Plugin ${installedPlugin.id} does not export a valid plugin object`
|
||||
`[PluginLoader] Plugin ${installedPlugin.id} does not export a valid plugin object`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (typeof plugin.onLoad !== 'function') {
|
||||
console.error(
|
||||
`[PluginLoader] Plugin ${installedPlugin.id} does not have an onLoad function`
|
||||
`[PluginLoader] Plugin ${installedPlugin.id} does not have an onLoad function`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
@@ -68,7 +71,7 @@ export function PluginLoader({ matrixClient, children }: PluginLoaderProps) {
|
||||
});
|
||||
},
|
||||
},
|
||||
pluginRegistry
|
||||
pluginRegistry,
|
||||
);
|
||||
|
||||
const compatContext = Object.assign(context as Record<string, unknown>, {
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import React, { useSyncExternalStore } from 'react';
|
||||
import { UILocation } from '@paarrot/plugin-manager';
|
||||
import {
|
||||
SidebarItem,
|
||||
SidebarItemTooltip,
|
||||
SidebarAvatar,
|
||||
} from '../../../components/sidebar';
|
||||
import { SidebarItem, SidebarItemTooltip, SidebarAvatar } from '../../../components/sidebar';
|
||||
import { pluginRegistry } from './PluginAPI';
|
||||
import { subscribeToButtons, getStoreVersion } from './PluginButtonSlot';
|
||||
|
||||
|
||||
@@ -1,8 +1,27 @@
|
||||
import React, { useState, useEffect, useCallback, useMemo } from 'react';
|
||||
import { Avatar, Badge, Box, Button, color, config, Header, IconButton, Input, Menu, MenuItem, PopOut, RectCords, Scroll, Spinner, Switch, Text, toRem } from 'folds';
|
||||
import { Icon, Icons } from '../../../components/icons';
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
Box,
|
||||
Button,
|
||||
color,
|
||||
config,
|
||||
Header,
|
||||
IconButton,
|
||||
Input,
|
||||
Menu,
|
||||
MenuItem,
|
||||
PopOut,
|
||||
RectCords,
|
||||
Scroll,
|
||||
Spinner,
|
||||
Switch,
|
||||
Text,
|
||||
toRem,
|
||||
} from 'folds';
|
||||
import { HexColorPicker } from 'react-colorful';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import { Icon, Icons } from '../../../components/icons';
|
||||
import { Page, PageContent, PageHeader } from '../../../components/page';
|
||||
import { PluginTab, PluginMetadata, InstalledPlugin } from './types';
|
||||
import { SequenceCard } from '../../../components/sequence-card';
|
||||
@@ -22,7 +41,9 @@ function PluginSettingsRenderer({ pluginId }: { pluginId: string }) {
|
||||
if (!schema || Object.keys(schema).length === 0) {
|
||||
return (
|
||||
<Box padding="300">
|
||||
<Text size="T300" priority="300">No settings available for this plugin.</Text>
|
||||
<Text size="T300" priority="300">
|
||||
No settings available for this plugin.
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -65,7 +86,7 @@ function SettingRenderer({
|
||||
const [selectMenuCords, setSelectMenuCords] = useState<RectCords>();
|
||||
|
||||
const label = definition.label || settingKey;
|
||||
const description = definition.description;
|
||||
const { description } = definition;
|
||||
|
||||
// Boolean - Switch
|
||||
if (definition.type === 'boolean') {
|
||||
@@ -111,7 +132,7 @@ function SettingRenderer({
|
||||
// Select - Dropdown
|
||||
if (definition.type === 'select' && definition.options) {
|
||||
const currentValue = value ?? definition.default ?? definition.options[0]?.value;
|
||||
const selectedOption = definition.options.find(opt => opt.value === currentValue);
|
||||
const selectedOption = definition.options.find((opt) => opt.value === currentValue);
|
||||
|
||||
return (
|
||||
<SettingTile title={label} description={description}>
|
||||
@@ -145,7 +166,11 @@ function SettingRenderer({
|
||||
<MenuItem
|
||||
key={option.value}
|
||||
size="300"
|
||||
after={currentValue === option.value ? <Icon size="100" src={Icons.Check} /> : undefined}
|
||||
after={
|
||||
currentValue === option.value ? (
|
||||
<Icon size="100" src={Icons.Check} />
|
||||
) : undefined
|
||||
}
|
||||
radii="300"
|
||||
onClick={() => {
|
||||
onChange(option.value);
|
||||
@@ -277,7 +302,7 @@ export function Plugins({ requestClose }: PluginsProps) {
|
||||
setLoading(false);
|
||||
}
|
||||
},
|
||||
[refreshInstalledPlugins]
|
||||
[refreshInstalledPlugins],
|
||||
);
|
||||
|
||||
const handleUninstall = useCallback(
|
||||
@@ -291,7 +316,7 @@ export function Plugins({ requestClose }: PluginsProps) {
|
||||
setError(err instanceof Error ? err.message : 'Failed to uninstall plugin');
|
||||
}
|
||||
},
|
||||
[refreshInstalledPlugins]
|
||||
[refreshInstalledPlugins],
|
||||
);
|
||||
|
||||
const handleToggleEnabled = useCallback(
|
||||
@@ -313,15 +338,15 @@ export function Plugins({ requestClose }: PluginsProps) {
|
||||
setError(err instanceof Error ? err.message : 'Failed to update plugin state');
|
||||
}
|
||||
},
|
||||
[installedPlugins, refreshInstalledPlugins]
|
||||
[installedPlugins, refreshInstalledPlugins],
|
||||
);
|
||||
|
||||
const isPluginInstalled = useCallback(
|
||||
(pluginId: string) => installedPlugins.some((p) => p.id === pluginId),
|
||||
[installedPlugins]
|
||||
[installedPlugins],
|
||||
);
|
||||
|
||||
const PluginAvatar = ({ thumbnail, name }: { thumbnail: string; name: string }) => {
|
||||
function PluginAvatar({ thumbnail, name }: { thumbnail: string; name: string }) {
|
||||
const [imageError, setImageError] = useState(false);
|
||||
|
||||
return (
|
||||
@@ -356,7 +381,7 @@ export function Plugins({ requestClose }: PluginsProps) {
|
||||
)}
|
||||
</Avatar>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
const filteredMarketplacePlugins = useMemo(() => {
|
||||
if (!searchQuery.trim()) return marketplacePlugins;
|
||||
@@ -468,7 +493,9 @@ export function Plugins({ requestClose }: PluginsProps) {
|
||||
{!loading && !error && filteredMarketplacePlugins.length === 0 && (
|
||||
<Box justifyContent="Center" style={{ padding: toRem(32) }}>
|
||||
<Text size="T400" priority="300">
|
||||
{searchQuery ? 'No plugins found matching your search' : 'No plugins available'}
|
||||
{searchQuery
|
||||
? 'No plugins found matching your search'
|
||||
: 'No plugins available'}
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
@@ -504,7 +531,9 @@ export function Plugins({ requestClose }: PluginsProps) {
|
||||
<Text size="T200" priority="400">
|
||||
by {plugin.author}
|
||||
</Text>
|
||||
<Text size="T200" priority="400">•</Text>
|
||||
<Text size="T200" priority="400">
|
||||
•
|
||||
</Text>
|
||||
<Text size="T200" priority="400">
|
||||
v{plugin.version}
|
||||
</Text>
|
||||
@@ -545,112 +574,127 @@ export function Plugins({ requestClose }: PluginsProps) {
|
||||
{filteredInstalledPlugins.length === 0 && (
|
||||
<Box justifyContent="Center" style={{ padding: toRem(32) }}>
|
||||
<Text size="T400" priority="300">
|
||||
{searchQuery ? 'No installed plugins found matching your search' : 'No plugins installed'}
|
||||
{searchQuery
|
||||
? 'No installed plugins found matching your search'
|
||||
: 'No plugins installed'}
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
{filteredInstalledPlugins.map((plugin) => {
|
||||
const hasSettings = pluginRegistry.getPluginSettingsSchema(plugin.id) &&
|
||||
const hasSettings =
|
||||
pluginRegistry.getPluginSettingsSchema(plugin.id) &&
|
||||
Object.keys(pluginRegistry.getPluginSettingsSchema(plugin.id)!).length > 0;
|
||||
const settingsExpanded = expandedSettings === plugin.id;
|
||||
|
||||
return (
|
||||
<Box
|
||||
key={plugin.id}
|
||||
direction="Column"
|
||||
style={{
|
||||
background: color.Surface.Container,
|
||||
borderRadius: config.radii.R400,
|
||||
border: `1px solid ${color.Surface.ContainerLine}`,
|
||||
transition: 'all 0.2s ease',
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
key={plugin.id}
|
||||
direction="Column"
|
||||
style={{
|
||||
padding: config.space.S500,
|
||||
}}
|
||||
onMouseEnter={(e) => {
|
||||
e.currentTarget.parentElement!.style.transform = 'translateY(-2px)';
|
||||
e.currentTarget.parentElement!.style.boxShadow = '0 4px 12px rgba(0,0,0,0.1)';
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
e.currentTarget.parentElement!.style.transform = 'translateY(0)';
|
||||
e.currentTarget.parentElement!.style.boxShadow = 'none';
|
||||
background: color.Surface.Container,
|
||||
borderRadius: config.radii.R400,
|
||||
border: `1px solid ${color.Surface.ContainerLine}`,
|
||||
transition: 'all 0.2s ease',
|
||||
}}
|
||||
>
|
||||
<Box gap="500" alignItems="Start">
|
||||
<Box shrink="No">
|
||||
<PluginAvatar thumbnail={plugin.thumbnail} name={plugin.name} />
|
||||
</Box>
|
||||
<Box grow="Yes" direction="Column" gap="200">
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="H5">{plugin.name}</Text>
|
||||
<Box gap="200" alignItems="Center">
|
||||
<Text size="T200" priority="400">
|
||||
by {plugin.author}
|
||||
</Text>
|
||||
<Text size="T200" priority="400">•</Text>
|
||||
<Text size="T200" priority="400">
|
||||
v{plugin.version}
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
<Text size="T300" priority="300">
|
||||
{plugin.description}
|
||||
</Text>
|
||||
<Box gap="100" wrap="Wrap">
|
||||
<Badge
|
||||
size="300"
|
||||
variant={plugin.enabled ? 'Success' : 'Secondary'}
|
||||
fill="Soft"
|
||||
>
|
||||
<Text size="L400">{plugin.enabled ? 'Enabled' : 'Disabled'}</Text>
|
||||
</Badge>
|
||||
</Box>
|
||||
</Box>
|
||||
<Box shrink="No" direction="Column" gap="200">
|
||||
{hasSettings && (
|
||||
<Button
|
||||
variant="Secondary"
|
||||
fill="Soft"
|
||||
size="400"
|
||||
before={<Icon size="200" src={Icons.Setting} />}
|
||||
after={<Icon size="200" src={settingsExpanded ? Icons.ChevronTop : Icons.ChevronBottom} />}
|
||||
onClick={() => setExpandedSettings(settingsExpanded ? null : plugin.id)}
|
||||
>
|
||||
<Text size="B400">Settings</Text>
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
variant="Secondary"
|
||||
size="400"
|
||||
onClick={() => handleToggleEnabled(plugin.id)}
|
||||
>
|
||||
<Text size="B400">{plugin.enabled ? 'Disable' : 'Enable'}</Text>
|
||||
</Button>
|
||||
<Button
|
||||
variant="Critical"
|
||||
fill="None"
|
||||
size="400"
|
||||
onClick={() => handleUninstall(plugin.id)}
|
||||
>
|
||||
<Text size="B400">Uninstall</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
{hasSettings && settingsExpanded && (
|
||||
<Box
|
||||
direction="Column"
|
||||
style={{
|
||||
borderTop: `1px solid ${color.Surface.ContainerLine}`,
|
||||
background: color.Surface.ContainerLowest,
|
||||
padding: config.space.S500,
|
||||
}}
|
||||
onMouseEnter={(e) => {
|
||||
e.currentTarget.parentElement!.style.transform = 'translateY(-2px)';
|
||||
e.currentTarget.parentElement!.style.boxShadow =
|
||||
'0 4px 12px rgba(0,0,0,0.1)';
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
e.currentTarget.parentElement!.style.transform = 'translateY(0)';
|
||||
e.currentTarget.parentElement!.style.boxShadow = 'none';
|
||||
}}
|
||||
>
|
||||
<PluginSettingsRenderer pluginId={plugin.id} />
|
||||
<Box gap="500" alignItems="Start">
|
||||
<Box shrink="No">
|
||||
<PluginAvatar thumbnail={plugin.thumbnail} name={plugin.name} />
|
||||
</Box>
|
||||
<Box grow="Yes" direction="Column" gap="200">
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="H5">{plugin.name}</Text>
|
||||
<Box gap="200" alignItems="Center">
|
||||
<Text size="T200" priority="400">
|
||||
by {plugin.author}
|
||||
</Text>
|
||||
<Text size="T200" priority="400">
|
||||
•
|
||||
</Text>
|
||||
<Text size="T200" priority="400">
|
||||
v{plugin.version}
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
<Text size="T300" priority="300">
|
||||
{plugin.description}
|
||||
</Text>
|
||||
<Box gap="100" wrap="Wrap">
|
||||
<Badge
|
||||
size="300"
|
||||
variant={plugin.enabled ? 'Success' : 'Secondary'}
|
||||
fill="Soft"
|
||||
>
|
||||
<Text size="L400">{plugin.enabled ? 'Enabled' : 'Disabled'}</Text>
|
||||
</Badge>
|
||||
</Box>
|
||||
</Box>
|
||||
<Box shrink="No" direction="Column" gap="200">
|
||||
{hasSettings && (
|
||||
<Button
|
||||
variant="Secondary"
|
||||
fill="Soft"
|
||||
size="400"
|
||||
before={<Icon size="200" src={Icons.Setting} />}
|
||||
after={
|
||||
<Icon
|
||||
size="200"
|
||||
src={
|
||||
settingsExpanded ? Icons.ChevronTop : Icons.ChevronBottom
|
||||
}
|
||||
/>
|
||||
}
|
||||
onClick={() =>
|
||||
setExpandedSettings(settingsExpanded ? null : plugin.id)
|
||||
}
|
||||
>
|
||||
<Text size="B400">Settings</Text>
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
variant="Secondary"
|
||||
size="400"
|
||||
onClick={() => handleToggleEnabled(plugin.id)}
|
||||
>
|
||||
<Text size="B400">{plugin.enabled ? 'Disable' : 'Enable'}</Text>
|
||||
</Button>
|
||||
<Button
|
||||
variant="Critical"
|
||||
fill="None"
|
||||
size="400"
|
||||
onClick={() => handleUninstall(plugin.id)}
|
||||
>
|
||||
<Text size="B400">Uninstall</Text>
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
{hasSettings && settingsExpanded && (
|
||||
<Box
|
||||
direction="Column"
|
||||
style={{
|
||||
borderTop: `1px solid ${color.Surface.ContainerLine}`,
|
||||
background: color.Surface.ContainerLowest,
|
||||
}}
|
||||
>
|
||||
<PluginSettingsRenderer pluginId={plugin.id} />
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
})}
|
||||
</Box>
|
||||
|
||||
@@ -14,27 +14,51 @@ export type SettingsSearchEntry = {
|
||||
*/
|
||||
export const SETTINGS_SEARCH_CATALOG: SettingsSearchEntry[] = [
|
||||
// Pages
|
||||
{ page: SettingsPages.GeneralPage, title: 'General', keywords: ['appearance', 'theme', 'messages', 'editor'] },
|
||||
{ page: SettingsPages.AccountPage, title: 'Account', keywords: ['profile', 'email', 'mxid', 'ignore'] },
|
||||
{
|
||||
page: SettingsPages.GeneralPage,
|
||||
title: 'General',
|
||||
keywords: ['appearance', 'theme', 'messages', 'editor'],
|
||||
},
|
||||
{
|
||||
page: SettingsPages.AccountPage,
|
||||
title: 'Account',
|
||||
keywords: ['profile', 'email', 'mxid', 'ignore'],
|
||||
},
|
||||
{
|
||||
page: SettingsPages.NotificationPage,
|
||||
title: 'Notifications',
|
||||
keywords: ['alerts', 'push', 'desktop', 'sound', 'mentions'],
|
||||
},
|
||||
{ page: SettingsPages.AudioPage, title: 'Audio & Video', keywords: ['microphone', 'speaker', 'call', 'camera'] },
|
||||
{ page: SettingsPages.DevicesPage, title: 'Devices', keywords: ['sessions', 'verification', 'backup', 'export'] },
|
||||
{
|
||||
page: SettingsPages.AudioPage,
|
||||
title: 'Audio & Video',
|
||||
keywords: ['microphone', 'speaker', 'call', 'camera'],
|
||||
},
|
||||
{
|
||||
page: SettingsPages.DevicesPage,
|
||||
title: 'Devices',
|
||||
keywords: ['sessions', 'verification', 'backup', 'export'],
|
||||
},
|
||||
{
|
||||
page: SettingsPages.EmojisStickersPage,
|
||||
title: 'Emojis & Stickers',
|
||||
keywords: ['emoticons', 'stickers', 'telegram', 'custom emoji'],
|
||||
},
|
||||
{ page: SettingsPages.PluginsPage, title: 'Plugins', keywords: ['extensions', 'addons', 'marketplace'] },
|
||||
{
|
||||
page: SettingsPages.PluginsPage,
|
||||
title: 'Plugins',
|
||||
keywords: ['extensions', 'addons', 'marketplace'],
|
||||
},
|
||||
{
|
||||
page: SettingsPages.DeveloperToolsPage,
|
||||
title: 'Developer Tools',
|
||||
keywords: ['debug', 'token', 'account data'],
|
||||
},
|
||||
{ page: SettingsPages.AboutPage, title: 'About', keywords: ['version', 'cache', 'protocol', 'paarrot'] },
|
||||
{
|
||||
page: SettingsPages.AboutPage,
|
||||
title: 'About',
|
||||
keywords: ['version', 'cache', 'protocol', 'paarrot'],
|
||||
},
|
||||
|
||||
// General
|
||||
{
|
||||
@@ -43,71 +67,167 @@ export const SETTINGS_SEARCH_CATALOG: SettingsSearchEntry[] = [
|
||||
keywords: ['appearance', 'dark', 'light', 'auto'],
|
||||
},
|
||||
{ page: SettingsPages.GeneralPage, title: 'Theme', keywords: ['appearance', 'color scheme'] },
|
||||
{ page: SettingsPages.GeneralPage, title: 'Monochrome Mode', keywords: ['grayscale', 'appearance'] },
|
||||
{ page: SettingsPages.GeneralPage, title: 'Emoji Style', keywords: ['appearance', 'twemoji', 'native'] },
|
||||
{ page: SettingsPages.GeneralPage, title: 'Page Zoom', keywords: ['scale', 'accessibility', 'size'] },
|
||||
{
|
||||
page: SettingsPages.GeneralPage,
|
||||
title: 'Monochrome Mode',
|
||||
keywords: ['grayscale', 'appearance'],
|
||||
},
|
||||
{
|
||||
page: SettingsPages.GeneralPage,
|
||||
title: 'Emoji Style',
|
||||
keywords: ['appearance', 'twemoji', 'native'],
|
||||
},
|
||||
{
|
||||
page: SettingsPages.GeneralPage,
|
||||
title: 'Page Zoom',
|
||||
keywords: ['scale', 'accessibility', 'size'],
|
||||
},
|
||||
{ page: SettingsPages.GeneralPage, title: 'Date Format', keywords: ['time', 'calendar'] },
|
||||
{ page: SettingsPages.GeneralPage, title: '24-Hour Time Format', keywords: ['clock', 'time'] },
|
||||
{ page: SettingsPages.GeneralPage, title: 'ENTER for Newline', keywords: ['editor', 'keyboard', 'shift enter'] },
|
||||
{ page: SettingsPages.GeneralPage, title: 'Markdown Formatting', keywords: ['editor', 'formatting'] },
|
||||
{
|
||||
page: SettingsPages.GeneralPage,
|
||||
title: 'ENTER for Newline',
|
||||
keywords: ['editor', 'keyboard', 'shift enter'],
|
||||
},
|
||||
{
|
||||
page: SettingsPages.GeneralPage,
|
||||
title: 'Markdown Formatting',
|
||||
keywords: ['editor', 'formatting'],
|
||||
},
|
||||
{
|
||||
page: SettingsPages.GeneralPage,
|
||||
title: 'Hide Typing & Read Receipts',
|
||||
keywords: ['privacy', 'activity', 'typing'],
|
||||
},
|
||||
{ page: SettingsPages.GeneralPage, title: 'Auto-Join Space Rooms', keywords: ['spaces', 'join'] },
|
||||
{ page: SettingsPages.GeneralPage, title: 'Message Layout', keywords: ['bubbles', 'compact', 'modern'] },
|
||||
{
|
||||
page: SettingsPages.GeneralPage,
|
||||
title: 'Message Layout',
|
||||
keywords: ['bubbles', 'compact', 'modern'],
|
||||
},
|
||||
{ page: SettingsPages.GeneralPage, title: 'Message Spacing', keywords: ['density', 'gap'] },
|
||||
{
|
||||
page: SettingsPages.GeneralPage,
|
||||
title: 'Scroll to Latest on Room Reselect',
|
||||
keywords: ['timeline', 'jump'],
|
||||
},
|
||||
{ page: SettingsPages.GeneralPage, title: 'Legacy Username Color', keywords: ['appearance', 'mxid color'] },
|
||||
{ page: SettingsPages.GeneralPage, title: 'Hide Membership Change', keywords: ['joins', 'leaves', 'timeline'] },
|
||||
{ page: SettingsPages.GeneralPage, title: 'Hide Profile Change', keywords: ['avatar', 'displayname', 'timeline'] },
|
||||
{ page: SettingsPages.GeneralPage, title: 'Disable Media Auto Load', keywords: ['images', 'bandwidth', 'lazy'] },
|
||||
{
|
||||
page: SettingsPages.GeneralPage,
|
||||
title: 'Legacy Username Color',
|
||||
keywords: ['appearance', 'mxid color'],
|
||||
},
|
||||
{
|
||||
page: SettingsPages.GeneralPage,
|
||||
title: 'Hide Membership Change',
|
||||
keywords: ['joins', 'leaves', 'timeline'],
|
||||
},
|
||||
{
|
||||
page: SettingsPages.GeneralPage,
|
||||
title: 'Hide Profile Change',
|
||||
keywords: ['avatar', 'displayname', 'timeline'],
|
||||
},
|
||||
{
|
||||
page: SettingsPages.GeneralPage,
|
||||
title: 'Disable Media Auto Load',
|
||||
keywords: ['images', 'bandwidth', 'lazy'],
|
||||
},
|
||||
{ page: SettingsPages.GeneralPage, title: 'Url Preview', keywords: ['link', 'embed', 'unfurl'] },
|
||||
{
|
||||
page: SettingsPages.GeneralPage,
|
||||
title: 'Url Preview in Encrypted Room',
|
||||
keywords: ['e2ee', 'link', 'embed'],
|
||||
},
|
||||
{ page: SettingsPages.GeneralPage, title: 'Show Hidden Events', keywords: ['state', 'debug', 'timeline'] },
|
||||
{
|
||||
page: SettingsPages.GeneralPage,
|
||||
title: 'Show Hidden Events',
|
||||
keywords: ['state', 'debug', 'timeline'],
|
||||
},
|
||||
|
||||
// Account
|
||||
{ page: SettingsPages.AccountPage, title: 'Profile', keywords: ['displayname', 'avatar', 'name'] },
|
||||
{
|
||||
page: SettingsPages.AccountPage,
|
||||
title: 'Profile',
|
||||
keywords: ['displayname', 'avatar', 'name'],
|
||||
},
|
||||
{ page: SettingsPages.AccountPage, title: 'Email Address', keywords: ['contact', 'mail'] },
|
||||
{ page: SettingsPages.AccountPage, title: 'Ignored Users', keywords: ['block', 'mute', 'ignore'] },
|
||||
{
|
||||
page: SettingsPages.AccountPage,
|
||||
title: 'Ignored Users',
|
||||
keywords: ['block', 'mute', 'ignore'],
|
||||
},
|
||||
|
||||
// Notifications
|
||||
{ page: SettingsPages.NotificationPage, title: 'Desktop Notifications', keywords: ['system', 'os'] },
|
||||
{ page: SettingsPages.NotificationPage, title: 'Notification Sound', keywords: ['audio', 'alert'] },
|
||||
{
|
||||
page: SettingsPages.NotificationPage,
|
||||
title: 'Desktop Notifications',
|
||||
keywords: ['system', 'os'],
|
||||
},
|
||||
{
|
||||
page: SettingsPages.NotificationPage,
|
||||
title: 'Notification Sound',
|
||||
keywords: ['audio', 'alert'],
|
||||
},
|
||||
{ page: SettingsPages.NotificationPage, title: 'Email Notification', keywords: ['mail'] },
|
||||
{ page: SettingsPages.NotificationPage, title: 'Background Notifications', keywords: ['tray', 'electron'] },
|
||||
{
|
||||
page: SettingsPages.NotificationPage,
|
||||
title: 'Background Notifications',
|
||||
keywords: ['tray', 'electron'],
|
||||
},
|
||||
{ page: SettingsPages.NotificationPage, title: '1-to-1 Chats', keywords: ['dm', 'direct'] },
|
||||
{ page: SettingsPages.NotificationPage, title: 'Rooms', keywords: ['messages', 'push'] },
|
||||
{ page: SettingsPages.NotificationPage, title: 'Mention @room', keywords: ['highlight', 'ping'] },
|
||||
{ page: SettingsPages.NotificationPage, title: 'Keyword Messages', keywords: ['highlight', 'filter'] },
|
||||
{ page: SettingsPages.NotificationPage, title: 'Special Messages', keywords: ['mentions', 'displayname'] },
|
||||
{ page: SettingsPages.NotificationPage, title: 'Test Notification', keywords: ['preview', 'sound'] },
|
||||
{
|
||||
page: SettingsPages.NotificationPage,
|
||||
title: 'Keyword Messages',
|
||||
keywords: ['highlight', 'filter'],
|
||||
},
|
||||
{
|
||||
page: SettingsPages.NotificationPage,
|
||||
title: 'Special Messages',
|
||||
keywords: ['mentions', 'displayname'],
|
||||
},
|
||||
{
|
||||
page: SettingsPages.NotificationPage,
|
||||
title: 'Test Notification',
|
||||
keywords: ['preview', 'sound'],
|
||||
},
|
||||
|
||||
// Audio & Video
|
||||
{ page: SettingsPages.AudioPage, title: 'Input Device', keywords: ['microphone', 'mic'] },
|
||||
{ page: SettingsPages.AudioPage, title: 'Output Device', keywords: ['speaker', 'headphones'] },
|
||||
{ page: SettingsPages.AudioPage, title: 'Noise Suppression', keywords: ['microphone', 'processing'] },
|
||||
{
|
||||
page: SettingsPages.AudioPage,
|
||||
title: 'Noise Suppression',
|
||||
keywords: ['microphone', 'processing'],
|
||||
},
|
||||
{ page: SettingsPages.AudioPage, title: 'Echo Cancellation', keywords: ['microphone', 'aec'] },
|
||||
{ page: SettingsPages.AudioPage, title: 'Auto Gain Control', keywords: ['microphone', 'agc'] },
|
||||
{ page: SettingsPages.AudioPage, title: 'Resolution', keywords: ['screen share', 'video'] },
|
||||
{ page: SettingsPages.AudioPage, title: 'Bitrate', keywords: ['screen share', 'quality'] },
|
||||
{ page: SettingsPages.AudioPage, title: 'Frame Rate', keywords: ['screen share', 'fps'] },
|
||||
{ page: SettingsPages.AudioPage, title: 'Show Remote Cursor', keywords: ['screen share', 'pointer'] },
|
||||
{
|
||||
page: SettingsPages.AudioPage,
|
||||
title: 'Show Remote Cursor',
|
||||
keywords: ['screen share', 'pointer'],
|
||||
},
|
||||
|
||||
// Devices
|
||||
{ page: SettingsPages.DevicesPage, title: 'Device Verification', keywords: ['crypto', 'cross signing'] },
|
||||
{
|
||||
page: SettingsPages.DevicesPage,
|
||||
title: 'Device Verification',
|
||||
keywords: ['crypto', 'cross signing'],
|
||||
},
|
||||
{ page: SettingsPages.DevicesPage, title: 'Device Dashboard', keywords: ['sessions', 'logout'] },
|
||||
{ page: SettingsPages.DevicesPage, title: 'Export Messages Data', keywords: ['backup', 'download'] },
|
||||
{ page: SettingsPages.DevicesPage, title: 'Import Messages Data', keywords: ['backup', 'restore'] },
|
||||
{
|
||||
page: SettingsPages.DevicesPage,
|
||||
title: 'Export Messages Data',
|
||||
keywords: ['backup', 'download'],
|
||||
},
|
||||
{
|
||||
page: SettingsPages.DevicesPage,
|
||||
title: 'Import Messages Data',
|
||||
keywords: ['backup', 'restore'],
|
||||
},
|
||||
|
||||
// Emojis & Stickers
|
||||
{
|
||||
@@ -115,8 +235,16 @@ export const SETTINGS_SEARCH_CATALOG: SettingsSearchEntry[] = [
|
||||
title: 'Auto-convert Text Emoticons',
|
||||
keywords: ['smileys', 'colon'],
|
||||
},
|
||||
{ page: SettingsPages.EmojisStickersPage, title: 'Telegram Bot Token', keywords: ['stickers', 'import'] },
|
||||
{ page: SettingsPages.EmojisStickersPage, title: 'Sticker Pack URL', keywords: ['telegram', 'import'] },
|
||||
{
|
||||
page: SettingsPages.EmojisStickersPage,
|
||||
title: 'Telegram Bot Token',
|
||||
keywords: ['stickers', 'import'],
|
||||
},
|
||||
{
|
||||
page: SettingsPages.EmojisStickersPage,
|
||||
title: 'Sticker Pack URL',
|
||||
keywords: ['telegram', 'import'],
|
||||
},
|
||||
|
||||
// Developer Tools
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user