mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 11:06:06 +00:00
18eeb16aa0
The currency converter, the world clocks, the collection lists, the plugin widgets and card badges and the card date format each existed once per dashboard. They now live in useCurrencyConverter, useDashboardTimezones, useCollectionLists, useDashboardPlugins and dashboardModel; the phone keeps aborting a pending rate request through an option.
30 lines
790 B
TypeScript
30 lines
790 B
TypeScript
import type { Collection } from '@trek/shared';
|
|
import { useEffect, useState } from 'react';
|
|
|
|
import { collectionsApi } from '../../api/collections';
|
|
|
|
/** The user's saved-place lists for the dashboard widgets, loaded once on mount. */
|
|
export function useCollectionLists() {
|
|
const [lists, setLists] = useState<Collection[]>([]);
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
useEffect(() => {
|
|
let cancelled = false;
|
|
void (async () => {
|
|
try {
|
|
const data = await collectionsApi.list();
|
|
if (!cancelled) setLists(data.collections);
|
|
} catch {
|
|
if (!cancelled) setLists([]);
|
|
} finally {
|
|
if (!cancelled) setLoading(false);
|
|
}
|
|
})();
|
|
return () => {
|
|
cancelled = true;
|
|
};
|
|
}, []);
|
|
|
|
return { lists, loading };
|
|
}
|