75 lines
2.4 KiB
TypeScript
75 lines
2.4 KiB
TypeScript
// Metro module 11584 (f11585).
|
|
import GuildStore from "../../../stores/GuildStore";
|
|
import GameServerStore from "../game_server/GameServerStore";
|
|
import GuildPowerupsStore from "./GuildPowerupsStore";
|
|
import { getExpiringGuildEntitlements } from "./utils/getExpiringGuildEntitlements";
|
|
import Module589 from "../../../_bundle/Module589";
|
|
import Dispatcher from "../../../Dispatcher";
|
|
import { HermesBuiltin } from "../../../_hermes/prelude";
|
|
let c7903_5 = {};
|
|
class GuildPowerupsNotificationStore extends Module589.PersistedStore {
|
|
static displayName = "GuildPowerupsNotificationStore";
|
|
static persistKey = "GuildPowerupsNotificationStore";
|
|
static migrations = [(a0) => {
|
|
Object.entries(a0).forEach((item) => {
|
|
const [r13, r14] = item;
|
|
a0[r13] = r14;
|
|
});
|
|
return a0;
|
|
}];
|
|
getState() {
|
|
return c7903_5;
|
|
}
|
|
initialize(a0) {
|
|
this.waitFor(GameServerStore, GuildPowerupsStore, GuildStore);
|
|
if (a0 != null) {
|
|
c7903_5 = a0;
|
|
}
|
|
}
|
|
getNotificationStateForGuild(a0) {
|
|
return c7903_5[a0];
|
|
}
|
|
}
|
|
const guildPowerupsNotificationStore = new GuildPowerupsNotificationStore(Dispatcher, {
|
|
GUILD_POWERUPS_ACK_NOTIFICATION: function handleAckNotification({ guildId }) {
|
|
let lastBoostCount = GuildStore.getGuild(guildId)?.premiumSubscriberCount;
|
|
if (lastBoostCount == null) {
|
|
lastBoostCount = 0;
|
|
}
|
|
const stateForGuild = GuildPowerupsStore.getStateForGuild(guildId);
|
|
const stateForGuild2 = GameServerStore.getStateForGuild(guildId);
|
|
const r12 = Object;
|
|
let r30 = stateForGuild?.unlockedPowerups;
|
|
if (r30 == null) {
|
|
r30 = {};
|
|
}
|
|
const r16 = r12.values(r30);
|
|
const r31 = [];
|
|
const r0 = HermesBuiltin.arraySpread(r31, r16, 0);
|
|
const r32 = Object;
|
|
let r35 = stateForGuild2?.entitlements;
|
|
if (r35 == null) {
|
|
r35 = {};
|
|
}
|
|
HermesBuiltin.arraySpread(r31, r32.values(r35), r0);
|
|
const expiringGuildEntitlements = getExpiringGuildEntitlements(r31);
|
|
const r41 = {
|
|
...c7903_5
|
|
};
|
|
const r45 = Date;
|
|
let r51 = expiringGuildEntitlements[expiringGuildEntitlements.length - 1]?.ends_at;
|
|
if (r51 == null) {
|
|
r51 = Date.now();
|
|
}
|
|
r41[guildId] = {
|
|
lastSeenWarningNotification: new r45(r51).getTime(),
|
|
lastBoostCount
|
|
};
|
|
c7903_5 = r41;
|
|
},
|
|
GUILD_POWERUPS_RESET_NOTIFICATIONS: function handleResetNotifications() {
|
|
c7903_5 = {};
|
|
}
|
|
});
|
|
export default guildPowerupsNotificationStore;
|