mirror of
https://github.com/pterodactyl/panel.git
synced 2024-11-25 18:42:31 +01:00
Don't use a persisted setting when switching users; ref #3021
This commit is contained in:
parent
3053a896f4
commit
914ee65ded
@ -16,8 +16,9 @@ import Pagination from '@/components/elements/Pagination';
|
|||||||
export default () => {
|
export default () => {
|
||||||
const { clearFlashes, clearAndAddHttpError } = useFlash();
|
const { clearFlashes, clearAndAddHttpError } = useFlash();
|
||||||
const [ page, setPage ] = useState(1);
|
const [ page, setPage ] = useState(1);
|
||||||
const { rootAdmin } = useStoreState(state => state.user.data!);
|
const uuid = useStoreState(state => state.user.data!.uuid);
|
||||||
const [ showOnlyAdmin, setShowOnlyAdmin ] = usePersistedState('show_all_servers', false);
|
const rootAdmin = useStoreState(state => state.user.data!.rootAdmin);
|
||||||
|
const [ showOnlyAdmin, setShowOnlyAdmin ] = usePersistedState(`${uuid}:show_all_servers`, false);
|
||||||
|
|
||||||
const { data: servers, error } = useSWR<PaginatedResult<Server>>(
|
const { data: servers, error } = useSWR<PaginatedResult<Server>>(
|
||||||
[ '/api/client/servers', showOnlyAdmin, page ],
|
[ '/api/client/servers', showOnlyAdmin, page ],
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Dispatch, SetStateAction, useEffect, useState } from 'react';
|
import { Dispatch, SetStateAction, useEffect, useState } from 'react';
|
||||||
|
|
||||||
export function usePersistedState<S = undefined> (key: string, defaultValue: S): [S | undefined, Dispatch<SetStateAction<S | undefined>>] {
|
export function usePersistedState<S = undefined> (key: string, defaultValue: S): [ S | undefined, Dispatch<SetStateAction<S | undefined>> ] {
|
||||||
const [ state, setState ] = useState(
|
const [ state, setState ] = useState(
|
||||||
() => {
|
() => {
|
||||||
try {
|
try {
|
||||||
@ -12,7 +12,7 @@ export function usePersistedState<S = undefined> (key: string, defaultValue: S):
|
|||||||
|
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user