266e47f240
Resolves all TS2345/TS2347/TS7006 type errors introduced by stricter TypeScript 5.x. Fix Icons.Settings to Icons.Setting, cast account data returns, fix implicit any. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
26 lines
945 B
TypeScript
26 lines
945 B
TypeScript
import React, { useCallback, useMemo } from 'react';
|
|
import { ImagePackContent } from './ImagePackContent';
|
|
import { ImagePack, PackContent } from '../../plugins/custom-emoji';
|
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
|
import { AccountDataEvent } from '../../../types/matrix/accountData';
|
|
import { useUserImagePack } from '../../hooks/useImagePacks';
|
|
|
|
export function UserImagePack() {
|
|
const mx = useMatrixClient();
|
|
|
|
const defaultPack = useMemo(() => new ImagePack(mx.getUserId() ?? '', {}, undefined), [mx]);
|
|
const imagePack = useUserImagePack();
|
|
|
|
const handleUpdate = useCallback(
|
|
async (packContent: PackContent) => {
|
|
await mx.setAccountData(
|
|
AccountDataEvent.PoniesUserEmotes as unknown as keyof import('matrix-js-sdk').AccountDataEvents,
|
|
packContent,
|
|
);
|
|
},
|
|
[mx],
|
|
);
|
|
|
|
return <ImagePackContent imagePack={imagePack ?? defaultPack} canEdit onUpdate={handleUpdate} />;
|
|
}
|