Refactor server list to object instead of array

- Improve performance due to frequency of accessing the list
This commit is contained in:
jeffvli 2023-05-09 00:39:11 -07:00
parent 3dfeed1432
commit b2db2b27da
4 changed files with 22 additions and 14 deletions

View file

@ -3,7 +3,6 @@ import { Checkbox, Stack, Group } from '@mantine/core';
import { Button, PasswordInput, TextInput, toast } from '/@/renderer/components';
import { useForm } from '@mantine/form';
import { closeAllModals } from '@mantine/modals';
import { nanoid } from 'nanoid/non-secure';
import { RiInformationLine } from 'react-icons/ri';
import { jellyfinApi } from '/@/renderer/api/jellyfin.api';
import { navidromeApi } from '/@/renderer/api/navidrome.api';
@ -25,7 +24,7 @@ const AUTH_FUNCTIONS = {
};
export const EditServerForm = ({ isUpdate, server, onCancel }: EditServerFormProps) => {
const { updateServer, setCurrentServer } = useAuthStoreActions();
const { updateServer } = useAuthStoreActions();
const [isLoading, setIsLoading] = useState(false);
const form = useForm({
@ -61,7 +60,6 @@ export const EditServerForm = ({ isUpdate, server, onCancel }: EditServerFormPro
const serverItem = {
credential: data.credential,
id: nanoid(),
name: values.name,
ndCredential: data.ndCredential,
type: values.type,
@ -71,8 +69,6 @@ export const EditServerForm = ({ isUpdate, server, onCancel }: EditServerFormPro
};
updateServer(server.id, serverItem);
setCurrentServer(serverItem);
toast.success({ message: 'Server has been updated' });
} catch (err: any) {
setIsLoading(false);