decord/source/modules/stickers/StickersPersistedStore.tsx

113 lines
3.6 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 6805
// Function ID: 6806
2026-07-29 08:29:29 +00:00
// Name: handleStickersStoreUpdate
2026-08-24 06:08:38 +00:00
// Dependencies: [1340, 6806, 685, 687, 4561, 12, 589, 709, 2]
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
// Module 6805 (handleStickersStoreUpdate)
import applyDefault from "apply" /* 12 */;
import initializeDefault from "initialize" /* 589 */;
import setDefault from "set" /* 687 */;
import dispatcherDefault from "dispatcher" /* 709 */;
import DEFAULT_FRECENCYDefault from "DEFAULT_FRECENCY" /* 4561 */;
import closure_2 from "handleConnectionClosedOrResumed" /* 1340 */;
import closure_3 from "loadSavedGuildStickers" /* 6806 */;
import { UserSettingsTypes } from "MAX_FAVORITES" /* 685 */;
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
function handleStickersStoreUpdate() {
2026-07-20 16:05:17 +00:00
if (stickerById.isLoaded) {
2026-08-24 06:08:38 +00:00
closure_6.compute();
2026-07-20 16:05:17 +00:00
}
}
function handleUserSettingsProtoStoreChange() {
const stickerFrecency = obj.frecencyWithoutFetchingLatest.stickerFrecency;
let stickers;
2026-07-29 08:29:29 +00:00
if (stickerFrecency != null) {
2026-07-20 16:05:17 +00:00
stickers = stickerFrecency.stickers;
}
if (null == stickers) {
return false;
} else {
2026-08-24 06:08:38 +00:00
obj = applyDefault;
closure_6.overwriteHistory(obj.mapValues(stickers, (recentUses) => {
2026-07-20 16:05:17 +00:00
const obj = {};
const merged = Object.assign(recentUses);
recentUses = recentUses.recentUses;
const mapped = recentUses.map(Number);
2026-07-29 08:29:29 +00:00
obj.recentUses = mapped.filter((arg0) => arg0 > 0);
2026-07-20 16:05:17 +00:00
return obj;
2026-07-29 08:29:29 +00:00
}), closure_5.pendingUsages);
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
let closure_5 = { pendingUsages: [] };
2026-07-20 16:05:17 +00:00
let obj = {
computeBonus() {
return 100;
},
lookupKey(arg0) {
return stickerById.getStickerById(arg0);
},
afterCompute() {
},
numFrequentlyItems: 20
};
2026-08-24 06:08:38 +00:00
let closure_6 = new DEFAULT_FRECENCYDefault(obj);
const PersistedStore = initializeDefault.PersistedStore;
2026-07-29 08:29:29 +00:00
class StickersPersistedStore extends PersistedStore {
}
const prototype = StickersPersistedStore.prototype;
prototype["initialize"] = function initialize(arg0) {
const self = this;
2026-08-24 06:08:38 +00:00
this.waitFor(closure_3, closure_2);
2026-07-29 08:29:29 +00:00
if (null != arg0) {
2026-08-24 06:08:38 +00:00
closure_5 = arg0;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
const items = [closure_3];
2026-07-29 08:29:29 +00:00
self.syncWith(items, handleStickersStoreUpdate);
2026-08-24 06:08:38 +00:00
const items1 = [closure_2];
2026-07-29 08:29:29 +00:00
self.syncWith(items1, handleUserSettingsProtoStoreChange);
};
prototype["getState"] = function getState() {
return closure_5;
};
prototype["hasPendingUsage"] = function hasPendingUsage() {
return closure_5.pendingUsages.length > 0;
};
Object.defineProperty(prototype, "stickerFrecencyWithoutFetchingLatest", {
get: function stickerFrecencyWithoutFetchingLatest() {
return closure_6;
},
set: undefined
});
StickersPersistedStore.displayName = "StickersPersistedStore";
StickersPersistedStore.persistKey = "StickersPersistedStoreV2";
2026-07-20 16:05:17 +00:00
obj = {
STICKER_TRACK_USAGE: function handleStickersUsage(stickerIds) {
stickerIds = stickerIds.stickerIds;
2026-07-29 08:29:29 +00:00
if (stickerIds != null) {
2026-07-20 16:05:17 +00:00
const item = stickerIds.forEach((key) => {
2026-07-29 08:29:29 +00:00
closure_6.track(key);
pendingUsages = pendingUsages.pendingUsages;
2026-07-20 16:05:17 +00:00
pendingUsages.push({ key, timestamp: Date.now() });
});
}
2026-07-29 08:29:29 +00:00
if (stickerById.isLoaded) {
2026-08-24 06:08:38 +00:00
closure_6.compute();
2026-07-29 08:29:29 +00:00
}
2026-07-20 16:05:17 +00:00
},
USER_SETTINGS_PROTO_UPDATE: function handleUserSettingsProtoUpdate(settings) {
if (settings.settings.type === UserSettingsTypes.FRECENCY_AND_FAVORITES_SETTINGS) {
if (settings.wasSaved) {
2026-07-29 08:29:29 +00:00
closure_5.pendingUsages = [];
2026-07-20 16:05:17 +00:00
}
}
return false;
}
};
2026-08-24 06:08:38 +00:00
const stickersPersistedStore = new StickersPersistedStore(dispatcherDefault, obj);
const tmp2 = new DEFAULT_FRECENCYDefault(obj);
const result = require("set").fileFinishedImporting("modules/stickers/StickersPersistedStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default stickersPersistedStore;
2026-08-24 06:08:38 +00:00
export const STICKER_PACK_NEW_TIMESTAMP_THRESHOLD = setDefault.Millis.DAY;