58 lines
2.0 KiB
TypeScript
58 lines
2.0 KiB
TypeScript
// Metro module 8080 (f8081).
|
|
import { useMemo } from "react";
|
|
import EmojiStore from "../../emojis/EmojiStore";
|
|
import { ActivityTypes } from "../../../Constants";
|
|
import UnicodeEmojis from "../../emojis/UnicodeEmojis";
|
|
import { CustomStatusSetting } from "../../user_settings/UserSettings";
|
|
import { useStateFromStores } from "../../../_bundle/Module589";
|
|
const _activityFromSetting = function _activityFromSetting(setting, stateFromStores) {
|
|
let emoji;
|
|
if (stateFromStores != null) {
|
|
emoji = {
|
|
id: stateFromStores.id,
|
|
name: stateFromStores.name,
|
|
animated: stateFromStores.animated
|
|
};
|
|
} else {
|
|
const r1 = setting.emojiName != null;
|
|
emoji = null;
|
|
if (r1) {
|
|
const emojiName = setting.emojiName;
|
|
emoji = null;
|
|
if (emojiName !== "") {
|
|
const byName = UnicodeEmojis.getByName(UnicodeEmojis.convertSurrogateToName(setting.emojiName, false));
|
|
emoji = byName != null ? {
|
|
id: null,
|
|
name: byName.surrogates,
|
|
animated: false
|
|
} : null;
|
|
}
|
|
}
|
|
}
|
|
const end = Number(setting.expiresAtMs);
|
|
const value = setting.label?.value;
|
|
return {
|
|
name: "Custom Status",
|
|
type: ActivityTypes.CUSTOM_STATUS,
|
|
state: setting.text.length > 0 ? setting.text : void 0,
|
|
timestamps: end > 0 ? {
|
|
end
|
|
} : void 0,
|
|
emoji,
|
|
details: value,
|
|
metadata: {
|
|
label: value
|
|
}
|
|
};
|
|
};
|
|
export function getActivityFromCustomStatus(a0) {
|
|
const emojiId2 = a0.emojiId;
|
|
return _activityFromSetting(a0, emojiId2 != null ? emojiId2 !== "0" ? EmojiStore.getUsableCustomEmojiById(emojiId2) : null : null);
|
|
}
|
|
export function useCustomStatusActivity() {
|
|
const setting = CustomStatusSetting.useSetting();
|
|
const emojiId = setting?.emojiId;
|
|
const stateFromStores = useStateFromStores([EmojiStore], () => emojiId != null ? emojiId !== "0" ? EmojiStore.getUsableCustomEmojiById(emojiId) : null : null, [emojiId]);
|
|
return useMemo(() => setting != null ? _activityFromSetting(setting, stateFromStores) : null, [setting, stateFromStores]);
|
|
}
|