@chayns-components/emoji-input 5.0.0-beta.1050 → 5.0.0-beta.1055
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emojiHistory.js","names":["_react","require","_get","_put","useEmojiHistory","accessToken","personId","selectedCategory","historyEmojis","setHistoryEmojis","useState","tempHistoryEmojis","useRef","addOrUpdateEmojiInHistory","useCallback","emoji","name","skin_tone_support","_historyItem","newHistoryEmojis","Array","from","current","historyItemIndex","findIndex","item","historyItem","splice","push","count","modifiedTime","Date","toISOString","sort","a","b","getTime","data","putEmojiHistory","value","slice","loadHistoryEmojis","getEmojiHistory","useEffect","exports"],"sources":["../../../src/hooks/emojiHistory.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { getEmojiHistory } from '../api/item-storage/get';\nimport { putEmojiHistory } from '../api/item-storage/put';\nimport type { Category } from '../types/category';\n\nexport interface HistoryItem {\n count: number;\n emoji: string;\n modifiedTime: string;\n name: string;\n skin_tone_support: boolean;\n}\n\ninterface UseEmojiHistoryOptions {\n accessToken?: string;\n personId?: string;\n selectedCategory: Category;\n}\n\nexport const useEmojiHistory = ({\n accessToken,\n personId,\n selectedCategory,\n}: UseEmojiHistoryOptions) => {\n const [historyEmojis, setHistoryEmojis] = useState<HistoryItem[]>([]);\n\n const tempHistoryEmojis = useRef<HistoryItem[] | null>(null);\n\n const addOrUpdateEmojiInHistory = useCallback(\n async ({\n emoji,\n name,\n skin_tone_support,\n }: {\n emoji: string;\n name: string;\n skin_tone_support: boolean;\n }) => {\n if (typeof accessToken !== 'string' || typeof personId !== 'string') {\n return;\n }\n\n const newHistoryEmojis = Array.from(tempHistoryEmojis.current ?? historyEmojis);\n\n const historyItemIndex = newHistoryEmojis.findIndex((item) => item.emoji === emoji);\n\n let historyItem;\n\n if (historyItemIndex > -1) {\n [historyItem] = newHistoryEmojis.splice(historyItemIndex, 1);\n }\n\n newHistoryEmojis.push({\n count: (historyItem?.count ?? 0) + 1,\n emoji,\n modifiedTime: new Date().toISOString(),\n name,\n skin_tone_support,\n });\n\n newHistoryEmojis.sort((a, b) => {\n if (a.count === b.count) {\n return new Date(b.modifiedTime).getTime() - new Date(a.modifiedTime).getTime();\n }\n\n return b.count - a.count;\n });\n\n const { data } = await putEmojiHistory({\n accessToken,\n personId,\n value: newHistoryEmojis.slice(0, 50),\n });\n\n if (data) {\n if (selectedCategory === 'history') {\n tempHistoryEmojis.current = data;\n } else {\n tempHistoryEmojis.current = null;\n\n setHistoryEmojis(data);\n }\n }\n },\n [accessToken, historyEmojis, personId, selectedCategory]
|
|
1
|
+
{"version":3,"file":"emojiHistory.js","names":["_react","require","_get","_put","useEmojiHistory","accessToken","personId","selectedCategory","historyEmojis","setHistoryEmojis","useState","tempHistoryEmojis","useRef","addOrUpdateEmojiInHistory","useCallback","emoji","name","skin_tone_support","_historyItem","newHistoryEmojis","Array","from","current","historyItemIndex","findIndex","item","historyItem","splice","push","count","modifiedTime","Date","toISOString","sort","a","b","getTime","data","putEmojiHistory","value","slice","loadHistoryEmojis","getEmojiHistory","useEffect","exports"],"sources":["../../../src/hooks/emojiHistory.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\nimport { getEmojiHistory } from '../api/item-storage/get';\nimport { putEmojiHistory } from '../api/item-storage/put';\nimport type { Category } from '../types/category';\n\nexport interface HistoryItem {\n count: number;\n emoji: string;\n modifiedTime: string;\n name: string;\n skin_tone_support: boolean;\n}\n\ninterface UseEmojiHistoryOptions {\n accessToken?: string;\n personId?: string;\n selectedCategory: Category;\n}\n\nexport const useEmojiHistory = ({\n accessToken,\n personId,\n selectedCategory,\n}: UseEmojiHistoryOptions) => {\n const [historyEmojis, setHistoryEmojis] = useState<HistoryItem[]>([]);\n\n const tempHistoryEmojis = useRef<HistoryItem[] | null>(null);\n\n const addOrUpdateEmojiInHistory = useCallback(\n async ({\n emoji,\n name,\n skin_tone_support,\n }: {\n emoji: string;\n name: string;\n skin_tone_support: boolean;\n }) => {\n if (typeof accessToken !== 'string' || typeof personId !== 'string') {\n return;\n }\n\n const newHistoryEmojis = Array.from(tempHistoryEmojis.current ?? historyEmojis);\n\n const historyItemIndex = newHistoryEmojis.findIndex((item) => item.emoji === emoji);\n\n let historyItem;\n\n if (historyItemIndex > -1) {\n [historyItem] = newHistoryEmojis.splice(historyItemIndex, 1);\n }\n\n newHistoryEmojis.push({\n count: (historyItem?.count ?? 0) + 1,\n emoji,\n modifiedTime: new Date().toISOString(),\n name,\n skin_tone_support,\n });\n\n newHistoryEmojis.sort((a, b) => {\n if (a.count === b.count) {\n return new Date(b.modifiedTime).getTime() - new Date(a.modifiedTime).getTime();\n }\n\n return b.count - a.count;\n });\n\n const { data } = await putEmojiHistory({\n accessToken,\n personId,\n value: newHistoryEmojis.slice(0, 50),\n });\n\n if (data) {\n if (selectedCategory === 'history') {\n tempHistoryEmojis.current = data;\n } else {\n tempHistoryEmojis.current = null;\n\n setHistoryEmojis(data);\n }\n }\n },\n [accessToken, historyEmojis, personId, selectedCategory],\n );\n\n const loadHistoryEmojis = useCallback(async () => {\n if (typeof accessToken !== 'string' || typeof personId !== 'string') {\n return;\n }\n\n const { data } = await getEmojiHistory({ accessToken, personId });\n\n if (data) {\n setHistoryEmojis(data);\n }\n }, [accessToken, personId]);\n\n useEffect(() => {\n void loadHistoryEmojis();\n }, [loadHistoryEmojis]);\n\n useEffect(() => {\n if (selectedCategory !== 'history' && tempHistoryEmojis.current) {\n setHistoryEmojis(tempHistoryEmojis.current);\n }\n }, [selectedCategory]);\n\n return { addOrUpdateEmojiInHistory, historyEmojis: historyEmojis.slice(0, 25) };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AAiBO,MAAMG,eAAe,GAAGA,CAAC;EAC5BC,WAAW;EACXC,QAAQ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