1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00
joplin/packages/app-mobile/components/ProfileSwitcher/useProfileConfig.ts

21 lines
610 B
TypeScript

import useAsyncEffect, { AsyncEffectEvent } from '@joplin/lib/hooks/useAsyncEffect';
import { ProfileConfig } from '@joplin/lib/services/profileConfig/types';
import { useState } from 'react';
import { loadProfileConfig } from '../../services/profiles';
export default (timestamp = 0) => {
const [profileConfig, setProfileConfig] = useState<ProfileConfig>(null);
useAsyncEffect(async (event: AsyncEffectEvent) => {
const load = async () => {
const r = await loadProfileConfig();
if (event.cancelled) return;
setProfileConfig(r);
};
void load();
}, [timestamp]);
return profileConfig;
};