2023-01-10 14:08:13 +02:00
|
|
|
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';
|
|
|
|
|
2023-06-30 10:11:26 +02:00
|
|
|
export default (timestamp = 0) => {
|
2023-01-10 14:08:13 +02:00
|
|
|
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;
|
|
|
|
};
|