// Metro module 1375 (f1376). import UserSettingsProtoStore from "../user_settings/UserSettingsProtoStore"; import { createChannelRecord } from "../../records/ChannelRecord"; import { FAVORITES_UNCATEGORIZED_PARENT_ID } from "./FavoritesConstants"; import { ChannelTypes, FAVORITES } from "../../Constants"; import { isEmpty, isEqual } from "../../_bundle/Module12"; import Module589 from "../../_bundle/Module589"; import { FavoriteChannelType } from "../../_bundle/Module1306"; import Dispatcher from "../../Dispatcher"; let c1144_7, c1144_8, c1144_9, c1144_10; const initializeFromUserSettings = function initializeFromUserSettings() { const favorites = UserSettingsProtoStore.settings.favorites; let r9 = favorites?.muted; if (r9 == null) { r9 = false; } const favoriteChannels = favorites?.favoriteChannels; const r23 = {}; if (favoriteChannels != null) { for (const key in favoriteChannels) { const id = key; const r18 = favoriteChannels[id]; r23[id] = { id, nickname: r18.nickname !== "" ? r18.nickname : null, type: r18.type, channelType: r18.channelType?.value, order: r18.position, parentId: r18.parentId !== FAVORITES_UNCATEGORIZED_PARENT_ID ? r18.parentId : null }; } } const r32 = favorites == null ? void 0 : favorites.guildVisible?.value; let r35 = r32; if (r35 == null) { r35 = !isEmpty(r23); } let r43 = c1144_8 !== r9 || c1144_9 !== r35; const r46 = r32 === false; if (!r43) { r43 = c1144_10 !== r46; } if (!r43) { r43 = !isEqual(c1144_7, r23); } if (r43) { c1144_8 = r9; c1144_9 = r35; c1144_10 = r46; c1144_7 = r23; r43 = true; } return r43; }; c1144_7 = {}; c1144_8 = false; c1144_9 = false; c1144_10 = false; class FavoriteStore extends Module589.Store { static displayName = "FavoriteStore"; initialize() { this.waitFor(UserSettingsProtoStore); initializeFromUserSettings(); this.syncWith([UserSettingsProtoStore], initializeFromUserSettings); } getFavoriteChannels() { return c1144_7; } get favoriteGuildMuted() { return c1144_8; } get favoriteGuildEnabled() { return c1144_9; } get favoriteGuildExplicitlyHidden() { return c1144_10; } isFavorite(a0) { return a0 != null && c1144_7[a0] != null; } getFavorite(a0) { if (a0 != null) { return c1144_7[a0]; } } getCategoryRecord(a0) { const r0 = a0 in c1144_7; let r8 = null; if (r0) { const type = c1144_7[a0].type; const CATEGORY = FavoriteChannelType.CATEGORY; r8 = null; if (type === CATEGORY) { const r17 = c1144_7[a0]; let nickname = r17.nickname; if (nickname == null) { nickname = ""; } r8 = createChannelRecord({ id: r17.id, name: nickname, type: ChannelTypes.GUILD_CATEGORY, position: r17.order, guild_id: FAVORITES }); } } return r8; } getNickname(a0) { let r7 = this.getFavorite(a0)?.nickname; if (r7 == null) { r7 = void 0; } return r7; } getFavoritesCount() { return Object.keys(this.getFavoriteChannels()).length; } hasStoredFavorites() { return !isEmpty(this.getFavoriteChannels()); } } const favoriteStore = new FavoriteStore(Dispatcher, {}); export default favoriteStore;