159 lines
5.1 KiB
TypeScript
159 lines
5.1 KiB
TypeScript
// Metro module 13037 (f13038).
|
|
import { useState, useEffect, useMemo } from "react";
|
|
import ChannelStore from "../../../stores/ChannelStore";
|
|
import { SHARE_SCREEN_MODAL_KEY } from "./ShareScreenConstants";
|
|
import Logger from "../../debug/Logger";
|
|
import ModalActionCreators from "../../../actions/ModalActionCreators";
|
|
import Module8197 from "../../../_bundle/Module8197";
|
|
import { useStateFromStores } from "../../../_bundle/Module589";
|
|
import ChannelActionCreators from "../../../actions/ChannelActionCreators";
|
|
import { ChannelTypes } from "../../../_bundle/Module692";
|
|
import ShareScreen from "./ShareScreen";
|
|
let c8996_9;
|
|
const onClose = function onClose() {
|
|
ModalActionCreators.popWithKey(SHARE_SCREEN_MODAL_KEY);
|
|
};
|
|
c8996_9 = new Logger("ShareScreenModal");
|
|
export default function ShareScreenModal(props) {
|
|
let stateFromStores, setState2, state2;
|
|
const { text, channelId, shareId, attachmentManifest } = props;
|
|
stateFromStores = void 0;
|
|
setState2 = void 0;
|
|
state2 = void 0;
|
|
const [state, setState] = useState(null);
|
|
useEffect(() => {
|
|
let _fetchAttachments2 = function _fetchAttachments() {
|
|
const r9 = async () => {
|
|
let c31675_2;
|
|
let c31675_3 = 0;
|
|
let c32036_0, c32036_1;
|
|
L14: {
|
|
L13: {
|
|
try {
|
|
c32036_0 = void 0;
|
|
if (shareId === void 0) {
|
|
break L14;
|
|
}
|
|
if (attachmentManifest !== void 0) {
|
|
c31675_3 = 1;
|
|
c32036_0 = await Module8197.sharedAttachments(shareId, attachmentManifest);
|
|
(0, setState)(c32036_0);
|
|
c31675_3 = 0;
|
|
break L13;
|
|
}
|
|
break L14;
|
|
} catch ($e) {
|
|
const r25 = $e;
|
|
let r7 = r25;
|
|
c31675_2 = r25;
|
|
if (c31675_3 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r66 = c31675_2;
|
|
c31675_3 = 0;
|
|
c32036_1 = r66;
|
|
c8996_9.error("Error fetching attachments:", c32036_1);
|
|
break L13;
|
|
} catch (r62) {
|
|
r7 = r62;
|
|
c31675_2 = r62;
|
|
if (c31675_3 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r7;
|
|
}
|
|
}
|
|
return void 0;
|
|
}
|
|
};
|
|
_fetchAttachments2 = r9;
|
|
return r9.apply(this, arguments);
|
|
};
|
|
(function fetchAttachments() {
|
|
return _fetchAttachments2.apply(this, arguments);
|
|
})();
|
|
}, [shareId, attachmentManifest]);
|
|
stateFromStores = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(channelId));
|
|
let state3;
|
|
[state3, setState2] = useState(null);
|
|
useEffect(() => {
|
|
let _fetchChannel2 = function _fetchChannel() {
|
|
const r9 = async () => {
|
|
let c31676_2;
|
|
let c31676_3 = 0;
|
|
let c32037_0, c32037_1;
|
|
L14: {
|
|
L13: {
|
|
try {
|
|
c32037_0 = void 0;
|
|
if (channelId == null) {
|
|
break L14;
|
|
}
|
|
if (stateFromStores == null) {
|
|
c31676_3 = 1;
|
|
c32037_0 = await ChannelActionCreators.fetchChannel(channelId);
|
|
(0, setState2)(c32037_0);
|
|
c31676_3 = 0;
|
|
break L13;
|
|
}
|
|
break L14;
|
|
} catch ($e) {
|
|
const r25 = $e;
|
|
let r7 = r25;
|
|
c31676_2 = r25;
|
|
if (c31676_3 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r68 = c31676_2;
|
|
c31676_3 = 0;
|
|
c32037_1 = r68;
|
|
c8996_9.error("Error fetching channel:", c32037_1);
|
|
break L13;
|
|
} catch (r64) {
|
|
r7 = r64;
|
|
c31676_2 = r64;
|
|
if (c31676_3 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r7;
|
|
}
|
|
}
|
|
return void 0;
|
|
}
|
|
};
|
|
_fetchChannel2 = r9;
|
|
return r9.apply(this, arguments);
|
|
};
|
|
(function fetchChannel() {
|
|
return _fetchChannel2.apply(this, arguments);
|
|
})();
|
|
}, [channelId, stateFromStores]);
|
|
state2 = stateFromStores == null ? state3 : stateFromStores;
|
|
return <ShareScreen sharedContent={useMemo(() => {
|
|
let attachments = state;
|
|
if (state == null) {
|
|
attachments = [];
|
|
}
|
|
const r3 = {
|
|
text,
|
|
attachments
|
|
};
|
|
if (state2 != null) {
|
|
if (state2.type !== ChannelTypes.DM) {
|
|
r3.targetChannelId = channelId;
|
|
} else if ((state2 ? "recipients" in state2 : state2) && Array.isArray(state2.recipients)) {
|
|
r3.targetUserId = state2.recipients[0];
|
|
} else if ((state2 ? "recipient" in state2 : state2) && "id" in state2.recipient) {
|
|
r3.targetUserId = state2.recipient?.id;
|
|
}
|
|
}
|
|
return r3;
|
|
}, [text, state, channelId, state2])} onClose={onClose} />;
|
|
};
|