43 lines
2.2 KiB
TypeScript
43 lines
2.2 KiB
TypeScript
// Metro module 16334 (f16335).
|
|
import LocalAppDetectionStore from "../../local_app_detection/native/LocalAppDetectionStore";
|
|
import MobileGameCommunitiesStore from "./MobileGameCommunitiesStore";
|
|
import AutomaticLifecycleManager from "../../../lib/AutomaticLifecycleManager";
|
|
import { getGameIdsForDetectedGames } from "./GameCommunityConfig";
|
|
import { fetchMobileGameCommunities } from "./MobileGameCommunitiesActionCreators";
|
|
import { GameCommunityUpsellMultiExperiment } from "./GameCommunityUpsellExperiment";
|
|
import { ALL_DETECTABLE_APP_NAMES } from "../../local_app_detection/LocalAppDetectionTypes";
|
|
class MobileGameCommunitiesManager extends AutomaticLifecycleManager {
|
|
actions = {
|
|
LOCAL_APP_DETECTION_COMPLETE: (a0) => this.handleLocalAppDetectionComplete(a0),
|
|
POST_CONNECTION_OPEN: () => this.handlePostConnectionOpen()
|
|
};
|
|
_fetchGameCommunities(a0) {
|
|
const gameIdsForDetectedGames = getGameIdsForDetectedGames(a0);
|
|
const r18 = Date.now() - MobileGameCommunitiesStore.getLastFetchedAt();
|
|
const r20 = gameIdsForDetectedGames.some((gameIdsForDetectedGame) => !MobileGameCommunitiesStore.getLastFetchedGameIds().has(gameIdsForDetectedGame));
|
|
if (!(!(r18 >= 86400000) && !r20)) {
|
|
fetchMobileGameCommunities(gameIdsForDetectedGames, Array.from(MobileGameCommunitiesStore.getDismissedGuildIds()), 6);
|
|
}
|
|
}
|
|
handlePostConnectionOpen() {
|
|
if (GameCommunityUpsellMultiExperiment.getConfig({
|
|
location: "MobileGameCommunitiesManager"
|
|
}).enabled && MobileGameCommunitiesStore.getLastFetchedAt() === 0 && Object.values(LocalAppDetectionStore.getUserAgnosticState().apps).some((item) => item?.lastScannedAt != null)) {
|
|
const r37 = {};
|
|
for (const item of ALL_DETECTABLE_APP_NAMES) {
|
|
r37[item] = LocalAppDetectionStore.isAppInstalled(item);
|
|
}
|
|
this._fetchGameCommunities(r37);
|
|
}
|
|
}
|
|
handleLocalAppDetectionComplete({ result }) {
|
|
if (GameCommunityUpsellMultiExperiment.getConfig({
|
|
location: "MobileGameCommunitiesManager"
|
|
}).enabled) {
|
|
this._fetchGameCommunities(result);
|
|
}
|
|
}
|
|
}
|
|
const mobileGameCommunitiesManager = new MobileGameCommunitiesManager();
|
|
export default mobileGameCommunitiesManager;
|