decord/source/modules/notification_center/NotificationCenterStore.tsx

128 lines
4.1 KiB
TypeScript
Raw Normal View History

// Module ID: 16507
// Function ID: 16508
// Name: NotificationCenterStore
// Dependencies: [32, 7739, 1090, 504, 7742, 11, 573, 2]
2026-07-20 16:05:17 +00:00
// Module 16507 (NotificationCenterStore)
import SnowflakeUtilsDefault from "SnowflakeUtils" /* 11 */;
import initializeDefault from "initialize" /* 504 */;
import DispatcherDefault from "Dispatcher" /* 573 */;
import DurationsDefault from "Durations" /* 1090 */;
import NotificationCenterItemsTypes from "NotificationCenterItemsTypes" /* 7742 */;
import _slicedToArray from "module_32" /* 32 */;
import RecentMentionsStore from "RecentMentionsStore" /* 7739 */;
2026-07-23 10:11:24 +00:00
require = fn;
2026-07-20 16:05:17 +00:00
function handleLoadFinished() {
obj.hasNewMentions = false;
obj.isDataStale = false;
obj.isRefreshing = false;
2026-07-20 16:05:17 +00:00
}
let closure_5 = 90 * DurationsDefault.Millis.DAY;
let obj = { tab: null, localItemAcks: {}, hasNewMentions: false, isDataStale: false, isRefreshing: false };
2026-08-24 06:08:38 +00:00
const PersistedStore = initializeDefault.PersistedStore;
2026-07-29 08:29:29 +00:00
class NotificationCenterStore extends PersistedStore {
}
const prototype = NotificationCenterStore.prototype;
prototype["initialize"] = function initialize(localItemAcks) {
this.waitFor(RecentMentionsStore);
2026-07-29 08:29:29 +00:00
if (null != localItemAcks) {
localItemAcks = localItemAcks.localItemAcks;
if (localItemAcks == null) {
localItemAcks = {};
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
localItemAcks.localItemAcks = (function purge(localItemAcks) {
obj = {};
2026-07-29 08:29:29 +00:00
const entries = Object.entries(localItemAcks);
while (tmp2 !== undefined) {
let tmp5 = _slicedToArray(tmp3, 2);
2026-07-29 08:29:29 +00:00
[tmp6, tmp7] = tmp5;
let _Date = Date;
let tmp8 = tmp7;
if (Date.now() - tmp7 < closure_1_5) {
2026-07-29 08:29:29 +00:00
obj[tmp6] = tmp8;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
continue;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return obj;
})(localItemAcks);
localItemAcks.isDataStale = true;
2026-07-29 08:29:29 +00:00
}
};
prototype["getState"] = function getState() {
return obj;
2026-07-29 08:29:29 +00:00
};
prototype["getTab"] = function getTab() {
let ForYou = obj.tab;
2026-07-29 08:29:29 +00:00
if (ForYou == null) {
ForYou = NotificationCenterItemsTypes.NotificationCenterTabs.ForYou;
2026-07-29 08:29:29 +00:00
}
return ForYou;
};
prototype["isLocalItemAcked"] = function isLocalItemAcked(addResult) {
let tmp = null != addResult.local_id;
if (tmp) {
let tmp3 = null != obj.localItemAcks[addResult.local_id];
2026-07-29 08:29:29 +00:00
if (!tmp3) {
obj = SnowflakeUtilsDefault;
tmp3 = obj.age(addResult.id) > closure_5;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp = tmp3;
}
return tmp;
};
prototype["hasNewMentions"] = function hasNewMentions() {
return obj.hasNewMentions;
2026-07-29 08:29:29 +00:00
};
prototype["isDataStale"] = function isDataStale() {
return obj.isDataStale;
2026-07-29 08:29:29 +00:00
};
prototype["isRefreshing"] = function isRefreshing() {
return obj.isRefreshing;
2026-07-29 08:29:29 +00:00
};
prototype["shouldReload"] = function shouldReload() {
let isRefreshing = obj.hasNewMentions;
2026-07-29 08:29:29 +00:00
if (!isRefreshing) {
isRefreshing = obj.isDataStale;
2026-07-29 08:29:29 +00:00
}
if (!isRefreshing) {
isRefreshing = obj.isRefreshing;
2026-07-29 08:29:29 +00:00
}
return isRefreshing;
};
NotificationCenterStore.displayName = "NotificationCenterStore";
NotificationCenterStore.persistKey = "NotificationCenterStore";
obj = {
2026-07-20 16:05:17 +00:00
MESSAGE_CREATE: function handleMessageCreate(message) {
if (RecentMentionsStore.hasMention(message.message.id)) {
obj.hasNewMentions = true;
2026-07-20 16:05:17 +00:00
}
},
NOTIFICATION_CENTER_SET_TAB: function handleSetTab(tab) {
obj = {};
2026-07-23 10:11:24 +00:00
const merged = Object.assign(obj);
2026-07-29 08:29:29 +00:00
obj.tab = tab.tab;
2026-07-20 16:05:17 +00:00
},
NOTIFICATION_CENTER_ITEMS_LOCAL_ACK: function handleAck(localIds) {
localIds = localIds.localIds;
const item = localIds.forEach((item) => {
2026-07-20 16:05:17 +00:00
obj = {};
const merged = Object.assign(obj);
const obj2 = {};
2026-07-29 08:29:29 +00:00
const merged1 = Object.assign(obj.localItemAcks);
obj2[item] = Date.now();
obj.localItemAcks = obj2;
2026-07-20 16:05:17 +00:00
});
},
NOTIFICATION_CENTER_REFRESH: function handleRefreshData() {
obj.isRefreshing = true;
2026-07-20 16:05:17 +00:00
},
LOAD_NOTIFICATION_CENTER_ITEMS_FAILURE: handleLoadFinished,
LOAD_NOTIFICATION_CENTER_ITEMS_SUCCESS: handleLoadFinished
};
const notificationCenterStore = new NotificationCenterStore(DispatcherDefault, obj);
const size = fn(2);
const result = size.fileFinishedImporting("modules/notification_center/NotificationCenterStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default notificationCenterStore;