Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4943.js (118.4 MB)
130 lines
3.6 KiB
TypeScript
130 lines
3.6 KiB
TypeScript
// Module ID: 11602
|
|
// Function ID: 11603
|
|
// Name: ChatUpdatesQueue
|
|
// Dependencies: [17, 2]
|
|
|
|
// Module 11602 (ChatUpdatesQueue)
|
|
import get_ActivityIndicator from "module_17" /* 17 */;
|
|
import size from "module_2" /* 2 */;
|
|
|
|
const NativeEventEmitter = get_ActivityIndicator.NativeEventEmitter;
|
|
const DCDChatBlockerManager = get_ActivityIndicator.NativeModules.DCDChatBlockerManager;
|
|
const result = size.fileFinishedImporting("modules/chat/native/ChatUpdatesQueue.tsx");
|
|
class ChatUpdatesQueue {
|
|
constructor(arg0, arg1) {
|
|
obj = Object.create(new.target.prototype);
|
|
closure_0 = obj;
|
|
set = new Set();
|
|
obj.blockers = set;
|
|
obj.queue = [];
|
|
obj.queueStartTimestamp = null;
|
|
obj.setOnFlushItem = function setOnFlushItem(onFlushItem) {
|
|
obj.onFlushItem = onFlushItem;
|
|
};
|
|
obj.getReactTag = global;
|
|
obj.onFlushItem = require;
|
|
tmp3 = new NativeEventEmitter(DCDChatBlockerManager);
|
|
obj.eventEmitter = tmp3;
|
|
eventEmitter = obj.eventEmitter;
|
|
obj.addBlockerSubscription = eventEmitter.addListener("AddBlocker", (reactTag) => {
|
|
reactTag = reactTag.reactTag;
|
|
if (tmp) {
|
|
obj.addBlocker(reactTag.blockerId);
|
|
}
|
|
});
|
|
eventEmitter2 = obj.eventEmitter;
|
|
obj.removeBlockerSubscription = eventEmitter2.addListener("RemoveBlocker", (reactTag) => {
|
|
reactTag = reactTag.reactTag;
|
|
if (tmp) {
|
|
obj.removeBlocker(reactTag.blockerId);
|
|
}
|
|
});
|
|
return obj;
|
|
}
|
|
}
|
|
const prototype = ChatUpdatesQueue.prototype;
|
|
prototype["hasUpdates"] = function hasUpdates() {
|
|
return this.queue.length > 0;
|
|
};
|
|
Object.defineProperty(prototype, "isBlocking", {
|
|
get: function isBlocking() {
|
|
let hasUpdatesResult = this.hasUpdates();
|
|
if (!hasUpdatesResult) {
|
|
hasUpdatesResult = this.blockers.size > 0;
|
|
}
|
|
return hasUpdatesResult;
|
|
},
|
|
set: undefined
|
|
});
|
|
prototype["addBlocker"] = function addBlocker(blockerId) {
|
|
if (null != blockerId) {
|
|
const self = this;
|
|
const blockers = this.blockers;
|
|
blockers.add(blockerId);
|
|
}
|
|
};
|
|
prototype["removeBlocker"] = function removeBlocker(blockerId) {
|
|
if (null != blockerId) {
|
|
const self = this;
|
|
const blockers = this.blockers;
|
|
blockers.delete(blockerId);
|
|
if (0 === this.blockers.size) {
|
|
self.flush();
|
|
}
|
|
}
|
|
};
|
|
prototype["add"] = function add(arg0) {
|
|
const self = this;
|
|
if (null == this.queueStartTimestamp) {
|
|
const _Date = Date;
|
|
self.queueStartTimestamp = Date.now();
|
|
}
|
|
const queue = self.queue;
|
|
queue.push(arg0);
|
|
let tmp3 = self.queue.length > 100;
|
|
let tmp4 = null != self.queueStartTimestamp;
|
|
if (tmp4) {
|
|
const _Date2 = Date;
|
|
tmp4 = Date.now() - self.queueStartTimestamp > 30000;
|
|
}
|
|
if (!tmp3) {
|
|
tmp3 = tmp4;
|
|
}
|
|
if (tmp3) {
|
|
const blockers = self.blockers;
|
|
blockers.clear();
|
|
self.flush();
|
|
}
|
|
};
|
|
prototype["tryFlush"] = function tryFlush() {
|
|
const self = this;
|
|
if (0 === this.blockers.size) {
|
|
self.flush();
|
|
}
|
|
};
|
|
prototype["clear"] = function clear() {
|
|
this.queue = [];
|
|
this.queueStartTimestamp = null;
|
|
};
|
|
prototype["flush"] = function flush() {
|
|
const self = this;
|
|
this.queueStartTimestamp = null;
|
|
const queue = this.queue;
|
|
const item = queue.forEach((item) => {
|
|
if (null != item) {
|
|
const onFlushItem = self.onFlushItem;
|
|
if (onFlushItem != null) {
|
|
onFlushItem(item);
|
|
}
|
|
}
|
|
});
|
|
this.queue = [];
|
|
};
|
|
prototype["cleanup"] = function cleanup() {
|
|
const addBlockerSubscription = this.addBlockerSubscription;
|
|
addBlockerSubscription.remove();
|
|
const removeBlockerSubscription = this.removeBlockerSubscription;
|
|
removeBlockerSubscription.remove();
|
|
};
|
|
|
|
export default ChatUpdatesQueue;
|