decord/alpha/source/stores/PrivateChannelReadStateStore.tsx

205 lines
6.4 KiB
TypeScript
Raw Normal View History

// Module ID: 14030
// Function ID: 14031
// Name: PrivateChannelReadStateStore
// Dependencies: [2046, 2042, 4772, 2096, 7465, 2018, 504, 573, 2]
2026-07-20 16:05:17 +00:00
// Module 14030 (PrivateChannelReadStateStore)
import initializeDefault from "initialize" /* 504 */;
import DispatcherDefault from "Dispatcher" /* 573 */;
import FunctionUtils from "FunctionUtils" /* 2018 */;
import ChannelRecord from "ChannelRecord" /* 2046 */;
import ChannelStore from "ChannelStore" /* 2042 */;
import ReadStateStore from "ReadStateStore" /* 4772 */;
import SelectedChannelStore from "SelectedChannelStore" /* 2096 */;
import PrivateChannelSortStore from "PrivateChannelSortStore" /* 7465 */;
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
2026-07-20 16:05:17 +00:00
function rebuildUnreads() {
const privateChannelIds = PrivateChannelSortStore.getPrivateChannelIds();
found = privateChannelIds.filter((item) => mentionCount.getMentionCount(item) > 0);
2026-07-20 16:05:17 +00:00
if (found.length > 20) {
found.length = 20;
}
const result = FunctionUtils.areArraysShallowlyEqual(found, found);
2026-07-29 08:29:29 +00:00
let flag = !result;
if (!result) {
2026-07-20 16:05:17 +00:00
const _Set = Set;
2026-08-24 06:08:38 +00:00
set = new Set(found);
2026-07-20 16:05:17 +00:00
flag = true;
}
return flag;
}
function handleConnectionOpen() {
const privateChannelIds = PrivateChannelSortStore.getPrivateChannelIds();
found = privateChannelIds.filter((item) => mentionCount.getMentionCount(item) > 0);
2026-07-29 08:29:29 +00:00
if (found.length > 20) {
found.length = 20;
}
const result = FunctionUtils.areArraysShallowlyEqual(found, found);
2026-07-29 08:29:29 +00:00
let flag = !result;
if (!result) {
const _Set = Set;
2026-08-24 06:08:38 +00:00
set = new Set(found);
2026-07-29 08:29:29 +00:00
flag = true;
}
return flag;
2026-07-20 16:05:17 +00:00
}
function handleGenericUpdate(channelId) {
const channel = ChannelStore.getChannel(channelId.channelId);
2026-07-20 16:05:17 +00:00
let tmp2 = null == channel;
if (!tmp2) {
tmp2 = !isPrivate(channel.type);
}
let tmp4 = !tmp2;
if (!tmp2) {
const privateChannelIds = PrivateChannelSortStore.getPrivateChannelIds();
found = privateChannelIds.filter((item) => mentionCount.getMentionCount(item) > 0);
2026-07-29 08:29:29 +00:00
if (found.length > 20) {
found.length = 20;
}
const result = FunctionUtils.areArraysShallowlyEqual(found, found);
2026-07-29 08:29:29 +00:00
let flag = !result;
if (!result) {
const _Set = Set;
2026-08-24 06:08:38 +00:00
set = new Set(found);
2026-07-29 08:29:29 +00:00
flag = true;
}
tmp4 = flag;
2026-07-20 16:05:17 +00:00
}
return tmp4;
}
const isPrivate = ChannelRecord.isPrivate;
let found = [];
2026-07-23 10:11:24 +00:00
let set = new Set();
2026-08-24 06:08:38 +00:00
const Store = initializeDefault.Store;
2026-07-29 08:29:29 +00:00
class PrivateChannelReadStateStore extends Store {
}
const prototype = PrivateChannelReadStateStore.prototype;
prototype["initialize"] = function initialize() {
this.waitFor(PrivateChannelSortStore, ChannelStore, SelectedChannelStore, ReadStateStore);
2026-07-29 08:29:29 +00:00
};
prototype["getUnreadPrivateChannelIds"] = function getUnreadPrivateChannelIds() {
return found;
2026-07-29 08:29:29 +00:00
};
PrivateChannelReadStateStore.displayName = "PrivateChannelReadStateStore";
const privateChannelReadStateStore = new PrivateChannelReadStateStore(DispatcherDefault, {
2026-07-20 16:05:17 +00:00
CONNECTION_OPEN: handleConnectionOpen,
OVERLAY_INITIALIZE: handleConnectionOpen,
MESSAGE_CREATE: handleGenericUpdate,
MESSAGE_ACK: handleGenericUpdate,
CHANNEL_SELECT: function handleChannelSelect(channelId) {
const channel = ChannelStore.getChannel(channelId.channelId);
2026-07-20 16:05:17 +00:00
let tmp2 = null == channel;
if (!tmp2) {
tmp2 = !isPrivate(channel.type);
}
let tmp4 = !tmp2;
if (!tmp2) {
const privateChannelIds = PrivateChannelSortStore.getPrivateChannelIds();
found = privateChannelIds.filter((item) => mentionCount.getMentionCount(item) > 0);
2026-07-29 08:29:29 +00:00
if (found.length > 20) {
found.length = 20;
}
const result = FunctionUtils.areArraysShallowlyEqual(found, found);
2026-07-29 08:29:29 +00:00
let flag = !result;
if (!result) {
const _Set = Set;
2026-08-24 06:08:38 +00:00
set = new Set(found);
2026-07-29 08:29:29 +00:00
flag = true;
}
tmp4 = flag;
2026-07-20 16:05:17 +00:00
}
return tmp4;
},
CHANNEL_DELETE: function handleChannelDelete(channel) {
2026-07-29 08:29:29 +00:00
let hasItem = set.has(channel.channel.id);
if (hasItem) {
const privateChannelIds = PrivateChannelSortStore.getPrivateChannelIds();
found = privateChannelIds.filter((item) => mentionCount.getMentionCount(item) > 0);
2026-07-29 08:29:29 +00:00
if (found.length > 20) {
found.length = 20;
}
const result = FunctionUtils.areArraysShallowlyEqual(found, found);
2026-07-29 08:29:29 +00:00
let flag = !result;
if (!result) {
const _Set = Set;
set = new Set(found);
flag = true;
}
hasItem = flag;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return hasItem;
2026-07-20 16:05:17 +00:00
},
WINDOW_FOCUS: function handleWindowFocus() {
const channel = ChannelStore.getChannel(SelectedChannelStore.getChannelId());
2026-07-20 16:05:17 +00:00
let tmp2 = null == channel;
if (!tmp2) {
tmp2 = !isPrivate(channel.type);
}
let tmp4 = !tmp2;
if (!tmp2) {
const privateChannelIds = PrivateChannelSortStore.getPrivateChannelIds();
found = privateChannelIds.filter((item) => mentionCount.getMentionCount(item) > 0);
2026-07-29 08:29:29 +00:00
if (found.length > 20) {
found.length = 20;
}
const result = FunctionUtils.areArraysShallowlyEqual(found, found);
2026-07-29 08:29:29 +00:00
let flag = !result;
if (!result) {
const _Set = Set;
2026-08-24 06:08:38 +00:00
set = new Set(found);
2026-07-29 08:29:29 +00:00
flag = true;
}
tmp4 = flag;
2026-07-20 16:05:17 +00:00
}
return tmp4;
},
CHANNEL_CREATE: function handleChannelCreate(channel) {
channel = ChannelStore.getChannel(channel.channel.id);
2026-07-20 16:05:17 +00:00
let tmp2 = null == channel;
if (!tmp2) {
tmp2 = !isPrivate(channel.type);
}
let tmp4 = !tmp2;
if (!tmp2) {
const privateChannelIds = PrivateChannelSortStore.getPrivateChannelIds();
found = privateChannelIds.filter((item) => mentionCount.getMentionCount(item) > 0);
2026-07-29 08:29:29 +00:00
if (found.length > 20) {
found.length = 20;
}
const result = FunctionUtils.areArraysShallowlyEqual(found, found);
2026-07-29 08:29:29 +00:00
let flag = !result;
if (!result) {
const _Set = Set;
2026-08-24 06:08:38 +00:00
set = new Set(found);
2026-07-29 08:29:29 +00:00
flag = true;
}
tmp4 = flag;
2026-07-20 16:05:17 +00:00
}
return tmp4;
},
2026-07-29 08:29:29 +00:00
CHANNEL_UPDATES: function handleChannelUpdates(arg0) {
2026-07-20 16:05:17 +00:00
let flag = false;
2026-07-29 08:29:29 +00:00
const iter = arg0.channels[Symbol.iterator]();
while (iter !== undefined) {
let channel = ChannelStore.getChannel(iter.next().id);
2026-07-29 08:29:29 +00:00
let tmp4 = null != channel;
if (tmp4) {
tmp4 = isPrivate(tmp3.type);
}
if (tmp4) {
flag = true;
}
continue;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let tmp7 = flag;
if (tmp7) {
tmp7 = rebuildUnreads();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp7;
2026-07-20 16:05:17 +00:00
}
});
let result = size.fileFinishedImporting("stores/PrivateChannelReadStateStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default privateChannelReadStateStore;