瀏覽代碼

create useEmojiHintModal hooks

WNomunomu 2 年之前
父節點
當前提交
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,
+  };
+};