36 lines
1.5 KiB
TypeScript
36 lines
1.5 KiB
TypeScript
// Metro module 9843 (f9844).
|
|
import { useCallback } from "react";
|
|
import { DraftType } from "../../../stores/DraftStore";
|
|
import UploadAttachmentStore from "../../../stores/UploadAttachmentStore";
|
|
import { useStateFromStores } from "../../../_bundle/defaultAreStatesEqual";
|
|
import { UploadPlatform } from "../../../lib/uploader/Upload";
|
|
import UploadAttachmentActionCreators from "../../../actions/UploadAttachmentActionCreators";
|
|
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
|
|
export default function useSetMediaPostThumbnail(a0, a1) {
|
|
const stateFromStores = useStateFromStores([UploadAttachmentStore], () => {
|
|
let r11 = UploadAttachmentStore.getUploads(a0, DraftType.ChannelMessage).find((item) => (item == null ? void 0 : item.item?.platform) === UploadPlatform.REACT_NATIVE && item.isThumbnail === true);
|
|
if (r11 == null) {
|
|
r11 = null;
|
|
}
|
|
return r11;
|
|
});
|
|
return useCallback(() => {
|
|
if (a1?.id != null) {
|
|
if (stateFromStores != null && stateFromStores.id !== a1?.id) {
|
|
UploadAttachmentActionCreators.update(a0, stateFromStores.id, DraftType.ChannelMessage, {
|
|
thumbnail: false
|
|
});
|
|
}
|
|
let r25 = a1?.isThumbnail;
|
|
if (r25 == null) {
|
|
r25 = false;
|
|
}
|
|
UploadAttachmentActionCreators.update(a0, a1?.id, DraftType.ChannelMessage, {
|
|
thumbnail: !r25,
|
|
spoiler: false
|
|
});
|
|
ActionSheetActionCreators.hideActionSheet();
|
|
}
|
|
}, [stateFromStores, a0, a1]);
|
|
};
|