mirror of
https://github.com/SableClient/Sable.git
synced 2026-12-02 06:42:33 -08:00
23 lines
808 B
TypeScript
23 lines
808 B
TypeScript
import type {
|
|
SecretStorageDefaultKeyContent,
|
|
SecretStorageKeyContent,
|
|
} from '$types/matrix/accountData';
|
|
|
|
import { useAccountData } from './useAccountData';
|
|
|
|
export const getSecretStorageKeyEventType = (key: string): string => `m.secret_storage.key.${key}`;
|
|
|
|
export const useSecretStorageDefaultKeyId = (): string | undefined => {
|
|
const defaultKeyEvent = useAccountData('m.secret_storage.default_key');
|
|
const defaultKeyId = defaultKeyEvent?.getContent<SecretStorageDefaultKeyContent>().key;
|
|
|
|
return defaultKeyId;
|
|
};
|
|
|
|
export const useSecretStorageKeyContent = (keyId: string): SecretStorageKeyContent | undefined => {
|
|
const keyEvent = useAccountData(getSecretStorageKeyEventType(keyId));
|
|
const secretStorageKey = keyEvent?.getContent<SecretStorageKeyContent>();
|
|
|
|
return secretStorageKey;
|
|
};
|