decord/source/stores/LocalActivityStore.tsx

384 lines
12 KiB
TypeScript
Raw Normal View History

// Module ID: 11590
// Function ID: 11591
// Name: LocalActivityStore
// Dependencies: [32, 1956, 4864, 1915, 11591, 5361, 1221, 4658, 1957, 1931, 11593, 2011, 4654, 1074, 1935, 11244, 12, 11594, 4766, 1332, 11595, 1384, 504, 573, 2]
2026-07-20 16:05:17 +00:00
// Module 11590 (LocalActivityStore)
import _modDef12 from "module_12" /* 12 */;
import initializeDefault from "initialize" /* 504 */;
import DispatcherDefault from "Dispatcher" /* 573 */;
import _modDef1332 from "module_1332" /* 1332 */;
import FlagUtils from "FlagUtils" /* 1384 */;
import UserSettings from "UserSettings" /* 1935 */;
import ActivityFlagUtils from "ActivityFlagUtils" /* 11595 */;
import _slicedToArray from "module_32" /* 32 */;
import EmbeddedActivitiesStore from "EmbeddedActivitiesStore" /* 1956 */;
import ApplicationStore from "ApplicationStore" /* 4864 */;
import RunningGameStore from "RunningGameStore" /* 1915 */;
import FirstPartyRichPresenceStore from "FirstPartyRichPresenceStore" /* 11591 */;
import SpotifyStore from "SpotifyStore" /* 5361 */;
import UserSettingsProtoStore from "UserSettingsProtoStore" /* 1221 */;
import ApplicationStreamingStore from "ApplicationStreamingStore" /* 4658 */;
import ChannelStore from "ChannelStore" /* 1957 */;
import DetectableGameStore from "DetectableGameStore" /* 1931 */;
import ExternalStreamingStore from "ExternalStreamingStore" /* 11593 */;
import SelectedChannelStore from "SelectedChannelStore" /* 2011 */;
import SessionsStore from "SessionsStore" /* 4654 */;
2026-07-23 10:11:24 +00:00
require = fn;
2026-07-20 16:05:17 +00:00
function updateActivities() {
items = [];
const CustomStatusSetting = UserSettings.CustomStatusSetting;
2026-07-20 16:05:17 +00:00
const setting = CustomStatusSetting.getSetting();
2026-07-29 08:29:29 +00:00
let tmp4 = null != setting;
if (tmp4) {
let tmp5 = "0" === setting.expiresAtMs;
if (!tmp5) {
2026-07-20 16:05:17 +00:00
const _Date = Date;
const _Number = Number;
const date = new Date(Number(setting.expiresAtMs));
const _Date2 = Date;
const time = date.getTime();
const date1 = new Date();
2026-07-29 08:29:29 +00:00
tmp5 = time - date1.getTime() > 0;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp4 = tmp5;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (tmp4) {
items.push(tmp(11244).getActivityFromCustomStatus(setting));
const tmpResult = tmp(11244);
2026-07-20 16:05:17 +00:00
}
const items1 = [...FirstPartyRichPresenceStore.getActivities()];
2026-07-20 16:05:17 +00:00
items.push.apply(items1);
const stream = ExternalStreamingStore.getStream();
2026-07-20 16:05:17 +00:00
if (null != stream) {
const obj = { type: constants.STREAMING };
2026-07-20 16:05:17 +00:00
const merged = Object.assign(stream);
items.push(obj);
}
const set = new Set();
const item = _modDef12.forEach(closure_20, (arg0) => {
2026-07-29 08:29:29 +00:00
[, tmp] = arg0;
if (null != tmp.application_id) {
set.add(tmp.name);
items.push(tmp);
2026-07-20 16:05:17 +00:00
}
});
const tmp24 = null != ApplicationStreamingStore.getCurrentUserActiveStream();
const visibleGame = RunningGameStore.getVisibleGame();
2026-07-29 08:29:29 +00:00
if (tmp24) {
const streamerActiveStreamMetadata = ApplicationStreamingStore.getStreamerActiveStreamMetadata();
const visibleRunningGames = RunningGameStore.getVisibleRunningGames();
2026-07-20 16:05:17 +00:00
let pid;
2026-07-29 08:29:29 +00:00
if (streamerActiveStreamMetadata != null) {
2026-07-20 16:05:17 +00:00
pid = streamerActiveStreamMetadata.pid;
}
2026-07-29 08:29:29 +00:00
let tmp29 = null;
2026-07-20 16:05:17 +00:00
if (null != pid) {
2026-07-29 08:29:29 +00:00
let found = visibleRunningGames.find((pid) => pid.pid === streamerActiveStreamMetadata.pid);
if (found == null) {
found = null;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp29 = found;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let tmp31 = null == tmp29;
if (tmp31) {
let id1;
2026-07-29 08:29:29 +00:00
if (streamerActiveStreamMetadata != null) {
id1 = streamerActiveStreamMetadata.id;
2026-07-20 16:05:17 +00:00
}
tmp31 = null != id1;
2026-07-29 08:29:29 +00:00
}
if (tmp31) {
let found1 = visibleRunningGames.find((id) => id.id === streamerActiveStreamMetadata.id);
if (found1 == null) {
found1 = null;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp29 = found1;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (null != tmp29) {
let tmp26 = tmp29;
2026-09-03 10:05:34 +00:00
if (null == c25) {
2026-07-29 08:29:29 +00:00
let start = tmp29.start;
if (start == null) {
2026-07-20 16:05:17 +00:00
const _Date3 = Date;
start = Date.now();
}
2026-09-03 10:05:34 +00:00
c25 = start;
2026-07-29 08:29:29 +00:00
tmp26 = tmp29;
2026-07-20 16:05:17 +00:00
}
} else {
2026-09-03 10:05:34 +00:00
c25 = null;
2026-07-29 08:29:29 +00:00
tmp26 = visibleGame;
2026-07-20 16:05:17 +00:00
}
} else {
2026-09-03 10:05:34 +00:00
c25 = null;
2026-07-29 08:29:29 +00:00
tmp26 = visibleGame;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let tmp35 = null != tmp26 && null != tmp26.name;
if (tmp35) {
let hasItem = set.has(tmp26.name);
2026-07-20 16:05:17 +00:00
if (!hasItem) {
const items2 = [];
const tmpResult3 = tmp(11594);
HermesBuiltin.arraySpread(SessionsStore.getRemoteActivities(), HermesBuiltin.arraySpread(items, 0));
hasItem = tmpResult3.doesGameHaveRichPresence(tmp26, items2);
const arraySpreadResult = HermesBuiltin.arraySpread(items, 0);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp35 = hasItem;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (null != tmp26) {
if (null != tmp26.name) {
if (!tmp35) {
if (!tmp43) {
const findGameResult = DetectableGameStore.findGame(tmp26);
const obj2 = { type: constants.PLAYING, name: null, application_id: null, timestamps: null };
({ name: obj9.name, id } = tmp26);
2026-07-29 08:29:29 +00:00
if (id == null) {
let id2;
2026-07-29 08:29:29 +00:00
if (findGameResult != null) {
id2 = findGameResult.id;
2026-07-29 08:29:29 +00:00
}
id = id2;
2026-07-29 08:29:29 +00:00
}
obj2.application_id = id;
2026-09-03 10:05:34 +00:00
let start2 = c25;
if (c25 == null) {
2026-07-29 08:29:29 +00:00
start2 = tmp26.start;
2026-07-20 16:05:17 +00:00
}
const obj3 = { start: start2 };
obj2.timestamps = obj3;
const merged1 = Object.assign(tmp(4766).maybeAddAdditionalGameMetadata(tmp26));
items.push(obj2);
const tmpResult4 = tmp(4766);
2026-07-20 16:05:17 +00:00
}
}
}
}
const activity = SpotifyStore.getActivity();
2026-07-20 16:05:17 +00:00
if (null != activity) {
const obj4 = { type: constants.LISTENING };
2026-07-29 08:29:29 +00:00
const merged2 = Object.assign(activity);
items.push(obj4);
2026-07-20 16:05:17 +00:00
}
}
const Constants = fn(1074);
({ ActivityFlags: closure_16, ActivityGamePlatforms: closure_17, ActivityTypes: closure_18 } = Constants);
let items = [];
const dependencyMap = {};
2026-09-03 10:05:34 +00:00
let closure_21 = {};
let c22 = 0;
const dependencyMap2 = {};
const dependencyMap3 = {};
2026-09-03 10:05:34 +00:00
let c25 = null;
2026-08-24 06:08:38 +00:00
const Store = initializeDefault.Store;
2026-07-29 08:29:29 +00:00
class LocalActivityStore extends Store {
}
const prototype = LocalActivityStore.prototype;
prototype["initialize"] = function initialize() {
this.waitFor(ApplicationStore, ApplicationStreamingStore, ChannelStore, EmbeddedActivitiesStore, ExternalStreamingStore, FirstPartyRichPresenceStore, DetectableGameStore, RunningGameStore, SelectedChannelStore, SessionsStore, SpotifyStore, UserSettingsProtoStore);
items = [FirstPartyRichPresenceStore];
2026-07-29 08:29:29 +00:00
this.syncWith(items, () => {
updateActivities();
2026-07-29 08:29:29 +00:00
});
};
prototype["getActivities"] = function getActivities() {
return items;
2026-07-29 08:29:29 +00:00
};
prototype["getPrimaryActivity"] = function getPrimaryActivity() {
return items[0];
2026-07-29 08:29:29 +00:00
};
prototype["getApplicationActivity"] = function getApplicationActivity(arg0) {
2026-08-24 06:08:38 +00:00
closure_0 = arg0;
2026-07-29 08:29:29 +00:00
return this.findActivity((application_id) => application_id.application_id === closure_0);
};
prototype["getCustomStatusActivity"] = function getCustomStatusActivity() {
return this.findActivity((type) => type.type === constants.CUSTOM_STATUS);
};
prototype["findActivity"] = function findActivity(_messages) {
return items.find(_messages);
2026-07-29 08:29:29 +00:00
};
prototype["getApplicationActivities"] = function getApplicationActivities() {
return closure_20;
};
prototype["getActivityForPID"] = function getActivityForPID(arg0) {
const values = Object.values(closure_20);
const obj = values[Symbol.iterator]();
while (obj !== undefined) {
let tmp4 = _slicedToArray(tmp2, 2);
2026-07-29 08:29:29 +00:00
if (tmp4[0] === arg0) {
obj.return();
return tmp5;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
return null;
};
2026-09-03 10:05:34 +00:00
prototype["getApplicationIdForPID"] = function getApplicationIdForPID(pid) {
const entries = Object.entries(closure_21);
const obj = entries[Symbol.iterator]();
while (obj !== undefined) {
let tmp5 = _slicedToArray(tmp3, 2);
2026-09-03 10:05:34 +00:00
let first = tmp5[0];
let tmp7 = _slicedToArray(tmp5[1], 2);
2026-09-03 10:05:34 +00:00
if (tmp7[0] === pid) {
obj.return();
return tmp8;
}
continue;
}
};
2026-07-29 08:29:29 +00:00
LocalActivityStore.displayName = "LocalActivityStore";
const localActivityStore = new LocalActivityStore(DispatcherDefault, {
2026-07-20 16:05:17 +00:00
ROBLOX_SUBGAME_UPDATE: updateActivities,
ROBLOX_SUBGAME_APPLICATION_FETCH_SUCCESS: updateActivities,
OVERLAY_INITIALIZE: function handleOverlayInitialize(localActivities) {
const merged = Object.assign(localActivities.localActivities);
closure_20 = {};
2026-07-20 16:05:17 +00:00
updateActivities();
},
START_SESSION: function handleStartSession() {
2026-08-24 06:08:38 +00:00
closure_20 = {};
2026-09-03 10:05:34 +00:00
closure_21 = {};
c22 = 0;
closure_23 = {};
closure_24 = {};
2026-07-20 16:05:17 +00:00
updateActivities();
},
LOCAL_ACTIVITY_UPDATE: function handleLocalActivityUpdate(arg0) {
2026-09-03 10:05:34 +00:00
({ socketId, pid, applicationId, activity, partyPrivacy } = arg0);
closure_0 = undefined;
let tmp3 = dependencyMap2[socketId];
if (null == tmp3) {
const sum = c22 + 1;
c22 = sum;
dependencyMap2[socketId] = sum;
tmp3 = sum;
}
let flag = false;
if (null != pid) {
closure_0 = tmp8;
let someResult = null != tmp8;
if (someResult) {
const _Object = Object;
const keys = Object.keys(closure_21);
someResult = keys.some((item) => closure_23[item] === closure_0);
2026-09-03 10:05:34 +00:00
}
flag = false;
if (tmp12) {
flag = tmp3 !== tmp8;
dependencyMap3[pid] = tmp3;
}
tmp12 = null == dependencyMap3[pid] || tmp3 >= dependencyMap3[pid] || !someResult;
}
if (null == activity) {
let tmp17 = null == dependencyMap[socketId];
2026-07-20 16:05:17 +00:00
} else {
items = [pid, activity, partyPrivacy];
tmp17 = _modDef1332(dependencyMap[socketId], items);
2026-09-03 10:05:34 +00:00
}
let tmp19 = null == applicationId;
if (!tmp19) {
const items1 = [pid, applicationId];
tmp19 = _modDef1332(closure_21[socketId], items1);
2026-09-03 10:05:34 +00:00
}
if (tmp17) {
if (tmp19) {
if (!flag) {
return false;
}
2026-07-20 16:05:17 +00:00
}
}
2026-09-03 10:05:34 +00:00
if (null != applicationId) {
const items2 = [pid, applicationId];
closure_21[socketId] = items2;
2026-09-03 10:05:34 +00:00
}
if (null != activity) {
const items3 = [pid, activity, partyPrivacy];
dependencyMap[socketId] = items3;
} else {
delete tmp[tmp2];
}
updateActivities();
},
RPC_APP_CONNECTED: function handleRPCAppConnected(socketId) {
const sum = c22 + 1;
c22 = sum;
closure_23[socketId.socketId] = sum;
2026-07-20 16:05:17 +00:00
},
RPC_APP_DISCONNECTED: function handleRPCAppDisconnected(arg0) {
2026-09-03 10:05:34 +00:00
delete tmp[tmp2];
2026-07-23 10:11:24 +00:00
delete tmp[tmp2];
2026-07-20 16:05:17 +00:00
updateActivities();
},
RUNNING_GAMES_CHANGE: updateActivities,
LIBRARY_APPLICATION_FLAGS_UPDATE_SUCCESS: updateActivities,
SPOTIFY_PLAYER_STATE: updateActivities,
SPOTIFY_PLAYER_PLAY: updateActivities,
STREAMING_UPDATE: updateActivities,
USER_CONNECTIONS_UPDATE: updateActivities,
STREAM_START: updateActivities,
STREAM_STOP: updateActivities,
USER_SETTINGS_PROTO_UPDATE: function handleUserSettingsProtoUpdate() {
2026-07-29 08:29:29 +00:00
(function recalculateActivityPartyPrivacyFlags() {
obj = {};
2026-07-29 08:29:29 +00:00
let flag = false;
const entries = Object.entries(obj);
while (tmp2 !== undefined) {
let tmp5 = _slicedToArray(tmp3, 2);
2026-07-29 08:29:29 +00:00
let first = tmp5[0];
let tmp7 = _slicedToArray(tmp5[1], 3);
2026-07-29 08:29:29 +00:00
[tmp8, tmp9] = tmp7;
let tmp10 = tmp9;
let tmp11 = tmp7[2];
let num = tmp9.flags;
if (num == null) {
num = 0;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let tmp12 = num;
let tmp13 = require;
let obj2 = ActivityFlagUtils;
2026-07-29 08:29:29 +00:00
let tmp15 = tmp9;
let obj3 = FlagUtils;
2026-07-29 08:29:29 +00:00
let num2;
if (tmp10 != null) {
num2 = tmp10.flags;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (num2 == null) {
num2 = 0;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let hasFlagResult = obj3.hasFlag(num2, constants.INSTANCE);
let tmp13Result = tmp13(11595);
2026-07-29 08:29:29 +00:00
let activityFlags = obj2.computeActivityFlags(tmp15, hasFlagResult, tmp10.platform === constants2.EMBEDDED, tmp13Result.isContextlessEmbeddedActivity(tmp10), tmp11);
if (activityFlags !== tmp12) {
items = [tmp8, , ];
let obj4 = {};
2026-07-29 08:29:29 +00:00
let merged = Object.assign(tmp10);
obj4.flags = tmp24;
items[1] = obj4;
2026-07-29 08:29:29 +00:00
items[2] = tmp11;
2026-07-20 16:05:17 +00:00
obj[first] = items;
flag = true;
} else {
2026-07-29 08:29:29 +00:00
let items1 = [tmp8, , ];
items1[1] = tmp10;
items1[2] = tmp11;
2026-07-20 16:05:17 +00:00
obj[first] = items1;
}
2026-07-29 08:29:29 +00:00
continue;
}
let str = "NO_CHANGES";
if (flag) {
str = "APPLICATION_ACTIVITIES_CHANGED";
}
return str;
})();
2026-07-20 16:05:17 +00:00
updateActivities();
},
EMBEDDED_ACTIVITY_CLOSE: updateActivities,
RUNNING_GAME_TOGGLE_DETECTION: updateActivities
});
const size = fn(2);
const result = size.fileFinishedImporting("stores/LocalActivityStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default localActivityStore;