Skip to content

Commit

Permalink
emojiCacheをlocalStorageに
Browse files Browse the repository at this point in the history
  • Loading branch information
yamader committed Feb 28, 2024
1 parent 648e3a5 commit 6fc5beb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/features/api/CustomEmoji.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
"use client"

import { atom, useAtom, useAtomValue } from "jotai"
import { useAtom, useAtomValue } from "jotai"
import { atomWithStorage } from "jotai/utils"
import { Fragment, Suspense, createContext, use, useContext, useState } from "react"
import { CustomEmojiProps } from "react-mfm"
import { useAPI } from "~/features/api"

// internal

const emojiCacheAtom = atom<{ [host: string]: { [name: string]: string | null } }>({})
// todo: invalidate
const emojiCacheAtom = atomWithStorage<{ [host: string]: { [name: string]: string | null } }>(
"minsk::api::emojiCache",
{},
)

const EmojiImg = ({ name, url }: { name: string; url?: string | null }) =>
!url ? `:${name}:` : <img src={url} alt={name} className="mfm-customEmoji" />
Expand Down

0 comments on commit 6fc5beb

Please sign in to comment.