mirror of
https://github.com/outline/outline.git
synced 2026-11-22 22:02:35 +03:00
* fix: Invalid sort comparator for frequently used items (#13241) Extracts frequency tracking for icons, emojis, and code languages into a shared FrequencyTracker with a spec-compliant, stable sort. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Snapshot frequently used icons while picker is open Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Sync frequent custom emojis to tracked ids, preserving order Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
28 lines
754 B
TypeScript
28 lines
754 B
TypeScript
import { emojiSkinToneKey, iconFrequencies } from "./utils";
|
|
import useFrequencyTracker from "~/hooks/useFrequencyTracker";
|
|
import usePersistedState from "~/hooks/usePersistedState";
|
|
import { EmojiSkinTone, IconType } from "@shared/types";
|
|
|
|
const skinToneKeys = {
|
|
[IconType.Custom]: "",
|
|
[IconType.Emoji]: emojiSkinToneKey,
|
|
[IconType.SVG]: "",
|
|
};
|
|
|
|
export const useIconState = (type: IconType) => {
|
|
const [emojiSkinTone, setEmojiSkinTone] = usePersistedState<EmojiSkinTone>(
|
|
skinToneKeys[type],
|
|
EmojiSkinTone.Default
|
|
);
|
|
|
|
const { frequent: frequentIcons, track: incrementIconCount } =
|
|
useFrequencyTracker(iconFrequencies[type]);
|
|
|
|
return {
|
|
emojiSkinTone,
|
|
setEmojiSkinTone,
|
|
incrementIconCount,
|
|
frequentIcons,
|
|
};
|
|
};
|