Merge remote-tracking branch 'origin/development' into development

pull/2014/head
morpheus65535 2 years ago
commit 0e79fbadba

@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Execute - name: Execute
uses: benc-uk/workflow-dispatch@v1 uses: benc-uk/workflow-dispatch@v121
with: with:
workflow: "release_beta_to_dev" workflow: "release_beta_to_dev"
token: ${{ secrets.WF_GITHUB_TOKEN }} token: ${{ secrets.WF_GITHUB_TOKEN }}

@ -14,12 +14,16 @@ import {
} from "@mantine/core"; } from "@mantine/core";
import { useForm } from "@mantine/form"; import { useForm } from "@mantine/form";
import { isObject } from "lodash"; import { isObject } from "lodash";
import { FunctionComponent, useMemo } from "react"; import { FunctionComponent, useCallback, useMemo } from "react";
import { useMutation } from "react-query"; import { useMutation } from "react-query";
import { Card } from "../components"; import { Card } from "../components";
import { notificationsKey } from "../keys"; import { notificationsKey } from "../keys";
import { useSettingValue, useUpdateArray } from "../utilities/hooks"; import { useSettingValue, useUpdateArray } from "../utilities/hooks";
const notificationHook = (notifications: Settings.NotificationInfo[]) => {
return notifications.map((info) => JSON.stringify(info));
};
interface Props { interface Props {
selections: readonly Settings.NotificationInfo[]; selections: readonly Settings.NotificationInfo[];
payload: Settings.NotificationInfo | null; payload: Settings.NotificationInfo | null;
@ -122,6 +126,13 @@ export const NotificationView: FunctionComponent = () => {
"name" "name"
); );
const updateWrapper = useCallback(
(info: Settings.NotificationInfo) => {
update(info, notificationHook);
},
[update]
);
const modals = useModals(); const modals = useModals();
const elements = useMemo(() => { const elements = useMemo(() => {
@ -135,12 +146,12 @@ export const NotificationView: FunctionComponent = () => {
modals.openContextModal(NotificationModal, { modals.openContextModal(NotificationModal, {
payload, payload,
selections: notifications, selections: notifications,
onComplete: update, onComplete: updateWrapper,
}) })
} }
></Card> ></Card>
)); ));
}, [modals, notifications, update]); }, [modals, notifications, updateWrapper]);
return ( return (
<SimpleGrid cols={3}> <SimpleGrid cols={3}>
@ -151,7 +162,7 @@ export const NotificationView: FunctionComponent = () => {
modals.openContextModal(NotificationModal, { modals.openContextModal(NotificationModal, {
payload: null, payload: null,
selections: notifications ?? [], selections: notifications ?? [],
onComplete: update, onComplete: updateWrapper,
}) })
} }
></Card> ></Card>

@ -57,7 +57,7 @@ export function useFormActions() {
} }
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
type HookType = (value: any) => unknown; export type HookType = (value: any) => unknown;
export type FormKey = keyof FormValues; export type FormKey = keyof FormValues;
export type FormValues = { export type FormValues = {

@ -1,7 +1,11 @@
import { LOG } from "@/utilities/console"; import { LOG } from "@/utilities/console";
import { get, isNull, isUndefined, uniqBy } from "lodash"; import { get, isNull, isUndefined, uniqBy } from "lodash";
import { useCallback, useMemo, useRef } from "react"; import { useCallback, useMemo, useRef } from "react";
import { useFormActions, useStagedValues } from "../utilities/FormValues"; import {
HookType,
useFormActions,
useStagedValues,
} from "../utilities/FormValues";
import { useSettings } from "../utilities/SettingsProvider"; import { useSettings } from "../utilities/SettingsProvider";
export interface BaseInput<T> { export interface BaseInput<T> {
@ -94,9 +98,9 @@ export function useUpdateArray<T>(key: string, compare: keyof T) {
}, [key, stagedValue]); }, [key, stagedValue]);
return useCallback( return useCallback(
(v: T) => { (v: T, hook?: HookType) => {
const newArray = uniqBy([v, ...staged], compareRef.current); const newArray = uniqBy([v, ...staged], compareRef.current);
setValue(newArray, key); setValue(newArray, key, hook);
}, },
[staged, setValue, key] [staged, setValue, key]
); );

Loading…
Cancel
Save