74 lines
2.3 KiB
TypeScript
74 lines
2.3 KiB
TypeScript
// Metro module 10481 (f10482).
|
|
import { useMemo, useEffect } from "react";
|
|
import PresenceSubscriptionsStore from "../presence_subscriptions/PresenceSubscriptionsStore";
|
|
import PresenceStore from "../../stores/PresenceStore";
|
|
import { useStateFromStoresArray } from "../../_bundle/Module589";
|
|
import { subscribe } from "../presence_subscriptions/PresenceSubscriptionsActionCreators";
|
|
let c7027_6 = [];
|
|
let c7027_7 = [];
|
|
let c7027_8 = [];
|
|
export default function useSubscribeMissingActivities(a0, a1) {
|
|
let c17994_0;
|
|
let c17995_2, stateFromStoresArray;
|
|
let c17995_0 = a0;
|
|
const [r10, r17] = useMemo(() => {
|
|
let r9;
|
|
if (a1.isPrivate()) {
|
|
const r12 = c17995_0.filter((item) => item.application?.id != null && item.activity?.party_id != null);
|
|
r9 = [r12, r12.map((item) => item.id)];
|
|
} else {
|
|
r9 = [c7027_8, c7027_7];
|
|
}
|
|
return r9;
|
|
}, [a0, a1]);
|
|
c17995_2 = r10;
|
|
stateFromStoresArray = useStateFromStoresArray([PresenceStore], () => {
|
|
const r4 = [];
|
|
let c26681_0 = r4;
|
|
c17995_2.forEach((item) => {
|
|
if (PresenceStore.findActivity(item.author.id, (a0) => {
|
|
const application_id = a0.application_id;
|
|
return application_id === item.application?.id && a0.party?.id === item.activity?.party_id;
|
|
}, null, true) != null) {
|
|
c26681_0.push(item.id);
|
|
}
|
|
});
|
|
return r4;
|
|
}, [r10]);
|
|
const [r32, r33] = [r17, useMemo(() => {
|
|
let r7;
|
|
let c26682_1;
|
|
const stateFromStoresArray2 = stateFromStoresArray;
|
|
if (c17995_2.length === 0) {
|
|
r7 = c7027_6;
|
|
} else {
|
|
r7 = [];
|
|
c26682_1 = r7;
|
|
c17995_2.forEach((item) => {
|
|
const id = item.application?.id;
|
|
const party_id = item.activity?.party_id;
|
|
if (!(item.id in stateFromStoresArray2) && id != null && party_id != null) {
|
|
c26682_1.push({
|
|
userId: item.author.id,
|
|
applicationId: id,
|
|
partyId: party_id,
|
|
messageId: item.id,
|
|
channelId: item.channel_id,
|
|
inviteTime: item.timestamp.getTime()
|
|
});
|
|
}
|
|
});
|
|
}
|
|
return r7;
|
|
}, [r10, stateFromStoresArray])];
|
|
c17994_0 = r33;
|
|
useEffect(() => {
|
|
for (const item of c17994_0) {
|
|
if (!PresenceSubscriptionsStore.isSubscribed(item)) {
|
|
subscribe(item);
|
|
}
|
|
}
|
|
}, [r33]);
|
|
return [r32, r33];
|
|
};
|