62 lines
2.1 KiB
TypeScript
62 lines
2.1 KiB
TypeScript
// Metro module 8183 (f8184).
|
|
import Durations from "../../utils/Durations";
|
|
import { ICYMIItemTypes } from "./ICYMITypes";
|
|
import { isItemUnreadInChannel } from "./ICYMIUtils";
|
|
import Module589 from "../../_bundle/Module589";
|
|
import Dispatcher from "../../Dispatcher";
|
|
let c5197_2 = 7 * Durations.Millis.DAY;
|
|
let c5197_3 = {
|
|
readIdToTimestampMap: {}
|
|
};
|
|
class ICYMIUnreadStateStore extends Module589.DeviceSettingsStore {
|
|
static displayName = "ICYMIUnreadStateStore";
|
|
static persistKey = "ICYMIUnreadStateStore";
|
|
initialize(a0) {
|
|
const r18 = a0 != null && a0.readIdToTimestampMap != null ? {
|
|
readIdToTimestampMap: a0.readIdToTimestampMap
|
|
} : {
|
|
readIdToTimestampMap: {}
|
|
};
|
|
c5197_3 = r18;
|
|
let c16329_0 = Date.now() - c5197_2;
|
|
for (const item of Object.keys(c5197_3.readIdToTimestampMap).filter((item) => c5197_3.readIdToTimestampMap[item] < c16329_0)) {
|
|
delete c5197_3.readIdToTimestampMap[item];
|
|
}
|
|
}
|
|
getReadTimestamp(a0) {
|
|
return c5197_3.readIdToTimestampMap[a0];
|
|
}
|
|
getState() {
|
|
return c5197_3;
|
|
}
|
|
getUserAgnosticState() {
|
|
return c5197_3;
|
|
}
|
|
}
|
|
const iCYMIUnreadStateStore = new ICYMIUnreadStateStore(Dispatcher, {
|
|
ICYMI_ACK_ITEMS: function handleTabAck({ items, override }) {
|
|
items.forEach((item) => {
|
|
if (item != null && (c5197_3.readIdToTimestampMap[item.id] == null || override)) {
|
|
c5197_3.readIdToTimestampMap[item.id] = item.timestamp;
|
|
}
|
|
});
|
|
},
|
|
LOAD_ICYMI_DEHYDRATED: function handleLoadDehydrated(a0) {
|
|
for (const item of a0.items) {
|
|
if (item.type === ICYMIItemTypes.MESSAGE) {
|
|
let r40 = c5197_3.readIdToTimestampMap[item.id] != null || item.data.message_context?.external_content_application_id != null;
|
|
if (!r40) {
|
|
r40 = isItemUnreadInChannel(item.data.channel_id, item.data.message_id);
|
|
}
|
|
if (!r40) {
|
|
c5197_3.readIdToTimestampMap[item.id] = 0;
|
|
}
|
|
}
|
|
}
|
|
},
|
|
CLEAR_ICYMI_READ_STATES: function handleClearReadStates() {
|
|
c5197_3.readIdToTimestampMap = {};
|
|
}
|
|
});
|
|
export default iCYMIUnreadStateStore;
|