43 lines
2.1 KiB
TypeScript
43 lines
2.1 KiB
TypeScript
// Metro module 14970 (f14971).
|
|
import ActiveJoinedThreadsStore from "../../threads/ActiveJoinedThreadsStore";
|
|
import JoinedThreadsStore from "../../threads/JoinedThreadsStore";
|
|
import ChannelStore from "../../../stores/ChannelStore";
|
|
import GuildReadStateStore from "../../../stores/GuildReadStateStore";
|
|
import PermissionStore from "../../../stores/PermissionStore";
|
|
import ReadStateStore from "../../../stores/ReadStateStore";
|
|
import UserGuildSettingsStore from "../../../stores/UserGuildSettingsStore";
|
|
import { useStateFromStoresObject } from "../../../_bundle/Module589";
|
|
import SnowflakeUtils from "../../../utils/SnowflakeUtils";
|
|
export default function useFavoritesGuildUnreads(c21493_0) {
|
|
return useStateFromStoresObject([ActiveJoinedThreadsStore, ChannelStore, GuildReadStateStore, JoinedThreadsStore, PermissionStore, ReadStateStore, UserGuildSettingsStore], () => {
|
|
const r13 = SnowflakeUtils.keys(c21493_0);
|
|
let c27877_0 = new Set();
|
|
return r13.reduce((acc, item) => {
|
|
const channel = ChannelStore.getChannel(item);
|
|
const r7 = channel == null ? void 0 : channel.getGuildId();
|
|
const mentionCount = ReadStateStore.getMentionCount(item);
|
|
if (!c27877_0.has(item)) {
|
|
c27877_0.add(item);
|
|
acc.badge = acc.badge + mentionCount;
|
|
}
|
|
acc.unread = acc.unread || ReadStateStore.hasUnread(item) && GuildReadStateStore.shouldCountChannelUnread(channel, mentionCount);
|
|
if (r7 != null) {
|
|
const activeJoinedRelevantThreadsForParent = ActiveJoinedThreadsStore.getActiveJoinedRelevantThreadsForParent(r7, item);
|
|
for (const key in activeJoinedRelevantThreadsForParent) {
|
|
const mentionCount2 = ReadStateStore.getMentionCount(key);
|
|
if (!c27877_0.has(key)) {
|
|
c27877_0.add(key);
|
|
acc.badge = acc.badge + mentionCount2;
|
|
}
|
|
const channel2 = ChannelStore.getChannel(key);
|
|
acc.unread = acc.unread || ReadStateStore.hasUnread(key) && GuildReadStateStore.shouldCountChannelUnread(channel2, mentionCount2);
|
|
}
|
|
}
|
|
return acc;
|
|
}, {
|
|
badge: 0,
|
|
unread: false
|
|
});
|
|
});
|
|
};
|