125 lines
4.1 KiB
TypeScript
125 lines
4.1 KiB
TypeScript
// Metro module 9942 (f9943).
|
|
import { useMemo } from "react";
|
|
import { UnknownChannelRecord } from "../../records/ChannelRecord";
|
|
import ChannelStore from "../../stores/ChannelStore";
|
|
import { ChannelTypes, Routes } from "../../Constants";
|
|
import { t, intl } from "../../intl/index.native";
|
|
import Module3771 from "../../_bundle/Module3771";
|
|
import { useStateFromStores } from "../../_bundle/Module589";
|
|
import ChannelActionCreators from "../../actions/ChannelActionCreators";
|
|
import safeTransitionTo_native from "../links/safeTransitionTo.native";
|
|
let c6607_9 = {
|
|
LONG: 0,
|
|
0: "LONG",
|
|
SHORT: 1,
|
|
1: "SHORT"
|
|
};
|
|
export { c6607_9 as DueInStringTypes };
|
|
export function useDueInString({ dueAt, now, type }) {
|
|
if (dueAt == null) {
|
|
return {
|
|
string: "",
|
|
isOverdue: false
|
|
};
|
|
}
|
|
let r6 = type === c6607_9.LONG ? t.TjNWNF : t.H4gnX9;
|
|
const r29 = type === c6607_9.LONG ? t.haia16 : t["Uq7Y+7"];
|
|
const isOverdue = now > dueAt;
|
|
if (isOverdue) {
|
|
r6 = r29;
|
|
}
|
|
return {
|
|
dueInText: intl.formatToPlainString(r6, {
|
|
duration: Module3771.duration(dueAt.getTime() - now.getTime(), "millisecond").humanize()
|
|
}),
|
|
isOverdue
|
|
};
|
|
}
|
|
export function useSavedMessageChannel(a0) {
|
|
const stateFromStores = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(a0.saveData.channelId));
|
|
return useMemo(() => {
|
|
let r2 = stateFromStores;
|
|
if (stateFromStores == null) {
|
|
r2 = a0.message != null ? new UnknownChannelRecord({
|
|
id: a0.saveData.channelId,
|
|
guild_id: a0.saveData.guildId,
|
|
type: ChannelTypes.UNKNOWN,
|
|
name: intl.string(t.J90oLW)
|
|
}) : void 0;
|
|
}
|
|
return r2;
|
|
}, [stateFromStores, a0]);
|
|
}
|
|
export async function savedMessageJumpToMessage(c26572_0, c26572_1) {
|
|
let c26572_2, c26572_3, c26572_4;
|
|
let c26572_5 = 0;
|
|
const r10 = void 0;
|
|
L28: {
|
|
L23: {
|
|
L25: {
|
|
L24: {
|
|
try {
|
|
let env30163;
|
|
c26572_3 = r10;
|
|
const r16 = env30163 = {};
|
|
c26572_2 = r16;
|
|
env30163[0] = c26572_0;
|
|
env30163[1] = c26572_1;
|
|
env30163[2] = void 0;
|
|
if (c26572_1?.type === ChannelTypes.UNKNOWN && c26572_0.saveData.guildId == null) {
|
|
c26572_5 = 1;
|
|
env30163[2] = await ChannelActionCreators.fetchChannel(c26572_0.saveData.channelId);
|
|
if (env30163[2].recipients == null) {
|
|
c26572_5 = 0;
|
|
break L25;
|
|
}
|
|
if (env30163[2].recipients.length > 1) {
|
|
c26572_5 = 0;
|
|
break L24;
|
|
}
|
|
await ChannelActionCreators.ensurePrivateChannel(env30163[2].recipients.map((recipient) => recipient.id));
|
|
c26572_5 = 0;
|
|
const r117 = env30163[1];
|
|
safeTransitionTo_native(Routes.CHANNEL(r117 == null ? void 0 : r117.getGuildId(), env30163[0].saveData.channelId, env30163[0].saveData.messageId), {
|
|
openChannel: true
|
|
});
|
|
break L23;
|
|
}
|
|
const r42 = env30163[1];
|
|
safeTransitionTo_native(Routes.CHANNEL(r42 == null ? void 0 : r42.getGuildId(), env30163[0].saveData.channelId, env30163[0].saveData.messageId), {
|
|
openChannel: true
|
|
});
|
|
break L28;
|
|
} catch ($e) {
|
|
const r31 = $e;
|
|
let r8 = r31;
|
|
c26572_4 = r31;
|
|
if (c26572_5 !== 0) {
|
|
while (true) {
|
|
try {
|
|
c26572_5 = 0;
|
|
const r158 = env30163[1];
|
|
safeTransitionTo_native(Routes.CHANNEL(r158 == null ? void 0 : r158.getGuildId(), env30163[0].saveData.channelId, env30163[0].saveData.messageId), {
|
|
openChannel: true
|
|
});
|
|
break L23;
|
|
} catch (r147) {
|
|
r8 = r147;
|
|
c26572_4 = r147;
|
|
if (c26572_5 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
}
|
|
return void 0;
|
|
}
|
|
return void 0;
|
|
}
|
|
return void 0;
|
|
}
|
|
}
|