decord/alpha/source/stores/ApplicationStreamPreviewStore.tsx

158 lines
5 KiB
TypeScript
Raw Permalink Normal View History

2026-10-12 06:59:38 +00:00
// Module ID: 7446
// Function ID: 7447
// Name: ApplicationStreamPreviewStore
2026-10-10 08:08:14 +00:00
// Dependencies: [5898, 12, 5900, 504, 584, 2]
2026-07-20 16:05:17 +00:00
2026-10-12 06:59:38 +00:00
// Module 7446 (ApplicationStreamPreviewStore)
import _modDef12 from "module_12" /* 12 */;
2026-10-03 08:58:59 +00:00
import get_initializedDefault from "get initialized" /* 504 */;
import DispatcherDefault from "Dispatcher" /* 584 */;
2026-10-10 08:08:14 +00:00
import Constants from "Constants" /* 5898 */;
import StreamKeyUtils from "StreamKeyUtils" /* 5900 */;
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
2026-10-03 08:58:59 +00:00
let closure_4, closure_5;
2026-07-20 16:05:17 +00:00
function reset() {
2026-08-24 06:08:38 +00:00
closure_4 = {};
closure_5 = {};
2026-07-20 16:05:17 +00:00
}
const StreamTypes = Constants.StreamTypes;
2026-10-03 08:58:59 +00:00
const React3 = {};
const hasOwnProperty = {};
const set = new Set();
2026-10-03 08:58:59 +00:00
const Store = get_initializedDefault.Store;
2026-07-29 08:29:29 +00:00
class ApplicationStreamPreviewStore extends Store {
2026-10-03 08:58:59 +00:00
getPreviewURL(guildId, channelId, ownerId) {
let CALL;
const tmp = StreamKeyUtils;
const encodeStreamKey = tmp.encodeStreamKey;
if (null != guildId) {
CALL = StreamTypes.GUILD;
} else {
CALL = StreamTypes.CALL;
}
const obj = { streamType: CALL, guildId, channelId, ownerId };
const tmp4 = closure_4[encodeStreamKey(tmp, obj)];
let url;
if (tmp4 != null) {
url = tmp4.url;
}
return url;
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
shouldFetchPreview(guildId, channelId, ownerId) {
let CALL;
const encodeStreamKey = StreamKeyUtils.encodeStreamKey;
StreamKeyUtils;
if (null != guildId) {
CALL = StreamTypes.GUILD;
} else {
CALL = StreamTypes.CALL;
}
const obj = { streamType: CALL, guildId, channelId, ownerId };
const encodeStreamKeyResult = encodeStreamKey(obj);
let num = closure_5[encodeStreamKeyResult];
if (num == null) {
num = 0;
}
let tmp6 = null != tmp5;
if (tmp6) {
const _Date = Date;
tmp6 = Date.now() > tmp5.expires;
}
const tmp8 = (null == tmp5 && num < 5 || tmp6) && !set.has(encodeStreamKeyResult);
return tmp8;
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
getPreviewURLForStreamKey(streamKey) {
const obj = StreamKeyUtils;
const decodeStreamKeyResult = obj.decodeStreamKey(streamKey);
return this.getPreviewURL(decodeStreamKeyResult.guildId, decodeStreamKeyResult.channelId, decodeStreamKeyResult.ownerId);
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
getIsPreviewLoading(guildId, channelId, ownerId) {
let CALL;
const encodeStreamKey = StreamKeyUtils.encodeStreamKey;
StreamKeyUtils;
if (null != guildId) {
CALL = StreamTypes.GUILD;
} else {
CALL = StreamTypes.CALL;
}
const obj = { streamType: CALL, guildId, channelId, ownerId };
return set.has(encodeStreamKey(obj));
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
}
const prototype = ApplicationStreamPreviewStore.prototype;
2026-07-29 08:29:29 +00:00
ApplicationStreamPreviewStore.displayName = "ApplicationStreamPreviewStore";
2026-10-03 08:58:59 +00:00
let obj = {
2026-07-20 16:05:17 +00:00
CONNECTION_OPEN: reset,
LOGOUT: reset,
STREAM_PREVIEW_FETCH_START: function handleStreamPreviewFetch(streamKey) {
streamKey = streamKey.streamKey;
2026-10-03 08:58:59 +00:00
let num = closure_5[streamKey];
const tmp = closure_5;
2026-07-29 08:29:29 +00:00
if (num == null) {
num = 0;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
tmp[streamKey] = num + 1;
2026-07-20 16:05:17 +00:00
set.add(streamKey);
},
STREAM_PREVIEW_FETCH_SUCCESS: function handleStreamPreviewFetchSuccess(streamKey) {
streamKey = streamKey.streamKey;
2026-07-29 08:29:29 +00:00
closure_4[streamKey] = { url: streamKey.previewURL, expires: Date.now() + 120000 };
closure_5[streamKey] = 0;
2026-10-03 08:58:59 +00:00
({ url: streamKey.previewURL, expires: Date.now() + 120000 });
2026-07-20 16:05:17 +00:00
set.delete(streamKey);
},
STREAM_PREVIEW_FETCH_FAIL: function handleStreamPreviewFetchFail(arg0) {
2026-10-03 08:58:59 +00:00
let retryAfter;
let streamKey;
2026-07-20 16:05:17 +00:00
({ streamKey, retryAfter } = arg0);
const timestamp = Date.now();
2026-10-03 08:58:59 +00:00
const tmp = closure_4;
2026-07-20 16:05:17 +00:00
if (null == retryAfter) {
2026-10-03 08:58:59 +00:00
retryAfter = 10000 * closure_5[streamKey];
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
tmp[streamKey] = { url: null, expires: timestamp + retryAfter };
2026-07-20 16:05:17 +00:00
set.delete(streamKey);
},
VOICE_STATE_UPDATES: function handleVoiceStateUpdates(voiceStates) {
voiceStates = voiceStates.voiceStates;
2026-10-03 08:58:59 +00:00
const tmp = importDefault;
const tmp2 = dependencyMap;
let obj = _modDef12;
const isEmptyResult = obj.isEmpty(closure_4);
2026-07-29 08:29:29 +00:00
let reduced = !isEmptyResult;
if (isEmptyResult) {
const tmpResult = _modDef12;
2026-10-03 08:58:59 +00:00
reduced = !tmpResult.isEmpty(closure_5);
2026-07-20 16:05:17 +00:00
}
if (reduced) {
reduced = voiceStates.reduce((acc, guildId) => {
2026-07-20 16:05:17 +00:00
guildId = guildId.guildId;
if (guildId.selfStream) {
return acc;
2026-07-20 16:05:17 +00:00
} else {
2026-10-03 08:58:59 +00:00
let CALL;
const encodeStreamKey = StreamKeyUtils.encodeStreamKey;
StreamKeyUtils;
2026-07-20 16:05:17 +00:00
if (null != guildId) {
2026-10-03 08:58:59 +00:00
CALL = constants.GUILD;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
CALL = constants.CALL;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
const obj = { streamType: CALL, guildId, channelId: tmp2, ownerId: tmp };
encodeStreamKey(obj);
delete closure_1_4[tmp9];
delete closure_1_5[tmp9];
2026-07-20 16:05:17 +00:00
return true;
}
}, false);
}
return reduced;
}
2026-10-03 08:58:59 +00:00
};
const applicationStreamPreviewStore = new ApplicationStreamPreviewStore(DispatcherDefault, obj);
const result = size.fileFinishedImporting("stores/ApplicationStreamPreviewStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default applicationStreamPreviewStore;