163 lines
5.1 KiB
TypeScript
163 lines
5.1 KiB
TypeScript
// Metro module 15454 (f15455).
|
|
import _slicedToArray from "../../../_bundle/_slicedToArray";
|
|
import { useRef, useState, useCallback } from "react";
|
|
import { MAX_RESULTS_PER_PAGE, MAX_VISIBLE_PAGES, GuildJoinRequestApplicationStatuses, GuildJoinRequestSortOrders } from "../MemberVerificationTypes";
|
|
import SnowflakeUtils from "../../../utils/SnowflakeUtils";
|
|
import GuildJoinRequestActionCreators from "../GuildJoinRequestActionCreators";
|
|
import { APIError } from "../../../errors/index";
|
|
let env10990 = {};
|
|
const c10990_6 = MAX_RESULTS_PER_PAGE * MAX_VISIBLE_PAGES;
|
|
export { c10990_6 as MEMBER_APPLICATION_FETCH_LIMIT };
|
|
export function usePaginatedMemberApplications(a0) {
|
|
let env22017 = {
|
|
$parent: env10990
|
|
};
|
|
const guildId = a0.guildId;
|
|
env22017[0] = guildId;
|
|
const guildJoinRequests = a0.guildJoinRequests;
|
|
env22017[1] = guildJoinRequests;
|
|
env22017[2] = void 0;
|
|
env22017[3] = void 0;
|
|
env22017[4] = void 0;
|
|
env22017[5] = void 0;
|
|
env22017[6] = void 0;
|
|
env22017[2] = useRef(false);
|
|
const r16 = _slicedToArray(useState(null), 2);
|
|
const error = r16[0];
|
|
env22017[3] = error;
|
|
env22017[4] = r16[1];
|
|
env22017[5] = useRef(null);
|
|
env22017[6] = useRef(false);
|
|
let c22018_0 = async (c30876_0, status) => {
|
|
let c30876_2, c30876_3, c30876_4;
|
|
let c30876_5 = 0;
|
|
const r11 = void 0;
|
|
const r10 = env10990;
|
|
L23: {
|
|
L22: {
|
|
try {
|
|
let env31761;
|
|
c30876_3 = r11;
|
|
const r39 = env31761 = {
|
|
$parent: r10
|
|
};
|
|
c30876_2 = r39;
|
|
env31761[0] = void 0;
|
|
env31761[1] = void 0;
|
|
if (env22017[2].current) {
|
|
break L23;
|
|
}
|
|
const current2 = `${c30876_0}-${status}`;
|
|
const r45 = env22017[5];
|
|
const current = r45.current;
|
|
let r22 = false;
|
|
if (current2 === current) {
|
|
if (env22017[6].current) {
|
|
break L23;
|
|
}
|
|
} else {
|
|
r45.current = current2;
|
|
env22017[6].current = false;
|
|
r22 = true;
|
|
if (env22017[6].current) {
|
|
break L23;
|
|
}
|
|
}
|
|
if (env22017[3] != null) {
|
|
(0, env22017[4])(null);
|
|
}
|
|
const guildId = env22017[0];
|
|
const r54 = (function getRequestPaginationParams(a0, a1, a2, a3, a4) {
|
|
const r3 = a3 === GuildJoinRequestApplicationStatuses.SUBMITTED;
|
|
if (a2 === GuildJoinRequestSortOrders.TIMESTAMP_DESC) {
|
|
if (!a4 && a1.length !== 0) {
|
|
const r34 = a1[a1.length - 1];
|
|
return {
|
|
before: r3 ? r34.joinRequestId : r34.actionedAt
|
|
};
|
|
}
|
|
return {
|
|
before: SnowflakeUtils.fromTimestamp(new Date().getTime())
|
|
};
|
|
}
|
|
if (!a4 && a1.length !== 0) {
|
|
const r24 = a1[a1.length - 1];
|
|
return {
|
|
after: r3 ? r24.joinRequestId : r24.actionedAt
|
|
};
|
|
}
|
|
return {
|
|
after: a0
|
|
};
|
|
})(guildId, env22017[1], c30876_0, status, r22);
|
|
c30876_5 = 2;
|
|
env22017[2].current = true;
|
|
env31761[0] = await GuildJoinRequestActionCreators.fetchGuildJoinRequests({
|
|
guildId,
|
|
status,
|
|
limit: c10990_6,
|
|
force: true,
|
|
...r54
|
|
});
|
|
if (env31761[0] != null && env31761[0].body.guild_join_requests.length < c10990_6) {
|
|
env22017[6].current = true;
|
|
}
|
|
c30876_5 = 1;
|
|
c30876_5 = 0;
|
|
env22017[2].current = false;
|
|
} catch ($e) {
|
|
const r37 = $e;
|
|
let r7 = r37;
|
|
c30876_4 = r37;
|
|
let r38 = c30876_5;
|
|
if (r38 !== 0) {
|
|
while (true) {
|
|
if (r38 === 1) {
|
|
try {
|
|
const r141 = c30876_4;
|
|
c30876_5 = 0;
|
|
env22017[2].current = false;
|
|
throw r141;
|
|
} catch (r139) {
|
|
r7 = r139;
|
|
c30876_4 = r139;
|
|
r38 = c30876_5;
|
|
if (r38 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
try {
|
|
const r114 = c30876_4;
|
|
c30876_5 = 1;
|
|
env31761[2] = r114;
|
|
env31761[1] = new APIError(env31761[2]);
|
|
(0, env22017[4])(env31761[1].getAnyErrorMessage());
|
|
c30876_5 = 0;
|
|
env22017[2].current = false;
|
|
break L22;
|
|
} catch (r111) {
|
|
r7 = r111;
|
|
c30876_4 = r111;
|
|
r38 = c30876_5;
|
|
if (r38 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r7;
|
|
}
|
|
}
|
|
return void 0;
|
|
}
|
|
};
|
|
return {
|
|
fetchNextPage: useCallback(function() {
|
|
return c22018_0.apply(this, arguments);
|
|
}, [error, guildId, guildJoinRequests]),
|
|
error
|
|
};
|
|
}
|