Просмотр исходного кода

create useEmojiHintModal hooks

WNomunomu 2 лет назад
Родитель
Сommit
e1becf417e
1 измененных файлов с 32 добавлено и 0 удалено
  1. 32 0
      apps/app/src/stores/modal.tsx

+ 32 - 0
apps/app/src/stores/modal.tsx

@@ -739,3 +739,35 @@ export const useLinkEditModal = (): SWRResponse<LinkEditModalStatus, Error> & Li
     },
     },
   });
   });
 };
 };
+
+/*
+ * EmojiHintModal
+ */
+type EmojiHintModalStatus = {
+  isOpened: boolean,
+}
+
+type EmojiHintModalUtils = {
+  open(): void,
+  close(): void,
+}
+
+export const useEmojiHintModal = (): SWRResponse<EmojiHintModalStatus, Error> & EmojiHintModalUtils => {
+
+  const initialStatus: EmojiHintModalStatus = { isOpened: false };
+  const swrResponse = useStaticSWR<EmojiHintModalStatus, Error>('emojiHintModal', undefined, { fallbackData: initialStatus });
+
+  const open = () => {
+    swrResponse.mutate({ isOpened: true });
+  };
+
+  const close = () => {
+    swrResponse.mutate({ isOpened: false });
+  };
+
+  return {
+    ...swrResponse,
+    open,
+    close,
+  };
+};