feat: PWA Support (#1488)
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import { useContext } from 'react';
|
||||
import { useSWRInfinite } from 'swr';
|
||||
import { MediaStatus } from '../../server/constants/media';
|
||||
import { LanguageContext } from '../context/LanguageContext';
|
||||
import useSettings from './useSettings';
|
||||
|
||||
export interface BaseSearchResult<T> {
|
||||
@@ -35,7 +33,6 @@ const useDiscover = <T extends BaseMedia, S = Record<string, never>>(
|
||||
{ hideAvailable = true } = {}
|
||||
): DiscoverResult<T, S> => {
|
||||
const settings = useSettings();
|
||||
const { locale } = useContext(LanguageContext);
|
||||
const { data, error, size, setSize, isValidating } = useSWRInfinite<
|
||||
BaseSearchResult<T> & S
|
||||
>(
|
||||
@@ -46,7 +43,6 @@ const useDiscover = <T extends BaseMedia, S = Record<string, never>>(
|
||||
|
||||
const params: Record<string, unknown> = {
|
||||
page: pageIndex + 1,
|
||||
language: locale,
|
||||
...options,
|
||||
};
|
||||
|
||||
|
||||
13
src/hooks/useLocale.ts
Normal file
13
src/hooks/useLocale.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { useContext } from 'react';
|
||||
import {
|
||||
LanguageContext,
|
||||
LanguageContextProps,
|
||||
} from '../context/LanguageContext';
|
||||
|
||||
const useLocale = (): Omit<LanguageContextProps, 'children'> => {
|
||||
const languageContext = useContext(LanguageContext);
|
||||
|
||||
return languageContext;
|
||||
};
|
||||
|
||||
export default useLocale;
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
Permission,
|
||||
PermissionCheckOptions,
|
||||
} from '../../server/lib/permissions';
|
||||
import { NotificationAgentKey } from '../../server/lib/settings';
|
||||
|
||||
export { Permission, UserType };
|
||||
export type { PermissionCheckOptions };
|
||||
@@ -25,10 +26,14 @@ export interface User {
|
||||
settings?: UserSettings;
|
||||
}
|
||||
|
||||
type NotificationAgentTypes = Record<NotificationAgentKey, number>;
|
||||
|
||||
export interface UserSettings {
|
||||
discordId?: string;
|
||||
region?: string;
|
||||
originalLanguage?: string;
|
||||
locale?: string;
|
||||
notificationTypes: Partial<NotificationAgentTypes>;
|
||||
}
|
||||
|
||||
interface UserHookResponse {
|
||||
|
||||
Reference in New Issue
Block a user