mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 17:11:17 -08:00
chore: fix oxlint diagnostics
This commit is contained in:
53 files changed
+801
-390
No files matched your search
Vendored
+3
-1
@@ -4,7 +4,6 @@
|
||||
},
|
||||
"editor.formatOnSave": true,
|
||||
"editor.defaultFormatter": "oxc.oxc-vscode",
|
||||
"oxc.fmt.configPath": "oxfmt.config.ts",
|
||||
"oxc.typeAware": true,
|
||||
"js/ts.tsdk.path": "node_modules/typescript/lib",
|
||||
"[jsonc]": {
|
||||
@@ -12,5 +11,8 @@
|
||||
},
|
||||
"[json]": {
|
||||
"editor.defaultFormatter": "oxc.oxc-vscode"
|
||||
},
|
||||
"[typescript]": {
|
||||
"editor.defaultFormatter": "oxc.oxc-vscode"
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@
|
||||
},
|
||||
"ignoreDependencies": [
|
||||
"buffer",
|
||||
"@e18e/eslint-plugin",
|
||||
"@sableclient/twemoji-font",
|
||||
"@sableclient/sable-call-embedded",
|
||||
"@matrix-org/matrix-sdk-crypto-wasm"
|
||||
|
||||
+18
-1
@@ -5,6 +5,7 @@ export default defineConfig({
|
||||
typeAware: true,
|
||||
},
|
||||
plugins: ['react', 'jsx-a11y', 'typescript', 'import', 'unicorn', 'oxc', 'vitest', 'promise'],
|
||||
jsPlugins: ['@e18e/eslint-plugin'],
|
||||
categories: {
|
||||
correctness: 'error',
|
||||
suspicious: 'warn',
|
||||
@@ -22,7 +23,6 @@ export default defineConfig({
|
||||
'no-console': ['error', { allow: ['warn', 'error'] }],
|
||||
'react/react-in-jsx-scope': 'off',
|
||||
'react/jsx-filename-extension': ['error', { extensions: ['.tsx', '.jsx'] }],
|
||||
'react/rules-of-hooks': 'error',
|
||||
'react/exhaustive-deps': 'error',
|
||||
'react/iframe-missing-sandbox': 'off',
|
||||
'jsx-a11y/no-autofocus': 'off',
|
||||
@@ -35,6 +35,23 @@ export default defineConfig({
|
||||
'typescript/no-unnecessary-type-arguments': 'off',
|
||||
'oxc/no-map-spread': 'off',
|
||||
'promise/always-return': 'off',
|
||||
'e18e/ban-dependencies': 'error',
|
||||
'e18e/prefer-array-at': 'error',
|
||||
'e18e/prefer-array-fill': 'error',
|
||||
'e18e/prefer-array-from-map': 'error',
|
||||
'e18e/prefer-array-some': 'error',
|
||||
'e18e/prefer-array-to-reversed': 'error',
|
||||
'e18e/prefer-array-to-sorted': 'error',
|
||||
'e18e/prefer-array-to-spliced': 'error',
|
||||
'e18e/prefer-date-now': 'error',
|
||||
'e18e/prefer-includes': 'error',
|
||||
'e18e/prefer-nullish-coalescing': 'error',
|
||||
'e18e/prefer-object-has-own': 'error',
|
||||
'e18e/prefer-regex-test': 'error',
|
||||
'e18e/prefer-spread-syntax': 'error',
|
||||
'e18e/prefer-static-regex': 'off',
|
||||
'e18e/prefer-timer-args': 'error',
|
||||
'e18e/prefer-url-canparse': 'error',
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
|
||||
+4
-3
@@ -97,6 +97,7 @@
|
||||
"workbox-precaching": "^7.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@e18e/eslint-plugin": "^0.3.0",
|
||||
"@rollup/plugin-inject": "^5.0.5",
|
||||
"@rollup/plugin-wasm": "^6.2.2",
|
||||
"@sableclient/sable-call-embedded": "v1.1.4",
|
||||
@@ -118,9 +119,9 @@
|
||||
"buffer": "^6.0.3",
|
||||
"jsdom": "^29.0.0",
|
||||
"knip": "5.85.0",
|
||||
"oxfmt": "^0.45.0",
|
||||
"oxlint": "^1.60.0",
|
||||
"oxlint-tsgolint": "^0.21.0",
|
||||
"oxfmt": "^0.46.0",
|
||||
"oxlint": "^1.61.0",
|
||||
"oxlint-tsgolint": "^0.21.1",
|
||||
"typescript": "^5.9.3",
|
||||
"vite": "^8.0.3",
|
||||
"vite-plugin-compression2": "2.5.3",
|
||||
|
||||
Generated
+592
-192
File diff suppressed because it is too large.
Load diff
@@ -182,7 +182,7 @@ const logger = new PrefixedLogger('[postinstall:knope]');
|
||||
const { dim, red, green } = createTextHelpers({ useColor: logger.useColor });
|
||||
|
||||
if (process.env.GITHUB_ACTIONS && process.env.CI) {
|
||||
logger.info(`${dim('Running in CI environment, skipping knope installation')}`);
|
||||
logger.info(dim('Running in CI environment, skipping knope installation'));
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -233,7 +233,7 @@ function collectReplacements(sourceFile, checker) {
|
||||
}
|
||||
|
||||
visit(sourceFile);
|
||||
return replacements.sort((left, right) => right.start - left.start);
|
||||
return replacements.toSorted((left, right) => right.start - left.start);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
@@ -260,6 +260,7 @@ async function main() {
|
||||
const { dim, green } = createTextHelpers();
|
||||
|
||||
const changes = [];
|
||||
const writePromises = [];
|
||||
|
||||
for (const sourceFile of program.getSourceFiles()) {
|
||||
const filePath = path.normalize(sourceFile.fileName);
|
||||
@@ -272,7 +273,7 @@ async function main() {
|
||||
const updatedCode = applyTextReplacements(originalCode, replacements);
|
||||
|
||||
if (write) {
|
||||
await fs.writeFile(filePath, updatedCode, 'utf8');
|
||||
writePromises.push(fs.writeFile(filePath, updatedCode, 'utf8'));
|
||||
}
|
||||
|
||||
changes.push({
|
||||
@@ -281,8 +282,10 @@ async function main() {
|
||||
});
|
||||
}
|
||||
|
||||
await Promise.all(writePromises);
|
||||
|
||||
changes
|
||||
.sort((left, right) => left.file.localeCompare(right.file))
|
||||
.toSorted((left, right) => left.file.localeCompare(right.file))
|
||||
.forEach((change) => {
|
||||
console.log(
|
||||
`${dim(change.file)}: ${green(`${change.replacements} matrix import rewrite(s)`)}`
|
||||
|
||||
@@ -22,7 +22,7 @@ export const ANSI = {
|
||||
export function shouldUseColor() {
|
||||
if (process.env.NO_COLOR !== undefined) return false;
|
||||
if (process.env.FORCE_COLOR && process.env.FORCE_COLOR !== '0') return true;
|
||||
return Boolean(process.stdout.isTTY);
|
||||
return process.stdout.isTTY;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -62,7 +62,7 @@ export function GlobalKeyboardShortcuts() {
|
||||
} else {
|
||||
const parents = roomToParents.get(roomId);
|
||||
if (parents && parents.size > 0) {
|
||||
const spaceId = Array.from(parents)[0];
|
||||
const spaceId = [...parents].at(0);
|
||||
if (!spaceId) {
|
||||
navigate(getHomeRoomPath(roomIdOrAliasToNav));
|
||||
return;
|
||||
@@ -90,7 +90,7 @@ export function GlobalKeyboardShortcuts() {
|
||||
if (unreadEntries.length === 0) return;
|
||||
evt.preventDefault();
|
||||
unreadIndexRef.current = 0;
|
||||
const [roomId] = unreadEntries[0]!;
|
||||
const [roomId] = unreadEntries[0];
|
||||
navigateToRoom(roomId, unreadEntries.length - 1);
|
||||
},
|
||||
[roomToUnread, currentRoom?.roomId, navigateToRoom]
|
||||
|
||||
@@ -121,7 +121,7 @@ function RenderMessageContentInternal({
|
||||
}));
|
||||
const mediaLinks = analyzed.filter((item) => item.type !== null);
|
||||
const previewCandidates = mediaLinks.length > 0 ? mediaLinks : analyzed;
|
||||
const toRender = multiplePreviews ? previewCandidates : [previewCandidates[0]!];
|
||||
const toRender = multiplePreviews ? previewCandidates : [previewCandidates[0]];
|
||||
return (
|
||||
<UrlPreviewHolder>
|
||||
{toRender.map((item) => {
|
||||
|
||||
@@ -380,7 +380,7 @@ describe('CustomEditor', () => {
|
||||
let resizeObserverCallback: ResizeObserverCallback | undefined;
|
||||
const observedElements = new Set<Element>();
|
||||
const flushQueuedFrames = () => {
|
||||
const pendingFrames = Array.from(queuedFrames.entries());
|
||||
const pendingFrames = [...queuedFrames.entries()];
|
||||
queuedFrames.clear();
|
||||
pendingFrames.forEach(([, callback]) => {
|
||||
callback(performance.now());
|
||||
@@ -421,7 +421,7 @@ describe('CustomEditor', () => {
|
||||
|
||||
act(() => {
|
||||
resizeObserverCallback?.(
|
||||
Array.from(observedElements).map((target) => ({ target }) as ResizeObserverEntry),
|
||||
Array.from(observedElements, (target) => ({ target }) as ResizeObserverEntry),
|
||||
{} as ResizeObserver
|
||||
);
|
||||
});
|
||||
@@ -489,7 +489,7 @@ describe('CustomEditor', () => {
|
||||
const flushQueuedFrames = () => {
|
||||
let safetyCounter = 0;
|
||||
while (queuedFrames.size > 0 && safetyCounter < 10) {
|
||||
const pendingFrames = Array.from(queuedFrames.entries());
|
||||
const pendingFrames = [...queuedFrames.entries()];
|
||||
queuedFrames.clear();
|
||||
pendingFrames.forEach(([, callback]) => {
|
||||
callback(performance.now());
|
||||
@@ -529,7 +529,7 @@ describe('CustomEditor', () => {
|
||||
|
||||
act(() => {
|
||||
resizeObserverCallback?.(
|
||||
Array.from(observedElements).map((target) => ({ target }) as ResizeObserverEntry),
|
||||
Array.from(observedElements, (target) => ({ target }) as ResizeObserverEntry),
|
||||
{} as ResizeObserver
|
||||
);
|
||||
});
|
||||
|
||||
@@ -100,7 +100,7 @@ export function EmoticonAutocomplete({
|
||||
useKeyDown(window, (evt: KeyboardEvent) => {
|
||||
onTabPress(evt, () => {
|
||||
if (autoCompleteEmoticon.length === 0) return;
|
||||
const emoticon = autoCompleteEmoticon[0]!;
|
||||
const emoticon = autoCompleteEmoticon[0];
|
||||
const key = 'url' in emoticon ? emoticon.url : emoticon.unicode;
|
||||
handleAutocomplete(key, emoticon.shortcode);
|
||||
});
|
||||
|
||||
@@ -133,7 +133,7 @@ export function RoomMentionAutocomplete({
|
||||
const rId = autoCompleteRoomIds[0];
|
||||
const r = mx.getRoom(rId);
|
||||
const name = r?.name ?? rId;
|
||||
handleAutocomplete(r?.getCanonicalAlias() ?? rId ?? '', name as string);
|
||||
handleAutocomplete(r?.getCanonicalAlias() ?? rId ?? '', name);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ export function UserMentionAutocomplete({
|
||||
handleAutocomplete(userId, userId);
|
||||
return;
|
||||
}
|
||||
const roomMember = autoCompleteMembers[0]!;
|
||||
const roomMember = autoCompleteMembers[0];
|
||||
handleAutocomplete(roomMember.userId, getName(roomMember));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -227,7 +227,7 @@ const parseCodeBlockNode = (node: Element): CodeBlockElement[] | ParagraphElemen
|
||||
type: BlockType.Paragraph,
|
||||
children: [{ text }],
|
||||
}));
|
||||
const childCode = node.children[0]!;
|
||||
const childCode = node.children[0];
|
||||
const className =
|
||||
isTag(childCode) && childCode.tagName === 'code' ? (childCode.attribs.class ?? '') : '';
|
||||
const prefix = { text: `${mdSequence}${className.replace('language-', '')}` };
|
||||
@@ -329,7 +329,7 @@ const parseHeadingNode = (
|
||||
|
||||
const headingMatch = node.name.match(/^h([123456])$/);
|
||||
const [, g1AsLevel] = headingMatch ?? ['h3', '3'];
|
||||
const level = Number.parseInt(g1AsLevel!, 10);
|
||||
const level = Number.parseInt(g1AsLevel, 10);
|
||||
|
||||
const mdSequence = node.attribs['data-md'];
|
||||
if (mdSequence !== undefined) {
|
||||
|
||||
@@ -83,7 +83,7 @@ export const toggleKeyboardShortcut = (editor: Editor, event: KeyboardEvent): bo
|
||||
const blockToggled = BLOCK_KEYS.find((hotkey) => {
|
||||
if (isKeyHotkey(hotkey, event)) {
|
||||
event.preventDefault();
|
||||
toggleBlock(editor, BLOCK_HOTKEYS[hotkey]!);
|
||||
toggleBlock(editor, BLOCK_HOTKEYS[hotkey]);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -107,7 +107,7 @@ export const toggleKeyboardShortcut = (editor: Editor, event: KeyboardEvent): bo
|
||||
: INLINE_KEYS.find((hotkey) => {
|
||||
if (isKeyHotkey(hotkey, event)) {
|
||||
event.preventDefault();
|
||||
toggleMark(editor, INLINE_HOTKEYS[hotkey]!);
|
||||
toggleMark(editor, INLINE_HOTKEYS[hotkey]);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -601,7 +601,7 @@ export function EmojiBoard({
|
||||
}}
|
||||
>
|
||||
{vItems.map((vItem) => {
|
||||
const group = groups[vItem.index]!;
|
||||
const group = groups[vItem.index];
|
||||
|
||||
return (
|
||||
<VirtualTile
|
||||
|
||||
@@ -74,7 +74,7 @@ export const EventHistory = as<'div', EventHistoryProps>(
|
||||
const spoilerClickHandler = useSpoilerClickHandler();
|
||||
const htmlReactParserOptions = useMemo<HTMLReactParserOptions>(
|
||||
() =>
|
||||
getReactCustomHtmlParser(mx, mEvents[0]!.getRoomId(), {
|
||||
getReactCustomHtmlParser(mx, mEvents[0].getRoomId(), {
|
||||
settingsLinkBaseUrl,
|
||||
linkifyOpts,
|
||||
useAuthentication,
|
||||
|
||||
@@ -74,7 +74,7 @@ function splitBodyTextByAbbreviations(
|
||||
}
|
||||
const result = segments as TextSegment[];
|
||||
for (let i = 0; i < result.length; i += 1) {
|
||||
result[i]!.id = `txt-${i}`;
|
||||
result[i].id = `txt-${i}`;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ export const PowerSelector = forwardRef<HTMLDivElement, PowerSelectorProps>(
|
||||
aria-pressed={selected}
|
||||
radii="300"
|
||||
onClick={selected ? undefined : () => onChange(power)}
|
||||
before={<PowerColorBadge color={tag!.color} />}
|
||||
before={<PowerColorBadge color={tag.color} />}
|
||||
after={<Text size="L400">{power}</Text>}
|
||||
>
|
||||
<Text style={{ flexGrow: 1 }} size="B400" truncate>
|
||||
{tag!.name}
|
||||
{tag.name}
|
||||
</Text>
|
||||
</MenuItem>
|
||||
);
|
||||
|
||||
@@ -252,7 +252,7 @@ export function PowerChip({ userId }: { userId: string }) {
|
||||
</CutoutCard>
|
||||
)}
|
||||
{getPowers(powerLevelTags).map((power) => {
|
||||
const powerTag = powerLevelTags[power]!;
|
||||
const powerTag = powerLevelTags[power];
|
||||
const powerTagIconSrc =
|
||||
powerTag.icon && getPowerTagIconSrc(mx, useAuthentication, powerTag.icon);
|
||||
|
||||
|
||||
@@ -477,87 +477,85 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) {
|
||||
</Text>
|
||||
</Box>
|
||||
</MenuItem>
|
||||
{Array.from(roomState.keys())
|
||||
.toSorted()
|
||||
.map((eventType) => {
|
||||
const expanded = eventType === expandStateType;
|
||||
const stateKeyToEvents = roomState.get(eventType);
|
||||
if (!stateKeyToEvents) return null;
|
||||
{[...roomState.keys()].toSorted().map((eventType) => {
|
||||
const expanded = eventType === expandStateType;
|
||||
const stateKeyToEvents = roomState.get(eventType);
|
||||
if (!stateKeyToEvents) return null;
|
||||
|
||||
return (
|
||||
<Box id={eventType} key={eventType} direction="Column" gap="100">
|
||||
<MenuItem
|
||||
onClick={() =>
|
||||
setExpandStateType(expanded ? undefined : eventType)
|
||||
}
|
||||
variant="Surface"
|
||||
fill="None"
|
||||
size="300"
|
||||
radii="0"
|
||||
before={
|
||||
<Icon
|
||||
size="50"
|
||||
src={expanded ? Icons.ChevronBottom : Icons.ChevronRight}
|
||||
/>
|
||||
}
|
||||
after={<Text size="L400">{stateKeyToEvents.size}</Text>}
|
||||
return (
|
||||
<Box id={eventType} key={eventType} direction="Column" gap="100">
|
||||
<MenuItem
|
||||
onClick={() =>
|
||||
setExpandStateType(expanded ? undefined : eventType)
|
||||
}
|
||||
variant="Surface"
|
||||
fill="None"
|
||||
size="300"
|
||||
radii="0"
|
||||
before={
|
||||
<Icon
|
||||
size="50"
|
||||
src={expanded ? Icons.ChevronBottom : Icons.ChevronRight}
|
||||
/>
|
||||
}
|
||||
after={<Text size="L400">{stateKeyToEvents.size}</Text>}
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="T200" truncate>
|
||||
{eventType}
|
||||
</Text>
|
||||
</Box>
|
||||
</MenuItem>
|
||||
{expanded && (
|
||||
<div
|
||||
style={{
|
||||
marginLeft: config.space.S400,
|
||||
borderLeft: `${config.borderWidth.B300} solid ${color.Surface.ContainerLine}`,
|
||||
}}
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="T200" truncate>
|
||||
{eventType}
|
||||
</Text>
|
||||
</Box>
|
||||
</MenuItem>
|
||||
{expanded && (
|
||||
<div
|
||||
style={{
|
||||
marginLeft: config.space.S400,
|
||||
borderLeft: `${config.borderWidth.B300} solid ${color.Surface.ContainerLine}`,
|
||||
}}
|
||||
<MenuItem
|
||||
onClick={() =>
|
||||
setComposeEvent({ type: eventType, stateKey: '' })
|
||||
}
|
||||
variant="Surface"
|
||||
fill="None"
|
||||
size="300"
|
||||
radii="0"
|
||||
before={<Icon size="50" src={Icons.Plus} />}
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="T200" truncate>
|
||||
Add New
|
||||
</Text>
|
||||
</Box>
|
||||
</MenuItem>
|
||||
{[...stateKeyToEvents.keys()].toSorted().map((stateKey) => (
|
||||
<MenuItem
|
||||
onClick={() =>
|
||||
setComposeEvent({ type: eventType, stateKey: '' })
|
||||
}
|
||||
onClick={() => {
|
||||
setOpenStateEvent({
|
||||
type: eventType,
|
||||
stateKey,
|
||||
});
|
||||
}}
|
||||
key={stateKey}
|
||||
variant="Surface"
|
||||
fill="None"
|
||||
size="300"
|
||||
radii="0"
|
||||
before={<Icon size="50" src={Icons.Plus} />}
|
||||
after={<Icon size="50" src={Icons.ChevronRight} />}
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="T200" truncate>
|
||||
Add New
|
||||
{stateKey ? `"${stateKey}"` : 'Default'}
|
||||
</Text>
|
||||
</Box>
|
||||
</MenuItem>
|
||||
{[...stateKeyToEvents.keys()].sort().map((stateKey) => (
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
setOpenStateEvent({
|
||||
type: eventType,
|
||||
stateKey,
|
||||
});
|
||||
}}
|
||||
key={stateKey}
|
||||
variant="Surface"
|
||||
fill="None"
|
||||
size="300"
|
||||
radii="0"
|
||||
after={<Icon size="50" src={Icons.ChevronRight} />}
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="T200" truncate>
|
||||
{stateKey ? `"${stateKey}"` : 'Default'}
|
||||
</Text>
|
||||
</Box>
|
||||
</MenuItem>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
})}
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
})}
|
||||
</CutoutCard>
|
||||
</Box>
|
||||
)}
|
||||
@@ -612,25 +610,23 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) {
|
||||
</Text>
|
||||
</Box>
|
||||
</MenuItem>
|
||||
{Array.from(accountData.keys())
|
||||
.toSorted()
|
||||
.map((type) => (
|
||||
<MenuItem
|
||||
key={type}
|
||||
variant="Surface"
|
||||
fill="None"
|
||||
size="300"
|
||||
radii="0"
|
||||
after={<Icon size="50" src={Icons.ChevronRight} />}
|
||||
onClick={() => setAccountDataType(type)}
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="T200" truncate>
|
||||
{type}
|
||||
</Text>
|
||||
</Box>
|
||||
</MenuItem>
|
||||
))}
|
||||
{[...accountData.keys()].toSorted().map((type) => (
|
||||
<MenuItem
|
||||
key={type}
|
||||
variant="Surface"
|
||||
fill="None"
|
||||
size="300"
|
||||
radii="0"
|
||||
after={<Icon size="50" src={Icons.ChevronRight} />}
|
||||
onClick={() => setAccountDataType(type)}
|
||||
>
|
||||
<Box grow="Yes">
|
||||
<Text size="T200" truncate>
|
||||
{type}
|
||||
</Text>
|
||||
</Box>
|
||||
</MenuItem>
|
||||
))}
|
||||
</CutoutCard>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
@@ -89,7 +89,7 @@ export function Members({ requestClose }: MembersProps) {
|
||||
|
||||
const sortedMembers = useMemo(
|
||||
() =>
|
||||
Array.from(members)
|
||||
[...members]
|
||||
.filter(membershipFilter.filterFn)
|
||||
.toSorted(memberSort.sortFn)
|
||||
.sort(memberPowerSort),
|
||||
@@ -296,7 +296,7 @@ export function Members({ requestClose }: MembersProps) {
|
||||
gap="100"
|
||||
>
|
||||
{virtualizer.getVirtualItems().map((vItem) => {
|
||||
const tagOrMember = flattenTagMembers[vItem.index]!;
|
||||
const tagOrMember = flattenTagMembers[vItem.index];
|
||||
|
||||
if ('userId' in tagOrMember) {
|
||||
const server = getMxIdServer(tagOrMember.userId);
|
||||
|
||||
@@ -167,7 +167,7 @@ export function Powers({ powerLevels, permissionGroups, onEdit }: PowersProps) {
|
||||
<SettingTile>
|
||||
<Box gap="200" wrap="Wrap">
|
||||
{getPowers(powerLevelTags).map((power) => {
|
||||
const tag = powerLevelTags[power]!;
|
||||
const tag = powerLevelTags[power];
|
||||
const tagIconSrc = tag.icon && getPowerTagIconSrc(mx, useAuthentication, tag.icon);
|
||||
|
||||
return (
|
||||
|
||||
@@ -437,7 +437,7 @@ export function PowersEditor({ powerLevels, requestClose }: Readonly<PowersEdito
|
||||
)}
|
||||
</SequenceCard>
|
||||
{getPowers(powerTags).map((power) => {
|
||||
const tag = powerTags[power]!;
|
||||
const tag = powerTags[power];
|
||||
const tagIconSrc =
|
||||
tag.icon && getPowerTagIconSrc(mx, useAuthentication, tag.icon);
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ export const useDnDMonitor = (
|
||||
onDragging(undefined);
|
||||
const { dropTargets } = location.current;
|
||||
if (dropTargets.length === 0) return;
|
||||
onReorder(source.data as HierarchyItem, dropTargets[0]!.data as DropContainerData);
|
||||
onReorder(source.data as HierarchyItem, dropTargets[0].data as DropContainerData);
|
||||
},
|
||||
}),
|
||||
autoScrollForElements({
|
||||
|
||||
@@ -134,7 +134,7 @@ function SelectRoomButton({ roomList, selectedRooms, onChange }: SelectRoomButto
|
||||
getRoomNameStr,
|
||||
SEARCH_OPTS
|
||||
);
|
||||
const rooms = Array.from(searchResult?.items ?? roomList).toSorted(factoryRoomIdByAtoZ(mx));
|
||||
const rooms = [...(searchResult?.items ?? roomList)].toSorted(factoryRoomIdByAtoZ(mx));
|
||||
|
||||
const virtualizer = useVirtualizer({
|
||||
count: rooms.length,
|
||||
@@ -244,7 +244,7 @@ function SelectRoomButton({ roomList, selectedRooms, onChange }: SelectRoomButto
|
||||
}}
|
||||
>
|
||||
{vItems.map((vItem) => {
|
||||
const roomId = rooms[vItem.index]!;
|
||||
const roomId = rooms[vItem.index];
|
||||
const room = mx.getRoom(roomId);
|
||||
if (!room) return null;
|
||||
const selected = localSelected?.includes(roomId);
|
||||
|
||||
@@ -72,7 +72,7 @@ export function RoomAbbreviations({ requestClose, isSpace }: AbbreviationsProps)
|
||||
type SpaceEntryGroup = { spaceId: string; spaceName: string; entries: AbbreviationEntry[] };
|
||||
const ancestorGroups = useMemo((): SpaceEntryGroup[] => {
|
||||
void ancestorUpdateCount;
|
||||
return Array.from(getAllParents(roomToParents, room.roomId)).reduce<SpaceEntryGroup[]>(
|
||||
return [...getAllParents(roomToParents, room.roomId)].reduce<SpaceEntryGroup[]>(
|
||||
(groups, parentId) => {
|
||||
const parentRoom = mx.getRoom(parentId);
|
||||
if (!parentRoom) return groups;
|
||||
|
||||
@@ -68,7 +68,7 @@ export function CommandAutocomplete({
|
||||
if (autoCompleteNames.length === 0) {
|
||||
return;
|
||||
}
|
||||
const cmdName = autoCompleteNames[0]!;
|
||||
const cmdName = autoCompleteNames[0];
|
||||
handleAutocomplete(cmdName);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -153,7 +153,7 @@ const getLatestThreadEventId = (room: Room, threadRootId: string): string => {
|
||||
(ev) => ev.getId() !== threadRootId && !reactionOrEditEvent(ev)
|
||||
);
|
||||
if (filtered.length > 0) {
|
||||
return filtered[filtered.length - 1]!.getId() ?? threadRootId;
|
||||
return filtered.at(-1)?.getId() ?? threadRootId;
|
||||
}
|
||||
// Fall back to the live timeline if the Thread object hasn't been registered yet
|
||||
const liveEvents = room
|
||||
@@ -165,7 +165,7 @@ const getLatestThreadEventId = (room: Room, threadRootId: string): string => {
|
||||
ev.threadRootId === threadRootId && ev.getId() !== threadRootId && !reactionOrEditEvent(ev)
|
||||
);
|
||||
if (liveEvents.length > 0) {
|
||||
return liveEvents[liveEvents.length - 1]!.getId() ?? threadRootId;
|
||||
return liveEvents.at(-1)?.getId() ?? threadRootId;
|
||||
}
|
||||
return threadRootId;
|
||||
};
|
||||
@@ -547,7 +547,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
if (contents.length > 0) {
|
||||
const replyContent =
|
||||
plainText?.length === 0 ? getReplyContent(replyDraft, room) : undefined;
|
||||
if (replyContent) contents[0]!['m.relates_to'] = replyContent;
|
||||
if (replyContent) contents[0]['m.relates_to'] = replyContent;
|
||||
if (threadRootId) {
|
||||
setReplyDraft({
|
||||
userId: mx.getUserId() ?? '',
|
||||
@@ -1176,19 +1176,17 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
{uploadBoard && (
|
||||
<Scroll size="300" hideTrack visibility="Hover">
|
||||
<UploadBoardContent>
|
||||
{Array.from(selectedFiles)
|
||||
.toReversed()
|
||||
.map((fileItem) => (
|
||||
<UploadCardRenderer
|
||||
key={getUploadItemKey(fileItem)}
|
||||
isEncrypted={!!fileItem.encInfo}
|
||||
fileItem={fileItem}
|
||||
setMetadata={handleFileMetadata}
|
||||
onRemove={handleRemoveUpload}
|
||||
setDesc={setDesc}
|
||||
roomId={roomId}
|
||||
/>
|
||||
))}
|
||||
{[...selectedFiles].toReversed().map((fileItem) => (
|
||||
<UploadCardRenderer
|
||||
key={getUploadItemKey(fileItem)}
|
||||
isEncrypted={!!fileItem.encInfo}
|
||||
fileItem={fileItem}
|
||||
setMetadata={handleFileMetadata}
|
||||
onRemove={handleRemoveUpload}
|
||||
setDesc={setDesc}
|
||||
roomId={roomId}
|
||||
/>
|
||||
))}
|
||||
</UploadBoardContent>
|
||||
</Scroll>
|
||||
)}
|
||||
|
||||
@@ -458,7 +458,7 @@ export function RoomTimeline({
|
||||
if (!el) return () => {};
|
||||
|
||||
const observer = new ResizeObserver((entries) => {
|
||||
const newHeight = entries[0]!.contentRect.height;
|
||||
const newHeight = entries[0].contentRect.height;
|
||||
const prev = prevViewportHeightRef.current;
|
||||
const atBottom = atBottomRef.current;
|
||||
const shrank = newHeight < prev;
|
||||
|
||||
@@ -28,7 +28,7 @@ export function OtherDevices({ devices, refreshDeviceList, showVerification }: O
|
||||
const authMetadata = useAuthMetadata();
|
||||
const accountManagementActions = useAccountManagementActions();
|
||||
|
||||
const [deleted, setDeleted] = useState(new Set());
|
||||
const [deleted, setDeleted] = useState<Set<string>>(new Set());
|
||||
|
||||
const handleDashboardOIDC = useCallback(() => {
|
||||
const authUrl = authMetadata?.account_management_uri ?? authMetadata?.issuer;
|
||||
@@ -77,7 +77,7 @@ export function OtherDevices({ devices, refreshDeviceList, showVerification }: O
|
||||
const deleteDevices = useAsync(
|
||||
useCallback(
|
||||
async (authDict?: AuthDict) => {
|
||||
await mx.deleteMultipleDevices(Array.from(deleted) as string[], authDict);
|
||||
await mx.deleteMultipleDevices([...deleted], authDict);
|
||||
},
|
||||
[mx, deleted]
|
||||
),
|
||||
|
||||
@@ -323,7 +323,7 @@ export function GlobalPacks({ onViewPack }: GlobalPacksProps) {
|
||||
|
||||
removedPacks.forEach((addr) => {
|
||||
if (updatedContent.rooms?.[addr.roomId]?.[addr.stateKey]) {
|
||||
delete updatedContent.rooms[addr.roomId]![addr.stateKey];
|
||||
delete updatedContent.rooms[addr.roomId][addr.stateKey];
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ const parseSettingsLinkQuery = (
|
||||
const params = new URLSearchParams(search);
|
||||
|
||||
if (
|
||||
Array.from(params.entries()).some(
|
||||
[...params.entries()].some(
|
||||
([key, value]) =>
|
||||
SETTINGS_LINK_FORBIDDEN_QUERY_VALUE_PATTERN.test(key) ||
|
||||
SETTINGS_LINK_FORBIDDEN_QUERY_VALUE_PATTERN.test(value)
|
||||
|
||||
@@ -7,7 +7,7 @@ const getHighlightTarget = (target: HTMLElement): HTMLElement =>
|
||||
target.closest<HTMLElement>('[data-sequence-card="true"]') ?? target.parentElement ?? target;
|
||||
const getFocusTarget = (focusId: string): HTMLElement | null =>
|
||||
document.getElementById(focusId) ??
|
||||
Array.from(document.querySelectorAll<HTMLElement>('[data-settings-focus]')).find(
|
||||
[...document.querySelectorAll<HTMLElement>('[data-settings-focus]')].find(
|
||||
(element) => element.getAttribute('data-settings-focus') === focusId
|
||||
) ??
|
||||
null;
|
||||
|
||||
@@ -1084,27 +1084,21 @@ export function useTimelineEventRenderer({
|
||||
`:`}
|
||||
</Text>
|
||||
{(pinsAdded || pinsRemoved) &&
|
||||
pinsAdded
|
||||
.concat(...pinsRemoved)
|
||||
.slice(0, 4)
|
||||
.map((x: string) => (
|
||||
<Reply
|
||||
key={x}
|
||||
style={{ opacity: '80%' }}
|
||||
room={room}
|
||||
replyEventId={x}
|
||||
onClick={handleOpenReply}
|
||||
replyIcon={
|
||||
<>
|
||||
<Icon size="100" src={Icons.Pin} />
|
||||
<Icon
|
||||
size="100"
|
||||
src={pinned.includes(x) ? Icons.Plus : Icons.Minus}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
))}
|
||||
[...pinsAdded, ...pinsRemoved].slice(0, 4).map((x: string) => (
|
||||
<Reply
|
||||
key={x}
|
||||
style={{ opacity: '80%' }}
|
||||
room={room}
|
||||
replyEventId={x}
|
||||
onClick={handleOpenReply}
|
||||
replyIcon={
|
||||
<>
|
||||
<Icon size="100" src={Icons.Pin} />
|
||||
<Icon size="100" src={pinned.includes(x) ? Icons.Plus : Icons.Minus} />
|
||||
</>
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</Box>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -194,9 +194,7 @@ const useTimelinePagination = (
|
||||
const fetched = countAfter - countBefore;
|
||||
|
||||
if (fetched > 0 && fetched < 5) {
|
||||
const checkTimeline = backwards
|
||||
? freshLTimelines[0]
|
||||
: freshLTimelines[freshLTimelines.length - 1];
|
||||
const checkTimeline = backwards ? freshLTimelines[0] : freshLTimelines.at(-1);
|
||||
if (!checkTimeline) return;
|
||||
const checkDirection = backwards ? Direction.Backward : Direction.Forward;
|
||||
const stillHasToken =
|
||||
|
||||
@@ -79,9 +79,7 @@ describe('useAsyncCallback', () => {
|
||||
|
||||
const successStates = result.current[0];
|
||||
expect(successStates.status).toBe(AsyncStatus.Success);
|
||||
if (successStates.status === AsyncStatus.Success) {
|
||||
expect(successStates.data).toBe('fresh');
|
||||
}
|
||||
expect(successStates).toMatchObject({ data: 'fresh' });
|
||||
});
|
||||
|
||||
it('does not call setState after the component unmounts', async () => {
|
||||
|
||||
@@ -140,7 +140,7 @@ export const parseTimestampFlag = (input: string): number | undefined => {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const value = Number.parseFloat(match[1]!); // supports decimal values
|
||||
const value = Number.parseFloat(match[1]); // supports decimal values
|
||||
const unit = match[2];
|
||||
|
||||
const now = Date.now(); // in milliseconds
|
||||
@@ -346,7 +346,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
|
||||
const userIds = rawIds.filter((id) => isUserId(id) && id !== mx.getSafeUserId());
|
||||
if (userIds.length === 0) return;
|
||||
if (userIds.length === 1) {
|
||||
const dmRoomId = getDMRoomFor(mx, userIds[0]!)?.roomId;
|
||||
const dmRoomId = getDMRoomFor(mx, userIds[0])?.roomId;
|
||||
if (dmRoomId) {
|
||||
navigateRoom(dmRoomId);
|
||||
return;
|
||||
@@ -359,7 +359,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
|
||||
preset: Preset.TrustedPrivateChat,
|
||||
initial_state: [createRoomEncryptionState()],
|
||||
});
|
||||
addRoomIdToMDirect(mx, result.room_id, userIds[0]!);
|
||||
addRoomIdToMDirect(mx, result.room_id, userIds[0]);
|
||||
navigateRoom(result.room_id);
|
||||
},
|
||||
},
|
||||
@@ -859,7 +859,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
|
||||
?.getStateEvents(EventType.SpaceParent);
|
||||
|
||||
const targetSpaceId =
|
||||
parents && parents.length > 0 ? parents[0]!.getStateKey() : room.roomId;
|
||||
parents && parents.length > 0 ? parents[0].getStateKey() : room.roomId;
|
||||
|
||||
try {
|
||||
if (input === 'reset' || input === 'clear') {
|
||||
@@ -946,7 +946,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
|
||||
?.getStateEvents(EventType.SpaceParent);
|
||||
|
||||
const targetSpaceId =
|
||||
parents && parents.length > 0 ? parents[0]!.getStateKey() : room.roomId;
|
||||
parents && parents.length > 0 ? parents[0].getStateKey() : room.roomId;
|
||||
|
||||
try {
|
||||
if (input.toLowerCase() === 'reset' || input === '') {
|
||||
@@ -1090,7 +1090,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => {
|
||||
?.getStateEvents(EventType.SpaceParent);
|
||||
|
||||
const targetSpaceId =
|
||||
parents && parents.length > 0 ? parents[0]!.getStateKey() : room.roomId;
|
||||
parents && parents.length > 0 ? parents[0].getStateKey() : room.roomId;
|
||||
|
||||
try {
|
||||
if (['reset', 'clear', ''].includes(rawInput.toLowerCase())) {
|
||||
|
||||
@@ -269,7 +269,7 @@ export const useRoomsImagePacks = (rooms: Room[]) => {
|
||||
useCallback(
|
||||
(mEvent) => {
|
||||
if (
|
||||
rooms.find((room) => room.roomId === mEvent.getRoomId()) &&
|
||||
rooms.some((room) => room.roomId === mEvent.getRoomId()) &&
|
||||
mEvent.getType() === (CustomStateEvent.PoniesRoomEmotes as string)
|
||||
) {
|
||||
setRoomPacks((prev) => {
|
||||
|
||||
@@ -52,7 +52,7 @@ const fillMissingPowers = (powerLevels: IPowerLevels): IPowerLevels =>
|
||||
}
|
||||
});
|
||||
if (draftPl.notifications && typeof draftPl.notifications.room !== 'number') {
|
||||
draftPl.notifications.room = DEFAULT_POWER_LEVELS.notifications.room as number;
|
||||
draftPl.notifications.room = DEFAULT_POWER_LEVELS.notifications.room;
|
||||
}
|
||||
return draftPl;
|
||||
});
|
||||
|
||||
@@ -58,7 +58,7 @@ export const useMergedAbbreviations = (room: Room): Map<string, string> => {
|
||||
return useMemo(() => {
|
||||
// `updateCount` is a cache-busting key for state-event driven recomputation.
|
||||
void updateCount;
|
||||
const allParentIds = Array.from(getAllParents(roomToParents, room.roomId));
|
||||
const allParentIds = [...getAllParents(roomToParents, room.roomId)];
|
||||
const ancestorEntries = allParentIds.flatMap((parentId) => {
|
||||
const parentRoom = mx.getRoom(parentId);
|
||||
if (!parentRoom) return [];
|
||||
|
||||
@@ -277,7 +277,7 @@ const getSpaceJoinedHierarchy = (
|
||||
};
|
||||
childItems.push(childItem);
|
||||
});
|
||||
return ([spaceItem] as HierarchyItem[]).concat(sortRoomItems(spaceItem.roomId, childItems));
|
||||
return [spaceItem, ...sortRoomItems(spaceItem.roomId, childItems)];
|
||||
});
|
||||
|
||||
return hierarchy;
|
||||
|
||||
@@ -215,7 +215,7 @@ export function Direct() {
|
||||
|
||||
const sortedDirects = useMemo(() => {
|
||||
void activityCounter;
|
||||
const items = Array.from(directs).toSorted(factoryRoomIdByActivity(mx));
|
||||
const items = [...directs].toSorted(factoryRoomIdByActivity(mx));
|
||||
const hasUnread = (roomId: string) => {
|
||||
const unread = roomToUnread.get(roomId);
|
||||
return !!unread && (unread.total > 0 || unread.highlight > 0);
|
||||
|
||||
@@ -207,7 +207,7 @@ export function Home() {
|
||||
const [closedCategories, setClosedCategories] = useAtom(useClosedNavCategoriesAtom());
|
||||
|
||||
const sortedRooms = useMemo(() => {
|
||||
const items = Array.from(rooms).toSorted(
|
||||
const items = [...rooms].toSorted(
|
||||
closedCategories.has(DEFAULT_CATEGORY_ID)
|
||||
? factoryRoomIdByActivity(mx)
|
||||
: factoryRoomIdByAtoZ(mx)
|
||||
|
||||
@@ -581,7 +581,7 @@ export function Space() {
|
||||
connectorStack = [{ aX: Math.round(renderDepth * PADDING_LEFT_DEPTH_OFFSET), aY: 0 }];
|
||||
}
|
||||
|
||||
const lastConnector = connectorStack[connectorStack.length - 1];
|
||||
const lastConnector = connectorStack.at(-1);
|
||||
if (!lastConnector) return;
|
||||
|
||||
// aX: numeric x where the vertical connector starts
|
||||
|
||||
@@ -318,7 +318,7 @@ export async function encryptMegolmKeyFile(
|
||||
// clear bit 63 of the IV to stop us hitting the 64-bit counter boundary
|
||||
// (which would mean we wouldn't be able to decrypt on Android). The loss
|
||||
// of a single bit of iv is a price we have to pay.
|
||||
iv[8]! &= 0x7f;
|
||||
iv[8] &= 0x7f;
|
||||
|
||||
const [aesKey, hmacKey] = await deriveKeys(salt, kdfRounds, password);
|
||||
const encodedData = toArrayBufferView(new TextEncoder().encode(data));
|
||||
|
||||
@@ -68,7 +68,7 @@ export const binarySearch = <T>(items: T[], match: (item: T) => -1 | 0 | 1): T |
|
||||
|
||||
const mid = Math.floor((start + end) / 2);
|
||||
|
||||
const result = match(items[mid]!);
|
||||
const result = match(items[mid]);
|
||||
if (result === 0) return items[mid];
|
||||
|
||||
if (result === 1) return search(start, mid - 1);
|
||||
@@ -106,6 +106,7 @@ export const parseGeoUri = (location: string) => {
|
||||
|
||||
const START_SLASHES_REG = /^\/+/g;
|
||||
const END_SLASHES_REG = /\/+$/g;
|
||||
const graphemeSegmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' });
|
||||
export const trimLeadingSlash = (str: string): string => str.replace(START_SLASHES_REG, '');
|
||||
export const trimTrailingSlash = (str: string): string => str.replace(END_SLASHES_REG, '');
|
||||
|
||||
@@ -113,7 +114,9 @@ export const trimSlash = (str: string): string => trimLeadingSlash(trimTrailingS
|
||||
|
||||
export const nameInitials = (str: string | undefined | null, len = 1): string => {
|
||||
if (!str) return '';
|
||||
return Array.from(str).slice(0, len).join('') || '';
|
||||
return Array.from(graphemeSegmenter.segment(str), ({ segment }) => segment)
|
||||
.slice(0, len)
|
||||
.join('');
|
||||
};
|
||||
|
||||
export const randomStr = (len = 12): string => {
|
||||
|
||||
@@ -228,7 +228,7 @@ export const syntaxErrorPosition = (error: SyntaxError): number | undefined => {
|
||||
const match = error.message.match(/position\s(\d+)\s/);
|
||||
if (!match) return undefined;
|
||||
|
||||
const posStr = match[1]!;
|
||||
const posStr = match[1];
|
||||
const position = parseInt(posStr, 10);
|
||||
if (Number.isNaN(position)) return undefined;
|
||||
return position;
|
||||
|
||||
@@ -272,7 +272,7 @@ export const addRoomIdToMDirect = async (
|
||||
// remove it from the lists of any others users
|
||||
// (it can only be a DM room for one person)
|
||||
Object.keys(userIdToRoomIds).forEach((targetUserId) => {
|
||||
const roomIds = userIdToRoomIds[targetUserId]!;
|
||||
const roomIds = userIdToRoomIds[targetUserId];
|
||||
|
||||
if (targetUserId !== userId) {
|
||||
const indexOfRoomId = roomIds.indexOf(roomId);
|
||||
@@ -304,7 +304,7 @@ export const removeRoomIdFromMDirect = async (mx: MatrixClient, roomId: string):
|
||||
userIdToRoomIds = structuredClone(mDirectsEvent.getContent());
|
||||
|
||||
Object.keys(userIdToRoomIds).forEach((targetUserId) => {
|
||||
const roomIds = userIdToRoomIds[targetUserId]!;
|
||||
const roomIds = userIdToRoomIds[targetUserId];
|
||||
const indexOfRoomId = roomIds.indexOf(roomId);
|
||||
if (indexOfRoomId > -1) {
|
||||
roomIds.splice(indexOfRoomId, 1);
|
||||
@@ -385,7 +385,7 @@ export const rateLimitedActions = async <T, R = void>(
|
||||
};
|
||||
|
||||
for (let i = 0; i < data.length; i += 1) {
|
||||
const dataItem = data[i]!;
|
||||
const dataItem = data[i];
|
||||
retryCount = 0;
|
||||
// oxlint-disable-next-line no-await-in-loop
|
||||
await performAction(dataItem, i);
|
||||
@@ -427,7 +427,7 @@ export const toggleReaction = (
|
||||
);
|
||||
const allReactions = relations?.getSortedAnnotationsByKey() ?? [];
|
||||
const [, reactionsSet] = allReactions.find(([k]) => k === key) ?? [];
|
||||
const reactions: MatrixEvent[] = reactionsSet ? Array.from(reactionsSet) : [];
|
||||
const reactions: MatrixEvent[] = reactionsSet ? [...reactionsSet] : [];
|
||||
const myReaction = reactions.find(factoryEventSentBy(mx.getUserId()!));
|
||||
|
||||
if (myReaction && myReaction.isRelation?.()) {
|
||||
|
||||
@@ -755,7 +755,7 @@ export const guessPerfectParent = (
|
||||
|
||||
if (typeof users === 'object')
|
||||
Object.keys(users).forEach((userId) => {
|
||||
if (users[userId]! > defaultPower) {
|
||||
if (users[userId] > defaultPower) {
|
||||
specialUsers.add(userId);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -73,7 +73,7 @@ describe('serializeForSync', () => {
|
||||
|
||||
it('strips all non-syncable keys from the payload', () => {
|
||||
const { settings: s } = serializeForSync(base);
|
||||
Array.from(NON_SYNCABLE_KEYS).forEach((key) => {
|
||||
[...NON_SYNCABLE_KEYS].forEach((key) => {
|
||||
expect(Object.hasOwn(s, key)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { CryptoCallbacks } from '$types/matrix-sdk';
|
||||
const secretStorageKeys = new Map<string, Uint8Array>();
|
||||
|
||||
export function storePrivateKey(keyId: string, privateKey: Uint8Array): void {
|
||||
if (privateKey instanceof Uint8Array === false) {
|
||||
if (!(privateKey instanceof Uint8Array)) {
|
||||
throw new Error('Unable to store, privateKey is invalid.');
|
||||
}
|
||||
secretStorageKeys.set(keyId, privateKey);
|
||||
|
||||
Reference in new issue
Block a user