This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

@@ -0,0 +1,324 @@
// Metro module 13520 (f13521).
import { MAX_FAVORITES, MAX_FAVORITE_GIFS_SIZE } from "./UserSettingsConstants";
import { ID_REGEX } from "../../Constants";
import Module589 from "../../_bundle/Module589";
import * as _Module1341 from "../../_bundle/Module1341";
import { FavoriteGIF, GIFType, FavoriteGIFs, FavoriteStickers, StickerFrecency, FavoriteEmojis, EmojiFrecency, FavoriteSoundboardSounds, GuildAndChannelFrecency } from "../../_bundle/Module1341";
import Module12 from "../../_bundle/Module12";
import { serializeUsageHistory } from "./UserSettingsUtils";
import { Storage } from "../../_bundle/Module595";
import SnowflakeUtils from "../../utils/SnowflakeUtils";
import { $forInKeys } from "../../_hermes/prelude";
let c9384_6;
const readFavoriteGIFs = function readFavoriteGIFs(a0) {
let c20507_0 = 1;
let c20507_1 = {
IMAGE: "IMAGE",
VIDEO: "VIDEO"
};
const state = Module589.PersistedStore.migrateAndReadStoreState("GIFFavoritesStore", [(a0) => a0 == null ? {
favorites: [],
timesFavorited: 0
} : Array.isArray(a0) ? {
favorites: a0,
timesFavorited: 0
} : a0, (a0) => Array.isArray(a0.favorites) ? a0 : {
favorites: [],
timesFavorited: 0
}]).state;
return state != null && state.favorites.length !== 0 ? state.favorites.map((a0, index) => {
let IMAGE;
const favorite = FavoriteGIF.create();
const format = a0.format;
if (c20507_1.IMAGE === format) {
IMAGE = GIFType.IMAGE;
} else if (c20507_1.VIDEO === format) {
IMAGE = GIFType.VIDEO;
} else {
a0.format;
IMAGE = GIFType.NONE;
}
favorite.format = IMAGE;
favorite.src = a0.src;
favorite.width = a0.width;
favorite.height = a0.height;
favorite.order = state.favorites.length - index + c20507_0;
return {
url: a0.url,
favorite
};
}) : [];
};
c9384_6 = "selectedChannelGuildFrecency";
const r24 = [{
version: 2,
run: (a0) => {
const r19 = readFavoriteGIFs(1);
if (r19.length === 0) {
return false;
}
if (a0.favoriteGifs == null) {
a0.favoriteGifs = FavoriteGIFs.create();
}
a0.favoriteGifs.gifs = {};
for (const item of r19) {
a0.favoriteGifs.gifs[item.url] = item.favorite;
}
a0.favoriteGifs.hideTooltip = r19.length > 2;
return true;
},
cleanup: () => {}
}, {
version: 3,
run: (a0) => {
const state3 = Module589.PersistedStore.migrateAndReadStoreState("StickersPersistedStore", [(a0) => a0 != null && Object.keys(a0).length !== 0 ? a0 : {
usageHistory: {},
favorites: []
}, (a0) => {
let r9;
L5: {
if (a0 != null && Object.keys(a0).length !== 0) {
const favorites = a0.favorites;
r9 = a0;
if (favorites != null) {
break L5;
}
a0.favorites = [];
r9 = a0;
} else {
r9 = {
usageHistory: {},
favorites: []
};
}
}
return r9;
}]).state;
if (state3 == null) {
return false;
}
const r3 = state3.favorites.length > 0;
let r22 = false;
if (r3) {
a0.favoriteStickers = FavoriteStickers.create();
a0.favoriteStickers.stickerIds = Module12.uniq(state3.favorites).slice(0, MAX_FAVORITES);
r22 = true;
}
if (Module12.size(state3.usageHistory) > 0) {
a0.stickerFrecency = StickerFrecency.create();
a0.stickerFrecency.stickers = serializeUsageHistory(state3.usageHistory, 100);
r22 = true;
}
return r22;
},
cleanup: () => {
Storage.remove("StickersPersistedStore");
}
}, {
version: 4,
run: (a0) => {
const state3 = Module589.PersistedStore.migrateAndReadStoreState("EmojiStore", [() => ({
usageHistory: Storage.get("EmojiUsageHistory") || {}
})]).state;
if (state3 == null) {
return false;
}
const r2 = state3.favorites != null && state3.favorites.length > 0;
let r22 = false;
if (r2) {
a0.favoriteEmojis = FavoriteEmojis.create();
a0.favoriteEmojis.emojis = Module12.uniq(state3.favorites).slice(0, MAX_FAVORITES);
r22 = true;
}
if (Module12.size(state3.usageHistory) > 0) {
a0.emojiFrecency = EmojiFrecency.create();
a0.emojiFrecency.emojis = serializeUsageHistory(state3.usageHistory, 100);
r22 = true;
}
return r22;
},
cleanup: () => {
Storage.remove("EmojiStore");
Storage.remove("EmojiUsageHistory");
Storage.remove("EmojiDiversitySurrogate");
}
}, {
version: 6,
run: (a0) => {
if (a0.favoriteGifs == null) {
a0.favoriteGifs = FavoriteGIFs.create();
}
if (a0.favoriteGifs.gifs == null) {
a0.favoriteGifs.gifs = {};
}
const r9 = readFavoriteGIFs(1);
let c20508_0 = r9;
if (r9.length === 0) {
return false;
}
Module12(a0.favoriteGifs.gifs).values().sortBy("order").forEach((item, index) => {
const order = c20508_0.length + 1 + index;
item.order = order;
return order;
});
let length2 = FavoriteGIFs.toBinary(a0.favoriteGifs).length;
let r63 = 0;
for (const item of r9) {
const { url, favorite } = item;
const length = r9.length;
const r74 = r63;
favorite.order = length - r74;
r63 = r74 + 1;
if (url in a0.favoriteGifs.gifs) {
a0.favoriteGifs.gifs[url].order = favorite.order;
} else {
const r91 = FavoriteGIF.toBinary(favorite).length + url.length + 7;
if (!(length2 + r91 > MAX_FAVORITE_GIFS_SIZE)) {
length2 = length2 + r91;
a0.favoriteGifs.gifs[url] = favorite;
}
}
}
while (FavoriteGIFs.toBinary(a0.favoriteGifs).length > MAX_FAVORITE_GIFS_SIZE) {
const gifs = a0.favoriteGifs.gifs;
let r123 = 0;
const r124 = $forInKeys(gifs);
let r125 = 0;
const length3 = r124.length;
if (r124 !== void 0) {
do {
const r127 = r123;
const r128 = r125 < length3 ? r124[r125++] : void 0;
if (r128 === void 0) {
break;
}
delete a0.favoriteGifs.gifs[r128];
r123 = r127 + 1;
} while (!(10 <= r123));
}
}
return true;
},
cleanup: () => {}
}, {
version: 7,
run: (a0) => {
const state3 = Module589.PersistedStore.migrateAndReadStoreState("ApplicationCommandFrecency", []).state;
if (state3 == null) {
return false;
}
const r3 = Module12.size(state3.usageHistory) > 0;
let r20 = false;
if (r3) {
a0.applicationCommandFrecency = _Module1341.ApplicationCommandFrecency.create();
a0.applicationCommandFrecency.applicationCommands = serializeUsageHistory(state3.usageHistory, 500);
r20 = true;
}
return r20;
},
cleanup: () => {
Storage.remove("ApplicationCommandFrecency");
}
}, {
version: 8,
run: (a0) => {
const state2 = Module589.PersistedStore.migrateAndReadStoreState("SoundboardFavoriteStore", []).state;
if (state2 == null) {
return false;
}
const r3 = Module12.size(state2.favoriteSounds) > 0;
let r22 = false;
if (r3) {
a0.favoriteSoundboardSounds = FavoriteSoundboardSounds.create();
SnowflakeUtils.keys(state2.favoriteSounds).forEach((item) => {
new Set(state2.favoriteSounds[item]).forEach((item) => {
const favoriteSoundboardSounds = a0.favoriteSoundboardSounds;
if (favoriteSoundboardSounds != null) {
favoriteSoundboardSounds.soundIds.push(item);
}
});
});
r22 = true;
}
return r22;
},
cleanup: () => {
Storage.remove("SoundboardFavoriteStore");
}
}, {
version: 9,
run: (a0) => {
const r16 = Storage.get(c9384_6);
if (r16 == null) {
return false;
}
for (const key in r16) {
if (!ID_REGEX.test(key)) {
delete r16[key];
}
}
a0.guildAndChannelFrecency = GuildAndChannelFrecency.create();
a0.guildAndChannelFrecency.guildAndChannels = serializeUsageHistory(r16, 100);
return true;
},
cleanup: () => {
Storage.remove(c9384_6);
}
}, {
version: 10,
run: (a0) => {
if (a0.emojiFrecency == null) {
return false;
}
let emojis = a0.emojiFrecency.emojis;
if (emojis == null) {
emojis = {};
}
const r3 = Module12.size(emojis) > 0;
let r1 = false;
if (r3) {
const emojiReactionFrecency = EmojiFrecency.create();
EmojiFrecency.mergePartial(emojiReactionFrecency, a0.emojiFrecency);
if (a0.emojiReactionFrecency != null) {
EmojiFrecency.mergePartial(emojiReactionFrecency, a0.emojiReactionFrecency);
}
a0.emojiReactionFrecency = emojiReactionFrecency;
r1 = true;
}
return r1;
},
cleanup: () => {}
}, {
version: 11,
run: (a0) => {
let r2;
if (a0.favoriteGifs != null && a0.favoriteGifs.gifs != null) {
const gifs = a0.favoriteGifs.gifs;
let r3 = false;
let r6 = false;
for (const key in gifs) {
r2 = r3;
r6 = r2;
const r28 = a0.favoriteGifs.gifs[key];
r3 = r2;
if (r28 != null) {
if (r28.src.startsWith("//")) {
r28.src = `https:${r28.src}`;
r2 = true;
}
if (r28.format !== GIFType.IMAGE && /\.(webp|avif|gif)(\?|$)/i.test(r28.src)) {
r28.format = GIFType.IMAGE;
r2 = true;
}
r3 = r2;
}
}
r2 = r3;
r6 = r2;
return r6;
}
return false;
},
cleanup: () => {}
}];
export default r24;