decord/source/modules/messages/VoiceSessionUtils.tsx

133 lines
5.2 KiB
TypeScript
Raw Normal View History

// Module ID: 8176
// Function ID: 8177
// Name: VoiceSessionUtils
// Dependencies: [19, 7761, 1957, 1371, 8177, 504, 8084, 4869, 1114, 12, 2]
2026-07-29 08:29:29 +00:00
// Exports: getSortedVoiceSessionParticipants, getVoiceSessionMessageContent, useSortedVoiceSessionParticipants
2026-07-20 16:05:17 +00:00
// Module 8176 (VoiceSessionUtils)
import useMessageAuthor from "useMessageAuthor" /* 4869 */;
import getHumanizedCallDurationDefault from "getHumanizedCallDuration" /* 8084 */;
import maybeSortByProbability from "maybeSortByProbability" /* 8177 */;
import noop from "module_19" /* 19 */;
import UserAffinitiesV2Store from "UserAffinitiesV2Store" /* 7761 */;
import ChannelStore from "ChannelStore" /* 1957 */;
import UserStore from "UserStore" /* 1371 */;
2026-07-23 10:11:24 +00:00
const require = globalThis.__r;
require = fn;
const size = fn(2);
let result = size.fileFinishedImporting("modules/messages/VoiceSessionUtils.tsx");
2026-07-29 08:29:29 +00:00
export const getSortedVoiceSessionParticipants = function getSortedVoiceSessionParticipants(message) {
_require = message;
2026-07-29 08:29:29 +00:00
const call = message.call;
let reduced;
if (call != null) {
const participants = call.participants;
reduced = participants.reduce((acc, item) => {
const user = UserStore.getUser(item);
let tmp2 = acc;
2026-07-29 08:29:29 +00:00
if (null != user) {
tmp2 = acc;
if (user.id !== author.author.id) {
2026-07-29 08:29:29 +00:00
const items = [];
items[HermesBuiltin.arraySpread(acc, 0)] = user;
2026-07-29 08:29:29 +00:00
tmp2 = items;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}
return tmp2;
}, []);
}
if (reduced == null) {
reduced = [];
}
const userAffinitiesMap = UserAffinitiesV2Store.getUserAffinitiesMap();
return require("maybeSortByProbability").maybeSortByProbability(reduced, userAffinitiesMap, "VoiceSessionUtils - participants");
2026-07-29 08:29:29 +00:00
};
export const useSortedVoiceSessionParticipants = function useSortedVoiceSessionParticipants(author) {
closure_129_0 = author;
const items = [UserStore];
2026-07-29 08:29:29 +00:00
const items1 = [author.author.id, author.call];
stateFromStoresArray = stateFromStoresArray(504).useStateFromStoresArray(items, () => {
2026-07-29 08:29:29 +00:00
const call = stateFromStoresArray.call;
let participants;
if (call != null) {
participants = call.participants;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (null != participants) {
const participants1 = stateFromStoresArray.call.participants;
const mapped = participants1.map((item) => user.getUser(item));
const found = mapped.filter((item) => null != item);
2026-07-29 08:29:29 +00:00
let found1 = found.filter((id) => id.id !== author.author.id);
} else {
found1 = [];
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return found1;
}, items1);
const obj = stateFromStoresArray(504);
const items2 = [UserAffinitiesV2Store];
const stateFromStores = stateFromStoresArray(504).useStateFromStores(items2, () => userAffinitiesMap.getUserAffinitiesMap(), []);
2026-07-29 08:29:29 +00:00
const items3 = [stateFromStoresArray, stateFromStores];
return noop.useMemo(() => maybeSortByProbability.maybeSortByProbability(stateFromStoresArray, stateFromStores, "VoiceSessionUtils - participants"), items3);
2026-07-20 16:05:17 +00:00
};
export const getVoiceSessionMessageContent = function getVoiceSessionMessageContent(channel_id) {
_require = ChannelStore.getChannel(channel_id.channel_id);
2026-08-24 06:08:38 +00:00
let tmp2 = getHumanizedCallDurationDefault(channel_id);
const messageAuthor = require("useMessageAuthor").getMessageAuthor(channel_id);
closure_129_0 = channel_id;
2026-07-29 08:29:29 +00:00
const call = channel_id.call;
let reduced;
if (call != null) {
const participants = call.participants;
reduced = participants.reduce((acc, item) => {
const user = UserStore.getUser(item);
let tmp2 = acc;
2026-07-29 08:29:29 +00:00
if (null != user) {
tmp2 = acc;
if (user.id !== author.author.id) {
2026-07-29 08:29:29 +00:00
const items = [];
items[HermesBuiltin.arraySpread(acc, 0)] = user;
2026-07-29 08:29:29 +00:00
tmp2 = items;
}
}
return tmp2;
}, []);
}
if (reduced == null) {
reduced = [];
}
const userAffinitiesMap = UserAffinitiesV2Store.getUserAffinitiesMap();
let obj = require("useMessageAuthor");
const result = require("maybeSortByProbability").maybeSortByProbability(reduced, userAffinitiesMap, "VoiceSessionUtils - participants");
2026-07-29 08:29:29 +00:00
const mapped = result.map((user) => {
const obj = { user, messageAuthor: useMessageAuthor.getUserAuthor(user, closure_0) };
2026-07-20 16:05:17 +00:00
return obj;
});
2026-07-29 08:29:29 +00:00
if (null == tmp2) {
const intl = tmp3(1114).intl;
const obj2 = { username: messageAuthor.nick, usernameOnClick: tmp3(12).identity };
let formatToPlainStringResult = intl.formatToPlainString(tmp3(1114).t.HzBfIN, obj2);
2026-07-20 16:05:17 +00:00
} else {
const intl2 = tmp3(1114).intl;
const obj3 = { userCount: mapped.length + 1, username: messageAuthor.nick, usernameOnClick: tmp3(12).identity, username2: null, username2OnClick: null, username3: null, username3OnClick: null, otherCount: null, duration: null };
2026-07-20 16:05:17 +00:00
const first = mapped[0];
let nick;
2026-07-29 08:29:29 +00:00
if (first != null) {
2026-07-20 16:05:17 +00:00
nick = first.messageAuthor.nick;
}
obj3.username2 = nick;
obj3.username2OnClick = tmp3(12).identity;
2026-07-20 16:05:17 +00:00
let nick1;
2026-07-29 08:29:29 +00:00
if (mapped[1] != null) {
nick1 = tmp7.messageAuthor.nick;
2026-07-20 16:05:17 +00:00
}
obj3.username3 = nick1;
obj3.username3OnClick = tmp3(12).identity;
obj3.otherCount = mapped.length - 1;
obj3.duration = tmp2;
formatToPlainStringResult = intl2.formatToPlainString(tmp3(1114).t.atbXuX, obj3);
2026-07-20 16:05:17 +00:00
}
return formatToPlainStringResult;
};