pl-fe: migrate /api/v*/instance to tanstack query

Signed-off-by: mkljczk <git@mkljczk.pl>
This commit is contained in:
mkljczk
2024-12-03 15:03:17 +01:00
parent 2086e027ad
commit 1f8b79f309
79 changed files with 240 additions and 337 deletions

View File

@ -1,7 +1,8 @@
import { Features } from 'pl-api';
import { useInstance } from 'pl-fe/api/hooks/instance/use-instance';
import { useAppSelector } from './use-app-selector';
import { useInstance } from './use-instance';
/** Get features for the current instance. */
const useFeatures = (): Features => {

View File

@ -1,6 +0,0 @@
import { useAppSelector } from './use-app-selector';
/** Get the Instance for the current backend. */
const useInstance = () => useAppSelector((state) => state.instance);
export { useInstance };

View File

@ -1,8 +1,9 @@
import { useInstance } from 'pl-fe/api/hooks/instance/use-instance';
import { useFeatures } from './use-features';
import { useInstance } from './use-instance';
const useRegistrationStatus = () => {
const instance = useInstance();
const { data: instance } = useInstance();
const features = useFeatures();
return {

View File

@ -0,0 +1,11 @@
import { useInstance } from 'pl-fe/api/hooks/instance/use-instance';
import { useAppSelector } from './use-app-selector';
const useVapidKey = () => {
const { data: instance } = useInstance();
return useAppSelector((state) => instance.configuration.vapid.public_key || state.auth.app?.vapid_key);
};
export { useVapidKey };