// Metro module 16656 (f16657). import SelectedChannelStore from "../../../stores/SelectedChannelStore"; import SelectedGuildStore from "../../../stores/SelectedGuildStore"; import UserStore from "../../../stores/UserStore"; import AppStateStore from "../../../stores/native/AppStateStore"; import { InAppNotificationTypes, MessageStates } from "../../../Constants"; import { LocalNotificationTypes } from "../../local_push_notification/native/Constants"; import InAppNotificationActionCreators from "../../../actions/native/InAppNotificationActionCreators"; import { generateInAppNotificationId } from "../../in_app_notifications/native/InAppNotificationUtils"; import PushNotification from "../../../lib/pushnotification/PushNotification"; import { intl, t } from "../../../intl/index.native"; import AutomaticLifecycleManager from "../../../lib/AutomaticLifecycleManager"; let handleMessageCreate; const handleMessageSendFailure = function handleMessageSendFailure(a0) { const { channelId, messageId } = a0; if (a0.shouldNotify) { if (AppStateStore.getState() !== "active") { PushNotification.presentLocalNotification({ category: "local", alertTitle: intl.string(t.LdlH2M), alertBody: intl.string(t.xxRPOT), userInfo: { channelId, messageId, type: LocalNotificationTypes.MESSAGE_SEND_FAILED } }); } else { if (channelId === SelectedChannelStore.getChannelId(SelectedGuildStore.getGuildId())) { return void 0; } InAppNotificationActionCreators.enqueueNotification({ type: InAppNotificationTypes.MESSAGE_FAILED_TO_SEND, channelId, messageId, key: channelId + "-" + messageId, duration: 5000, onDismiss: () => { InAppNotificationActionCreators.clearNotification(); }, inAppNotificationId: generateInAppNotificationId() }); } } }; handleMessageCreate = function handleMessageCreate(a0) { const message = a0.message; if (a0.sendMessageOptions?.isHydratingExpiredPendingMessage && message.state === MessageStates.SEND_FAILED && UserStore.getCurrentUser()?.id === message.author?.id) { setTimeout(() => { handleMessageSendFailure({ channelId: message.channel_id, messageId: message.id, shouldNotify: true }); }, 3000); } }; class MessageSendFailureNotificationManager extends AutomaticLifecycleManager { actions = { MESSAGE_CREATE: handleMessageCreate, MESSAGE_SEND_FAILED: handleMessageSendFailure }; } const messageSendFailureNotificationManager = new MessageSendFailureNotificationManager(); export default messageSendFailureNotificationManager;