// Module ID: 5104 // Function ID: 5105 // Name: filterPlayingActivities // Dependencies: [5105, 1340, 4416, 5235, 4419, 10505, 4469, 4398, 676, 4428, 4070, 1403, 9804, 659, 12, 589, 709, 2] // Module 5104 (filterPlayingActivities) import applyDefault from "apply" /* 12 */; import initializeDefault from "initialize" /* 589 */; import isUndefinedOrNullDefault from "isUndefinedOrNull" /* 659 */; import dispatcherDefault from "dispatcher" /* 709 */; import hasFlag from "hasFlag" /* 1403 */; import explicitContentFromProto from "explicitContentFromProto" /* 4070 */; import isListeningOnSpotifyDefault from "isListeningOnSpotify" /* 9804 */; import closure_3 from "upsertAccount" /* 5105 */; import closure_4 from "handleConnectionClosedOrResumed" /* 1340 */; import closure_5 from "gameFromServer" /* 4416 */; import closure_6 from "checkIdleAFK" /* 5235 */; import closure_7 from "setLibraryApplications" /* 4419 */; import closure_8 from "updateActivities" /* 10505 */; import closure_9 from "sortActivity" /* 4469 */; import { sortActivity } from "sortActivity" /* 4469 */; import closure_11 from "handleUpdate" /* 4398 */; import ME from "ME" /* 676 */; require = arg1; function filterPlayingActivities(arg0) { if (0 === arg0.length) { return arg0; } else { const items = []; const items1 = []; const iter = arg0[Symbol.iterator](); const nextResult = iter.next(); while (iter !== undefined) { let tmp4 = nextResult; let tmp5 = constants2; if (nextResult.type === constants2.PLAYING) { let tmp8 = nextResult; let arr = items1.push(tmp4); } else { let tmp6 = nextResult; arr = items.push(tmp4); } continue; } if (0 === items1.length) { return arg0; } else if (1 === items1.length) { return arg0; } else { const items2 = []; HermesBuiltin.arraySpread(items1, 0); const items3 = []; items3[HermesBuiltin.arraySpread(items, 0)] = items2.sort(sortActivity)[0]; return items3.sort(sortActivity); } } } function shouldShowActivity(flags) { let num = flags.flags; if (num == null) { num = 0; } if (obj.hasFlag(num, constants.CONTEXTLESS)) { return true; } else { const type = flags.type; if (constants2.LISTENING === type) { if (isListeningOnSpotifyDefault(flags)) { let shouldShowActivityResult = closure_3.shouldShowActivity(); } else { shouldShowActivityResult = null != flags.application_id; if (shouldShowActivityResult) { let tmpResult = tmp(4428); shouldShowActivityResult = tmpResult.shouldShareApplicationActivity(flags.application_id, closure_7); } } return shouldShowActivityResult; } else if (tmp3.PLAYING === type) { if (null != flags.application_id) { tmpResult = tmp(4428); let result = tmpResult.shouldShareApplicationActivity(flags.application_id, closure_7); } else { const searchGamesByNameResult = closure_5.searchGamesByName(flags.name); if (1 === searchGamesByNameResult.length) { result = tmp(4428).shouldShareApplicationActivity(searchGamesByNameResult[0], closure_7); const tmpResult1 = tmp(4428); } else { const ShowCurrentGame = tmp(4070).ShowCurrentGame; result = ShowCurrentGame.getSetting(); } } return result; } else { if (tmp3.STREAMING !== type) { const WATCHING = tmp3.WATCHING; } let result1 = null == flags.application_id; if (!result1) { result1 = tmp(4428).shouldShareApplicationActivity(flags.application_id, closure_7); const tmpResult2 = tmp(4428); } return result1; } } obj = hasFlag; } function handleUpdate() { let num = idleSince.getIdleSince(); if (num == null) { num = 0; } closure_22 = idleSince.isAFK(); if (c23) { let IDLE = closure_18; let ONLINE = closure_18; } else if (c16) { const INVISIBLE = StatusTypes.INVISIBLE; IDLE = INVISIBLE; ONLINE = INVISIBLE; } else { const StatusSetting = explicitContentFromProto.StatusSetting; ONLINE = StatusSetting.getSetting(); if (ONLINE === StatusTypes.UNKNOWN) { ONLINE = StatusTypes.ONLINE; } IDLE = ONLINE; } let tmp7 = ONLINE === StatusTypes.ONLINE; if (tmp7) { tmp7 = num > 0; } if (tmp7) { IDLE = tmp6.IDLE; } if (!c23) { if (IDLE !== tmp6.INVISIBLE) { activities = activities.getActivities(); let found = activities.filter(shouldShowActivity); } let flag = false; if (!isUndefinedOrNullDefault(found, found)) { closure_21 = filterPlayingActivities(found); flag = true; } remoteActivities = remoteActivities.getRemoteActivities(); if (remoteActivities !== remoteActivities) { flag = true; } const hiddenActivities = remoteActivities.getHiddenActivities(); if (flag) { const items = []; let arraySpreadResult = HermesBuiltin.arraySpread(found, 0); arraySpreadResult = HermesBuiltin.arraySpread(remoteActivities.filter((type) => type.type !== constants.CUSTOM_STATUS), arraySpreadResult); const tmp12Result = applyDefault; const tmp12ResultResult = applyDefault(items.sort(sortActivity)); const valueResult = applyDefault(items.sort(sortActivity)).uniqBy((type) => "" + type.type + ":" + type.application_id + ":" + type.name).value(); closure_27 = filterPlayingActivities(valueResult); const iter = applyDefault(items.sort(sortActivity)).uniqBy((type) => "" + type.type + ":" + type.application_id + ":" + type.name); } } found = []; } function handleConnectionOpen() { c23 = false; const UNKNOWN = StatusTypes.UNKNOWN; handleUpdate(); const result = authStore.setCurrentUserOnConnectionOpen(closure_17, closure_26); } const StatusTypes = ME.StatusTypes; ({ ActivityFlags: map1, ActivityTypes: closure_14, AppStates: closure_15 } = ME); let c16 = false; ({ ONLINE: closure_17, UNKNOWN: closure_18 } = StatusTypes); let c19 = 0; let closure_20 = []; let closure_21 = []; let c22 = false; let c23 = true; let closure_24 = Object.freeze([]); let closure_25 = Object.freeze([]); let closure_26 = []; let closure_27 = []; const Store = initializeDefault.Store; class SelfPresenceStore extends Store { } const prototype = SelfPresenceStore.prototype; prototype["initialize"] = function initialize() { this.waitFor(closure_5, closure_6, closure_7, closure_8, closure_9, closure_11, closure_3, closure_4); const items = [closure_8]; this.syncWith(items, handleUpdate); }; prototype["getLocalPresence"] = function getLocalPresence() { return { status: closure_17, since: c19, activities: closure_21, afk: c22 }; }; prototype["getStatus"] = function getStatus() { return closure_17; }; prototype["getActivities"] = function getActivities() { let flag = arg0; if (arg0 === undefined) { flag = true; } return flag ? closure_27 : closure_21; }; prototype["getUnfilteredActivities"] = function getUnfilteredActivities() { let flag = arg0; if (arg0 === undefined) { flag = true; } return flag ? closure_26 : closure_20; }; prototype["getHiddenActivities"] = function getHiddenActivities() { return closure_25; }; prototype["getPrimaryActivity"] = function getPrimaryActivity() { let flag = arg0; if (arg0 === undefined) { flag = true; } return this.getActivities(flag)[0]; }; prototype["getApplicationActivity"] = function getApplicationActivity(arg0) { closure_0 = arg0; let flag = arg1; if (arg1 === undefined) { flag = true; } return this.findActivity((application_id) => application_id.application_id === closure_0, flag); }; prototype["findActivity"] = function findActivity(closure_4) { let flag = arg1; if (arg1 === undefined) { flag = true; } const activities = this.getActivities(flag); return activities.find(closure_4); }; SelfPresenceStore.displayName = "SelfPresenceStore"; const selfPresenceStore = new SelfPresenceStore(dispatcherDefault, { START_SESSION: handleUpdate, CONNECTION_OPEN: function handleConnectionOpenTracked() { c23 = false; const UNKNOWN = StatusTypes.UNKNOWN; handleUpdate(); const result = authStore.setCurrentUserOnConnectionOpen(closure_17, closure_26); }, CONNECTION_OPEN_SUPPLEMENTAL: handleConnectionOpen, OVERLAY_INITIALIZE: handleConnectionOpen, CONNECTION_CLOSED: handleUpdate, IDLE: handleUpdate, AFK: handleUpdate, RUNNING_GAMES_CHANGE: handleUpdate, STREAMING_UPDATE: handleUpdate, USER_SETTINGS_PROTO_UPDATE: handleUpdate, LOCAL_ACTIVITY_UPDATE: handleUpdate, SPOTIFY_PLAYER_STATE: handleUpdate, SPOTIFY_PLAYER_PLAY: handleUpdate, USER_CONNECTIONS_UPDATE: handleUpdate, SESSIONS_REPLACE: handleUpdate, RPC_APP_DISCONNECTED: handleUpdate, LIBRARY_FETCH_SUCCESS: handleUpdate, LIBRARY_APPLICATION_FLAGS_UPDATE_SUCCESS: handleUpdate, LOGOUT: function handleLogout() { c23 = true; closure_18 = closure_17; handleUpdate(); }, FORCE_INVISIBLE: function handleForceInvisible(invisible) { invisible = invisible.invisible; handleUpdate(); }, WINDOW_FOCUS: function handleWindowFocus() { c16 = false; handleUpdate(); }, APP_STATE_UPDATE: function handleAppStateUpdate(state) { if (state.state === constants3.ACTIVE) { if (c16) { c16 = false; handleUpdate(); } } return false; } }); let result = require("set").fileFinishedImporting("stores/SelfPresenceStore.tsx"); export default selfPresenceStore;