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

+37
View File
@@ -0,0 +1,37 @@
// Metro module 16331 (f16332).
import { removeFavoriteChannel, setFavoriteCategoryCollapsed, setAllFavoriteCategoriesCollapsed } from "./FavoritesActionCreators";
import { isFavoritesGuildId } from "./FavoritesUtils";
import AutomaticLifecycleManager from "../../lib/AutomaticLifecycleManager";
let handleCategoryCollapse, handleCategoryExpand, handleCategoryCollapseAll, handleCategoryExpandAll;
const handleChannelDelete = function handleChannelDelete(a0) {
removeFavoriteChannel(a0.channel.id, {
trackAnalytics: false
});
};
handleCategoryCollapse = function handleCategoryCollapse(a0) {
setFavoriteCategoryCollapsed(a0.id, true);
};
handleCategoryExpand = function handleCategoryExpand(a0) {
setFavoriteCategoryCollapsed(a0.id, false);
};
handleCategoryCollapseAll = function handleCategoryCollapseAll(a0) {
if (isFavoritesGuildId(a0.guildId)) {
setAllFavoriteCategoriesCollapsed(true);
}
};
handleCategoryExpandAll = function handleCategoryExpandAll(a0) {
if (isFavoritesGuildId(a0.guildId)) {
setAllFavoriteCategoriesCollapsed(false);
}
};
class FavoriteManager extends AutomaticLifecycleManager {
actions = {
CHANNEL_DELETE: handleChannelDelete,
CATEGORY_COLLAPSE: handleCategoryCollapse,
CATEGORY_EXPAND: handleCategoryExpand,
CATEGORY_COLLAPSE_ALL: handleCategoryCollapseAll,
CATEGORY_EXPAND_ALL: handleCategoryExpandAll
};
}
const favoriteManager = new FavoriteManager();
export default favoriteManager;
+125
View File
@@ -0,0 +1,125 @@
// 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;
@@ -0,0 +1,474 @@
// Metro module 10214 (f10215).
import { THREAD_CHANNEL_TYPES } from "../../records/ChannelRecord";
import ChannelStore from "../../stores/ChannelStore";
import PermissionStore from "../../stores/PermissionStore";
import FavoriteStore from "./FavoriteStore";
import { FAVORITES_UNCATEGORIZED_PARENT_ID, MAX_FAVORITE_CHANNELS } from "./FavoritesConstants";
import { Permissions } from "../../_bundle/Module505";
import * as _Module1306 from "../../_bundle/Module1306";
import { FavoriteChannelType } from "../../_bundle/Module1306";
import { UInt32Value, BoolValue } from "../../_bundle/Module1337";
import Module12 from "../../_bundle/Module12";
import { getFavoritesAccess } from "./FavoritesHooks";
import AlertActionCreators from "../../actions/AlertActionCreators";
import { intl, t } from "../../intl/index.native";
import { PreloadedUserSettingsActionCreators, UserSettingsDelay, removeDismissedContent } from "../user_settings/UserSettingsProtoActionCreators";
import { trackFavoritesGuildRemoveFromFavorites, trackFavoritesGuildAddToFavorites, trackFavoritesGuildOrderUpdated, trackFavoritesGuildVisibilitySettingToggled } from "./FavoritesAnalytics";
import { isFavoritesGuildCategoryNameValid } from "./FavoritesUtils";
import SnowflakeUtils from "../../utils/SnowflakeUtils";
import { FAVORITES_GUILD_DISMISSIBLE_CONTENT } from "./FavoritesDismissibleContent";
function $mk84185($env) {
return (a0) => {
let r38;
const r13 = $env;
let r3 = false;
let r2 = r13[2][Symbol.iterator]();
const next = r2.next;
const r40 = $env.$parent;
while (true) {
const r41 = r2 === void 0 ? void 0 : (r38 = next.call(r2)).done ? r2 = void 0 : r38.value;
if (r2 !== void 0) {
L10: {
try {
const r17 = r40[13];
const favoriteChannels = a0.favoriteChannels;
const r20 = r40[0];
const r43 = r40[2];
const r48 = r17(favoriteChannels, r20(r43[6]).FavoriteChannelType.REFERENCE_ORIGINAL);
if (r48 == null) {
const r50 = r40[4];
const channel = r50.getChannel(r41);
const favoriteChannels2 = a0.favoriteChannels;
const FavoriteChannel = r20(r43[6]).FavoriteChannel;
const r60 = {
nickname: "",
type: r20(r43[6]).FavoriteChannelType.REFERENCE_ORIGINAL,
channelType: channel != null ? r20(r43[7]).UInt32Value.create({
value: channel.type
}) : void 0,
position: (0, r40[10])(a0.favoriteChannels),
parentId: null
};
let parentId = r13[0];
if (parentId == null) {
parentId = r40[7];
}
r60.parentId = parentId;
favoriteChannels2[r41] = FavoriteChannel.create(r60);
(0, r40[11])(a0.favoriteChannels);
const r75 = r40[12];
const favoriteChannels3 = a0.favoriteChannels;
r75(favoriteChannels3, r41);
r3 = true;
r20(r43[13]).trackFavoritesGuildAddToFavorites(r13[1], (0, r40[17])(r41, r20(r43[6]).FavoriteChannelType.REFERENCE_ORIGINAL), (0, r40[16])(a0.favoriteChannels));
continue;
}
(0, r40[14])(r48);
if (r3) {
break L10;
}
} catch (r97) {
if (r2 !== void 0 && typeof r2.return === "function") {
try {
r2.return();
} catch {}
}
throw r97;
}
const r95 = r2;
if (r95 !== void 0 && typeof r95.return === "function") {
r95.return();
}
return false;
}
const r96 = r2;
if (r96 !== void 0 && typeof r96.return === "function") {
r96.return();
}
}
return void 0;
}
};
}
function $mk84187($env) {
return (a0) => {
if ((0, $env[0])(a0)) {
return void 0;
}
return false;
};
}
let cleanFavoriteChannels, cleanupChannelParentId, getReachedLimit, showLimitReachedAlert, onSaveFailed, getFavoritesCount, getAnalyticsChannelType, removeFavoriteChannel;
let $mk84182 = function() {
return (a0) => a0.type !== FavoriteChannelType.CATEGORY;
}, $mk84184 = function() {
return (a0) => !FavoriteStore.isFavorite(a0);
};
let env6810 = {};
const getNextPositionFromChannels = function getNextPositionFromChannels(a0) {
let r16;
let r7 = 0;
let r6 = 0;
for (const key in a0) {
r16 = r7;
r6 = r16;
const r17 = a0[key];
r7 = r17 != null && r17.position != null ? Math.max(r16, r17.position) : r16;
}
r16 = r7;
r6 = r16;
return r6 + 1;
};
cleanFavoriteChannels = function cleanFavoriteChannels(a0) {
for (const key in a0) {
const r12 = a0[key];
if (r12 != null) {
if (r12.type !== FavoriteChannelType.CATEGORY) {
const channel = ChannelStore.getChannel(key);
if (channel != null) {
if (r12.channelType == null) {
r12.channelType = UInt32Value.create({
value: channel.type
});
}
if (!(channel.isPrivate() || PermissionStore.can(Permissions.VIEW_CHANNEL, channel))) {
delete a0[key];
}
} else {
const value2 = r12.channelType?.value;
if (value2 != null && THREAD_CHANNEL_TYPES.has(value2)) {
continue;
}
delete a0[key];
}
}
} else {
delete a0[key];
}
}
};
cleanupChannelParentId = function cleanupChannelParentId(a0, a1) {
const r3 = a0[a1];
if (r3 != null) {
if (r3.parentId !== FAVORITES_UNCATEGORIZED_PARENT_ID) {
const r10 = r3.parentId != null ? a0[r3.parentId] : null;
if (!(r10 != null && r10.type === FavoriteChannelType.CATEGORY)) {
r3.parentId = FAVORITES_UNCATEGORIZED_PARENT_ID;
}
}
}
};
getReachedLimit = function getReachedLimit(a0, a1) {
cleanFavoriteChannels(a0);
if (Module12.size(a0) >= MAX_FAVORITE_CHANNELS) {
return MAX_FAVORITE_CHANNELS;
}
const favoriteLimit = getFavoritesAccess().favoriteLimit;
return favoriteLimit <= 0 ? null : a1 !== FavoriteChannelType.CATEGORY ? Module12.filter(a0, $mk84182()).length >= favoriteLimit ? favoriteLimit : null : null;
};
showLimitReachedAlert = function showLimitReachedAlert(a0) {
AlertActionCreators.show({
title: intl.string(t["+XYXtZ"]),
body: intl.formatToPlainString(t.JaIyFi, {
count: a0
})
});
};
onSaveFailed = function onSaveFailed() {
AlertActionCreators.show({
title: intl.string(t.iufib1),
body: intl.string(t.eAn6z2),
onCloseCallback: function onCloseCallback() {
window.location.reload();
}
});
};
getFavoritesCount = function getFavoritesCount(a0) {
return Object.keys(a0).length;
};
getAnalyticsChannelType = function getAnalyticsChannelType(a0, a1) {
const CATEGORY = FavoriteChannelType.CATEGORY;
let r11 = null;
if (a1 !== CATEGORY) {
let r16 = ChannelStore.getChannel(a0)?.type;
if (r16 == null) {
r16 = null;
}
r11 = r16;
}
return r11;
};
removeFavoriteChannel = function removeFavoriteChannel(a0) {
let c17767_3;
let c17767_0 = a0;
let r4 = arguments[1];
if (r4 === void 0) {
r4 = {};
}
let trackAnalytics = r4.trackAnalytics;
if (trackAnalytics === void 0) {
trackAnalytics = true;
}
let c17767_1 = trackAnalytics;
c17767_3 = void 0;
const favorite = FavoriteStore.getFavorite(a0);
if (favorite != null) {
let r17 = null;
if (trackAnalytics) {
const type = favorite.type;
const CATEGORY = FavoriteChannelType.CATEGORY;
let r24 = null;
if (type !== CATEGORY) {
let r28 = ChannelStore.getChannel(a0)?.type;
if (r28 == null) {
r28 = null;
}
r24 = r28;
}
r17 = r24;
}
c17767_3 = r17;
PreloadedUserSettingsActionCreators.updateAsync("favorites", (a0) => {
delete a0.favoriteChannels[c17767_0];
if (favorite.type === FavoriteChannelType.CATEGORY) {
const favoriteChannels = a0.favoriteChannels;
for (const key in favoriteChannels) {
if (a0.favoriteChannels[key].parentId === c17767_0) {
a0.favoriteChannels[key].parentId = FAVORITES_UNCATEGORIZED_PARENT_ID;
}
}
}
cleanFavoriteChannels(a0.favoriteChannels);
if (c17767_1) {
trackFavoritesGuildRemoveFromFavorites(c17767_3, Object.keys(a0.favoriteChannels).length);
}
}, UserSettingsDelay.INFREQUENT_USER_ACTION, onSaveFailed);
}
};
export function addFavoriteChannel(a0, a1, r4 = "channel_context_menu") {
let env17768;
const r6 = [a0];
const r13 = env17768 = {
$parent: env6810
};
env17768[0] = a1;
if (r4 === void 0) {
r4 = "channel_context_menu";
}
env17768[1] = r4;
env17768[2] = void 0;
const r16 = r6.filter($mk84184());
env17768[2] = r16;
if (r16.length !== 0) {
const FREQUENT_USER_ACTION = UserSettingsDelay.FREQUENT_USER_ACTION;
PreloadedUserSettingsActionCreators.updateAsync("favorites", $mk84185(r13), FREQUENT_USER_ACTION, onSaveFailed);
}
}
export function addFavoriteChannels(a0, a1) {
let env17766;
const r2 = env17766 = {
$parent: env6810
};
env17766[0] = a1;
let r4 = arguments[2];
if (r4 === void 0) {
r4 = "channel_context_menu";
}
env17766[1] = r4;
env17766[2] = void 0;
const r15 = a0.filter($mk84184());
env17766[2] = r15;
if (r15.length !== 0) {
const FREQUENT_USER_ACTION = UserSettingsDelay.FREQUENT_USER_ACTION;
PreloadedUserSettingsActionCreators.updateAsync("favorites", $mk84185(r2), FREQUENT_USER_ACTION, onSaveFailed);
}
}
export { removeFavoriteChannel };
export function setFavoriteChannelNickname(a0, c17769_1) {
let c17769_0 = a0;
if (FavoriteStore.isFavorite(a0)) {
PreloadedUserSettingsActionCreators.updateAsync("favorites", (a0) => {
const r5 = a0.favoriteChannels[c17769_0];
let nickname2 = c17769_1;
if (nickname2 == null) {
nickname2 = "";
}
r5.nickname = nickname2;
}, UserSettingsDelay.INFREQUENT_USER_ACTION, onSaveFailed);
}
}
export function addFavoriteCategory(a0, r3 = "modal") {
let nickname, c17770_2;
let c17770_0 = r3;
nickname = void 0;
c17770_2 = void 0;
if (isFavoritesGuildCategoryNameValid(a0)) {
nickname = a0.trim();
c17770_2 = SnowflakeUtils.fromTimestamp(Date.now());
PreloadedUserSettingsActionCreators.updateAsync("favorites", (a0) => {
let r29;
const favoriteChannels = a0.favoriteChannels;
const CATEGORY = FavoriteChannelType.CATEGORY;
cleanFavoriteChannels(favoriteChannels);
const r35 = Module12.size(favoriteChannels);
let MAX_FAVORITE_CHANNELS2 = MAX_FAVORITE_CHANNELS;
if (!(r35 >= MAX_FAVORITE_CHANNELS2)) {
const favoriteLimit = getFavoritesAccess().favoriteLimit;
MAX_FAVORITE_CHANNELS2 = favoriteLimit <= 0 ? null : CATEGORY !== FavoriteChannelType.CATEGORY ? Module12.filter(favoriteChannels, $mk84182()).length >= favoriteLimit ? favoriteLimit : null : null;
}
if (MAX_FAVORITE_CHANNELS2 != null) {
AlertActionCreators.show({
title: intl.string(t["+XYXtZ"]),
body: intl.formatToPlainString(t.JaIyFi, {
count: MAX_FAVORITE_CHANNELS2
})
});
return false;
}
const { favoriteChannels: favoriteChannels3, favoriteChannels: favoriteChannels2 } = a0;
let r21 = 0;
let r20 = 0;
for (const key in favoriteChannels2) {
r29 = r21;
r20 = r29;
const r67 = favoriteChannels2[key];
r21 = r67 != null && r67.position != null ? Math.max(r29, r67.position) : r29;
}
r29 = r21;
r20 = r29;
favoriteChannels3[c17770_2] = _Module1306.FavoriteChannel.create({
nickname,
type: FavoriteChannelType.CATEGORY,
position: r20 + 1,
parentId: FAVORITES_UNCATEGORIZED_PARENT_ID
});
const CATEGORY2 = FavoriteChannelType.CATEGORY;
const CATEGORY3 = FavoriteChannelType.CATEGORY;
let r88 = null;
if (CATEGORY2 !== CATEGORY3) {
let r93 = ChannelStore.getChannel(c17770_2)?.type;
if (r93 == null) {
r93 = null;
}
r88 = r93;
}
trackFavoritesGuildAddToFavorites(c17770_0, r88, Object.keys(a0.favoriteChannels).length);
}, UserSettingsDelay.FREQUENT_USER_ACTION, onSaveFailed);
}
}
export function removeFavoriteCategory(a0) {
removeFavoriteChannel(a0);
}
export function setFavoriteCategoryCollapsed(a0, collapsed) {
let c17771_0 = a0;
const favorite2 = FavoriteStore.getFavorite(a0);
if (favorite2 != null && favorite2.type === FavoriteChannelType.CATEGORY) {
let env17772;
const r23 = env17772 = {};
env17772[0] = (a0) => {
const r8 = a0.favoriteChannels[c17771_0];
let r10 = r8 != null && r8.type === FavoriteChannelType.CATEGORY && r8.collapsed !== collapsed;
if (r10) {
r8.collapsed = collapsed;
r10 = true;
}
return r10;
};
const FREQUENT_USER_ACTION = UserSettingsDelay.FREQUENT_USER_ACTION;
PreloadedUserSettingsActionCreators.updateAsync("favorites", $mk84187(r23), FREQUENT_USER_ACTION, onSaveFailed);
}
}
export function setAllFavoriteCategoriesCollapsed(collapsed2) {
let env17774;
const r12 = env17774 = {};
env17774[0] = (a0) => {
let r4;
const favoriteChannels = a0.favoriteChannels;
let r3 = false;
let r6 = false;
for (const key in favoriteChannels) {
r4 = r3;
r6 = r4;
const r21 = a0.favoriteChannels[key];
let r2 = r21 != null && r21.type === FavoriteChannelType.CATEGORY && r21.collapsed !== collapsed2;
if (r2) {
r21.collapsed = collapsed2;
r2 = true;
}
r3 = r2 ? true : r4;
}
r4 = r3;
r6 = r4;
return r6;
};
const FREQUENT_USER_ACTION = UserSettingsDelay.FREQUENT_USER_ACTION;
PreloadedUserSettingsActionCreators.updateAsync("favorites", $mk84187(r12), FREQUENT_USER_ACTION, onSaveFailed);
}
export function updateFavoriteChannels(a0) {
let c17775_0 = a0;
if (a0.length !== 0) {
PreloadedUserSettingsActionCreators.updateAsync("favorites", (a0) => {
for (const item of c17775_0) {
const id = item.id;
if (item.position != null) {
a0.favoriteChannels[id].position = item.position;
}
if (item.parent_id !== void 0) {
const r40 = a0.favoriteChannels[id];
let parent_id = item.parent_id;
if (parent_id == null) {
parent_id = FAVORITES_UNCATEGORIZED_PARENT_ID;
}
r40.parentId = parent_id;
cleanupChannelParentId(a0.favoriteChannels, id);
}
}
trackFavoritesGuildOrderUpdated();
}, UserSettingsDelay.FREQUENT_USER_ACTION, onSaveFailed);
}
}
export function updateFavoriteChannelParent(c17776_0, c17776_1) {
PreloadedUserSettingsActionCreators.updateAsync("favorites", (a0) => {
const favoriteChannels = a0.favoriteChannels;
const r8 = favoriteChannels[c17776_0];
let parentId = c17776_1;
if (parentId == null) {
parentId = FAVORITES_UNCATEGORIZED_PARENT_ID;
}
r8.parentId = parentId;
const favoriteChannels2 = a0.favoriteChannels;
const r10 = favoriteChannels2[c17776_0];
if (r10 != null) {
if (r10.parentId !== FAVORITES_UNCATEGORIZED_PARENT_ID) {
const r15 = r10.parentId != null ? favoriteChannels2[r10.parentId] : null;
if (!(r15 != null && r15.type === FavoriteChannelType.CATEGORY)) {
r10.parentId = FAVORITES_UNCATEGORIZED_PARENT_ID;
}
}
}
}, UserSettingsDelay.FREQUENT_USER_ACTION, onSaveFailed);
}
export function toggleFavoriteGuildMuted() {
PreloadedUserSettingsActionCreators.updateAsync("favorites", (a0) => {
a0.muted = !a0.muted;
}, UserSettingsDelay.INFREQUENT_USER_ACTION, onSaveFailed);
}
export function resetFavoritesGuild() {
PreloadedUserSettingsActionCreators.updateAsync("favorites", (a0) => {
a0.favoriteChannels = {};
a0.guildVisible = void 0;
a0.muted = false;
}, UserSettingsDelay.INFREQUENT_USER_ACTION, onSaveFailed);
for (const item of FAVORITES_GUILD_DISMISSIBLE_CONTENT) {
removeDismissedContent(item);
}
}
export function setFavoritesGuildVisibility(value, r3 = "settings_page") {
let c17777_1 = r3;
PreloadedUserSettingsActionCreators.updateAsync("favorites", (a0) => {
a0.guildVisible = BoolValue.create({
value
});
trackFavoritesGuildVisibilitySettingToggled(c17777_1, value);
}, UserSettingsDelay.INFREQUENT_USER_ACTION, onSaveFailed);
}
+56
View File
@@ -0,0 +1,56 @@
// Metro module 10219 (f10220).
import SelectedGuildStore from "../../stores/SelectedGuildStore";
import { AnalyticEvents } from "../../Constants";
import { isFavoritesGuildId } from "./FavoritesUtils";
import AnalyticsUtils from "../../utils/AnalyticsUtils";
let c6814_5 = "manual_browsing";
export function setNextFavoritesGuildViewSource(a0) {
if (!isFavoritesGuildId(SelectedGuildStore.getGuildId())) {
c6814_5 = a0;
}
}
export function consumeNextFavoritesGuildViewSource() {
const r0 = c6814_5;
c6814_5 = "manual_browsing";
return r0;
}
export function trackFavoritesGuildAddToFavorites(a0, a1, a2) {
AnalyticsUtils.track(AnalyticEvents.FAVORITES_GUILD_ADD_TO_FAVORITES, {
source: a0,
channel_type: a1,
total_favorites: a2
});
}
export function trackFavoritesGuildRemoveFromFavorites(a0, a1) {
AnalyticsUtils.track(AnalyticEvents.FAVORITES_GUILD_REMOVE_FROM_FAVORITES, {
channel_type: a0,
total_favorites: a1
});
}
export function trackFavoritesGuildOrderUpdated() {
AnalyticsUtils.track(AnalyticEvents.FAVORITES_GUILD_ORDER_UPDATED);
}
export function trackFavoritesGuildVisibilitySettingToggled(a0, a1) {
AnalyticsUtils.track(AnalyticEvents.FAVORITES_GUILD_SETTING_TOGGLED, {
source: a0,
is_visible: a1
});
}
export function trackFavoritesGuildUpsellModalOpened(a0) {
AnalyticsUtils.track(AnalyticEvents.FAVORITES_GUILD_UPSELL_MODAL_OPENED, {
source: a0
});
}
export function trackFavoritesGuildAddModalOpened(a0) {
AnalyticsUtils.track(AnalyticEvents.FAVORITES_GUILD_ADD_MODAL_OPENED, {
source: a0
});
}
export function trackFavoritesGuildViewed(a0, a1, a2, a3) {
AnalyticsUtils.track(AnalyticEvents.FAVORITES_GUILD_VIEWED, {
source: a0,
total_favorites: a1,
is_xp_enabled: a2,
is_premium_tier_2: a3
});
}
+15
View File
@@ -0,0 +1,15 @@
// Metro module 1410 (f1411).
import { constructFromPartialGuildRecord } from "../../utils/GuildRecordUtils";
const r23 = constructFromPartialGuildRecord({
id: "373",
name: "Favorites",
description: "The place for all your favorite channels!",
joinedAt: new Date(),
maxMembers: 500000
});
export const FAVORITES_RAW_GUILD_ID = "373";
export { r23 as FAVORITES_GUILD_RECORD };
export const FAVORITES_UNCATEGORIZED_PARENT_ID = "0";
export const MAX_FAVORITE_CHANNELS = 200;
export const MAX_FAVORITES_ADD_CHANNEL_COUNT = 20;
export const MAX_FAVORITE_CATEGORY_NAME_LENGTH = 100;
@@ -0,0 +1,4 @@
// Metro module 10220 (f10221).
import { DismissibleContent } from "../../_bundle/Module1358";
const r14 = [DismissibleContent.FAVORITES_SERVER_ONBOARDING_INTRO, DismissibleContent.FAVORITES_SERVER_ONBOARDING_MENU_ITEM, DismissibleContent.FAVORITES_GUILD_NEW_BADGE];
export { r14 as FAVORITES_GUILD_DISMISSIBLE_CONTENT };
@@ -0,0 +1,35 @@
// Metro module 10218 (f10219).
import { createApexExperiment } from "../experiments/apex/index";
const apexExperiment = createApexExperiment({
name: "2026-01-favorites-server",
kind: "user",
defaultConfig: {
enabled: false,
hasHigherPrivileges: false
},
variations: {
1: {
enabled: true,
hasHigherPrivileges: true
},
2: {
enabled: true,
hasHigherPrivileges: false
},
3: {
enabled: true,
hasHigherPrivileges: true,
isFreemium: true
}
}
});
export function useFavoritesGuildConfig(a0) {
return apexExperiment.useConfig({
location: a0.location
});
}
export function getFavoritesGuildConfig(a0) {
return apexExperiment.getConfig({
location: a0.location
});
}
+169
View File
@@ -0,0 +1,169 @@
// Metro module 10215 (f10216).
import SelectedGuildStore from "../../stores/SelectedGuildStore";
import UserStore from "../../stores/UserStore";
import FavoriteStore from "./FavoriteStore";
import { useFavoritesNotificationStore } from "./FavoritesNotificationStore";
import { MAX_FAVORITE_CHANNELS } from "./FavoritesConstants";
import { PremiumTypes } from "../premium/PremiumConstants";
import { FREE_FAVORITE_LIMIT } from "../../_bundle/Module10217";
import { useFavoritesGuildConfig, getFavoritesGuildConfig } from "./FavoritesGuildExperiment";
import { useStateFromStores, useStateFromStoresObject } from "../../_bundle/Module589";
import PremiumTypeUtils from "../../utils/PremiumTypeUtils";
import SnowflakeUtils from "../../utils/SnowflakeUtils";
import { FavoriteChannelType } from "../../_bundle/Module1306";
import * as _FavoritesUtils from "./FavoritesUtils";
function $mk84199($env) {
return (a0, a1) => {
const r6 = $env[0];
let r9 = r6[a0.id]?.order;
if (r9 == null) {
r9 = 0;
}
let r4 = r6[a1.id]?.order;
if (r4 == null) {
r4 = 0;
}
return r9 - r4;
};
}
let $mk84198 = function() {
return () => FavoriteStore.getFavoriteChannels();
}, $mk84200 = function() {
return () => SelectedGuildStore.getGuildId();
};
const useFavoritesAccess = function useFavoritesAccess(location2 = "useFavoritesAccess") {
const favoritesGuildConfig = useFavoritesGuildConfig({
location: location2
});
const { enabled, hasHigherPrivileges, isFreemium: isFreemium2 = false } = favoritesGuildConfig;
const isPremiumExactly = PremiumTypeUtils.isPremiumExactly(useStateFromStores([UserStore], () => UserStore.getCurrentUser()), PremiumTypes.TIER_2);
const hasAccess = enabled && (isPremiumExactly || isFreemium2);
return {
hasAccess,
isExperimentEnabled: enabled,
isFreemium: isFreemium2,
hasHigherPrivileges,
favoriteLimit: hasAccess ? isPremiumExactly ? MAX_FAVORITE_CHANNELS : isFreemium2 ? FREE_FAVORITE_LIMIT : 0 : 0
};
};
export { useFavoritesAccess };
export function getFavoritesAccess() {
const favoritesGuildConfig = getFavoritesGuildConfig({
location: "getFavoritesAccess"
});
const { enabled, hasHigherPrivileges, isFreemium: isFreemium2 = false } = favoritesGuildConfig;
const isPremiumExactly = PremiumTypeUtils.isPremiumExactly(UserStore.getCurrentUser(), PremiumTypes.TIER_2);
const hasAccess = enabled && (isPremiumExactly || isFreemium2);
return {
hasAccess,
isExperimentEnabled: enabled,
isFreemium: isFreemium2,
hasHigherPrivileges,
favoriteLimit: hasAccess ? isPremiumExactly ? MAX_FAVORITE_CHANNELS : isFreemium2 ? FREE_FAVORITE_LIMIT : 0 : 0
};
}
export function useFavorites() {
return useStateFromStoresObject([FavoriteStore], $mk84198());
}
export function useFavorite(c17779_0) {
return useStateFromStores([FavoriteStore], () => FavoriteStore.getFavorite(c17779_0));
}
export function useFavoritedChannelIds() {
return SnowflakeUtils.keys(useStateFromStoresObject([FavoriteStore], $mk84198()));
}
export function getFavoritesCategories(r10 = FavoriteStore.getFavoriteChannels()) {
let env17778;
const r16 = env17778 = {};
env17778[0] = r10;
const r17 = [{
id: null,
name: ""
}];
for (const key in r10) {
const r14 = r10[key];
if (r14.type === FavoriteChannelType.CATEGORY) {
let nickname = r14.nickname;
if (nickname == null) {
nickname = "";
}
r17.push({
id: r14.id,
name: nickname
});
}
}
r17.sort($mk84199(r16));
return r17;
}
export function useFavoritesCategories() {
return useStateFromStores([FavoriteStore], () => {
let env26637;
let r10 = FavoriteStore.getFavoriteChannels();
const r5 = env26637 = {};
env26637[0] = void 0;
if (r10 === void 0) {
r10 = FavoriteStore.getFavoriteChannels();
}
env26637[0] = r10;
const r18 = [{
id: null,
name: ""
}];
for (const key in r10) {
const r14 = r10[key];
if (r14.type === FavoriteChannelType.CATEGORY) {
let nickname = r14.nickname;
if (nickname == null) {
nickname = "";
}
r18.push({
id: r14.id,
name: nickname
});
}
}
r18.sort($mk84199(r5));
return r18;
});
}
export function useIsFavoritesGuildSelected() {
return _FavoritesUtils.isFavoritesGuildId(useStateFromStores([SelectedGuildStore], $mk84200()));
}
export function useFavoritesAwareChannel(a0, a1) {
let r31;
let c17780_0;
L9: {
let r4 = a0;
c17780_0 = a0;
const isFavoritesGuildId = _FavoritesUtils.isFavoritesGuildId(useStateFromStores([SelectedGuildStore], $mk84200()));
const hasAccess = useFavoritesAccess(a1).hasAccess;
const stateFromStores = useStateFromStores([FavoriteStore], () => c17780_0 != null && (FavoriteStore.isFavorite(c17780_0.id) || c17780_0.isThread() && FavoriteStore.isFavorite(c17780_0.parent_id)), [a0]);
if (isFavoritesGuildId) {
r31 = null;
if (!hasAccess) {
break L9;
}
r31 = null;
if (!stateFromStores) {
break L9;
}
const r32 = a0 == null ? void 0 : a0.isCategory();
r31 = null;
if (r32) {
break L9;
}
}
if (a0 == null) {
r4 = null;
}
r31 = r4;
}
return r31;
}
export function useFavoriteAdded() {
return {
favoriteAdded: useFavoritesNotificationStore((a0) => a0.favoriteAdded),
notifyFavoriteAdded: useFavoritesNotificationStore((a0) => a0.notifyFavoriteAdded),
clearFavoriteAdded: useFavoritesNotificationStore((a0) => a0.clearFavoriteAdded)
};
}
@@ -0,0 +1,13 @@
// Metro module 10216 (f10217).
import { create } from "../../_bundle/Module644";
import { batchUpdates } from "../../_bundle/Module705";
const r15 = create((c17781_0) => ({
favoriteAdded: false,
notifyFavoriteAdded: () => batchUpdates(() => c17781_0({
favoriteAdded: true
})),
clearFavoriteAdded: () => batchUpdates(() => c17781_0({
favoriteAdded: false
}))
}));
export { r15 as useFavoritesNotificationStore };
+25
View File
@@ -0,0 +1,25 @@
// Metro module 1865 (f1866).
import { FAVORITES_RAW_GUILD_ID } from "./FavoritesConstants";
import { FAVORITES } from "../../Constants";
import { intl, t } from "../../intl/index.native";
export function getFavoritesAwareGuildName(a0) {
if (a0 != null) {
const id = a0.id;
return id === FAVORITES_RAW_GUILD_ID || id === FAVORITES ? intl.string(t.wMWyci) : a0.name;
}
}
export function isFavoritesGuildId(a0) {
return a0 === FAVORITES_RAW_GUILD_ID || a0 === FAVORITES;
}
export function isFavoritesGuildCategoryNameValid(a0) {
return a0.trim() !== "";
}
export function canFavoriteChannelType(a0, a1) {
const isCategory = a0.isCategory();
let r3 = !isCategory;
if (!isCategory) {
const isThread = a0.isThread();
r3 = isThread ? a1 : !isThread;
}
return r3;
}
@@ -0,0 +1,30 @@
// Metro module 11882 (f11883).
import { useCallback } from "react";
import ChannelStore from "../../../stores/ChannelStore";
import PermissionStore from "../../../stores/PermissionStore";
import FavoriteStore from "../FavoriteStore";
import { Permissions } from "../../../Constants";
import { useFavoritesAccess } from "../FavoritesHooks";
import { useStateFromStores } from "../../../_bundle/Module589";
import { AutocompleterResultTypes } from "../../autocompleter/index";
import { canFavoriteChannelType } from "../FavoritesUtils";
import { assertNever } from "../../../utils/GlobalUtils";
export default function useFavoritesGuildChannelFilter() {
const hasHigherPrivileges = useFavoritesAccess().hasHigherPrivileges;
const stateFromStores = useStateFromStores([FavoriteStore], () => FavoriteStore.getFavoriteChannels());
return useCallback((a0, a1) => {
const type = a0.type;
if (AutocompleterResultTypes.USER === type) {
const dMChannelFromUserId = ChannelStore.getDMChannelFromUserId(a0.record.id);
const r1 = a1 ? !a1 : dMChannelFromUserId == null;
return r1 ? !r1 : dMChannelFromUserId == null || stateFromStores[dMChannelFromUserId.id] == null;
}
if (AutocompleterResultTypes.GROUP_DM === type) {
return stateFromStores[a0.record.id] == null;
}
if (AutocompleterResultTypes.TEXT_CHANNEL !== type && AutocompleterResultTypes.VOICE_CHANNEL !== type) {
return assertNever(a0);
}
return PermissionStore.can(Permissions.VIEW_CHANNEL, a0.record) && canFavoriteChannelType(a0.record, hasHigherPrivileges) && stateFromStores[a0.record.id] == null;
}, [stateFromStores, hasHigherPrivileges]);
};
@@ -0,0 +1,18 @@
// Metro module 15125 (f15126).
import { useCallback } from "react";
import { Routes } from "../../../Constants";
import { useFavoritesAccess } from "../FavoritesHooks";
import { transitionTo } from "../../routing/router_utils";
import { intl, t } from "../../../intl/index.native";
import FavoritesGuild_messages from "../intl/FavoritesGuild.messages";
export default function useFavoritesGuildHeaderAction() {
const hasAccess = useFavoritesAccess().hasAccess;
const callback = useCallback(() => {
transitionTo(Routes.ME);
}, []);
return {
isPreview: !hasAccess,
label: intl.string(hasAccess ? FavoritesGuild_messages.G9fGlP : t.ojM1xJ),
exitPreview: callback
};
};
@@ -0,0 +1,27 @@
// Metro module 15122 (f15123).
import { useCallback } from "react";
import SelectedGuildStore from "../../../stores/SelectedGuildStore";
import { Routes } from "../../../Constants";
import { useFavoritesAccess } from "../FavoritesHooks";
import { setFavoritesGuildVisibility } from "../FavoritesActionCreators";
import { isFavoritesGuildId } from "../FavoritesUtils";
import { transitionTo } from "../../routing/router_utils";
import { intl, t } from "../../../intl/index.native";
import FavoritesGuild_messages from "../intl/FavoritesGuild.messages";
export default function useFavoritesGuildHideAction() {
const hasAccess = useFavoritesAccess().hasAccess;
const callback = useCallback(() => {
if (hasAccess) {
setFavoritesGuildVisibility(false, "server_context_menu");
}
if (isFavoritesGuildId(SelectedGuildStore.getGuildId())) {
transitionTo(Routes.ME);
}
}, [hasAccess]);
return {
isPreview: !hasAccess,
label: intl.string(hasAccess ? FavoritesGuild_messages["8FO0y9"] : t.ojM1xJ),
subLabel: hasAccess ? intl.string(FavoritesGuild_messages.FaHxWl) : void 0,
perform: callback
};
};
@@ -0,0 +1,23 @@
// Metro module 15123 (f15124).
import { useCallback } from "react";
import { DeveloperMode } from "../../user_settings/UserSettings";
import { useFavoritesAccess } from "../FavoritesHooks";
import { resetFavoritesGuild } from "../FavoritesActionCreators";
import { intl } from "../../../intl/index.native";
import FavoritesGuild_messages from "../intl/FavoritesGuild.messages";
export default function useFavoritesGuildResetAction() {
let isAvailable = DeveloperMode.useSetting();
const hasAccess = useFavoritesAccess().hasAccess;
const callback = useCallback(() => {
resetFavoritesGuild();
}, []);
if (isAvailable) {
isAvailable = hasAccess;
}
return {
isAvailable,
label: intl.string(FavoritesGuild_messages.YkET6R),
subLabel: intl.string(FavoritesGuild_messages.ZzcwNk),
perform: callback
};
};
@@ -0,0 +1,42 @@
// Metro module 14970 (f14971).
import ActiveJoinedThreadsStore from "../../threads/ActiveJoinedThreadsStore";
import JoinedThreadsStore from "../../threads/JoinedThreadsStore";
import ChannelStore from "../../../stores/ChannelStore";
import GuildReadStateStore from "../../../stores/GuildReadStateStore";
import PermissionStore from "../../../stores/PermissionStore";
import ReadStateStore from "../../../stores/ReadStateStore";
import UserGuildSettingsStore from "../../../stores/UserGuildSettingsStore";
import { useStateFromStoresObject } from "../../../_bundle/Module589";
import SnowflakeUtils from "../../../utils/SnowflakeUtils";
export default function useFavoritesGuildUnreads(c21493_0) {
return useStateFromStoresObject([ActiveJoinedThreadsStore, ChannelStore, GuildReadStateStore, JoinedThreadsStore, PermissionStore, ReadStateStore, UserGuildSettingsStore], () => {
const r13 = SnowflakeUtils.keys(c21493_0);
let c27877_0 = new Set();
return r13.reduce((acc, item) => {
const channel = ChannelStore.getChannel(item);
const r7 = channel == null ? void 0 : channel.getGuildId();
const mentionCount = ReadStateStore.getMentionCount(item);
if (!c27877_0.has(item)) {
c27877_0.add(item);
acc.badge = acc.badge + mentionCount;
}
acc.unread = acc.unread || ReadStateStore.hasUnread(item) && GuildReadStateStore.shouldCountChannelUnread(channel, mentionCount);
if (r7 != null) {
const activeJoinedRelevantThreadsForParent = ActiveJoinedThreadsStore.getActiveJoinedRelevantThreadsForParent(r7, item);
for (const key in activeJoinedRelevantThreadsForParent) {
const mentionCount2 = ReadStateStore.getMentionCount(key);
if (!c27877_0.has(key)) {
c27877_0.add(key);
acc.badge = acc.badge + mentionCount2;
}
const channel2 = ChannelStore.getChannel(key);
acc.unread = acc.unread || ReadStateStore.hasUnread(key) && GuildReadStateStore.shouldCountChannelUnread(channel2, mentionCount2);
}
}
return acc;
}, {
badge: 0,
unread: false
});
});
};
@@ -0,0 +1,14 @@
// Metro module 10221 (f10222).
import FavoriteStore from "../FavoriteStore";
import { getFavoritesAccess, useFavoritesAccess } from "../FavoritesHooks";
import { useStateFromStores } from "../../../_bundle/Module589";
export function computeIsFavoritesGuildEnabled(a0, a1) {
return a0 ? !a1.favoriteGuildExplicitlyHidden : a1.favoriteGuildEnabled;
}
export function getIsFavoritesGuildEnabled() {
return getFavoritesAccess().isFreemium ? !FavoriteStore.favoriteGuildExplicitlyHidden : FavoriteStore.favoriteGuildEnabled;
}
export function useIsFavoritesGuildEnabled() {
const isFreemium = useFavoritesAccess("useIsFavoritesGuildEnabled").isFreemium;
return useStateFromStores([FavoriteStore], () => isFreemium ? !FavoriteStore.favoriteGuildExplicitlyHidden : FavoriteStore.favoriteGuildEnabled);
}
@@ -0,0 +1,36 @@
// Metro module 15014 (f15015).
import { isContentShown, useIsContentShown } from "../../dismissible_content/DismissibleContentShownStateStore";
import SelectedGuildStore from "../../../stores/SelectedGuildStore";
import FavoriteStore from "../FavoriteStore";
import { isFavoritesGuildId } from "../FavoritesUtils";
import { computeIsFavoritesGuildEnabled } from "./useIsFavoritesGuildEnabled";
import { useFavoritesAccess, getFavoritesAccess } from "../FavoritesHooks";
import { DismissibleContent } from "../../../_bundle/Module1358";
import { useIsDismissibleContentDismissed_UNSAFE, UNSAFE_isDismissibleContentDismissed } from "../../dismissible_content/DismissibleContentUnsafeUtils";
import { useStateFromStores } from "../../../_bundle/Module589";
export default function useIsFavoritesGuildVisible(a0) {
const favoritesAccess = useFavoritesAccess(a0);
const { isExperimentEnabled, isFreemium, hasAccess } = favoritesAccess;
const isContentShown2 = useIsContentShown(DismissibleContent.FAVORITES_SERVER_ONBOARDING_MENU_ITEM);
const isDismissibleContentDismissed_UNSAFE = useIsDismissibleContentDismissed_UNSAFE(DismissibleContent.FAVORITES_SERVER_ONBOARDING_INTRO);
return useStateFromStores([FavoriteStore, SelectedGuildStore], () => {
let r14 = !!isExperimentEnabled;
if (r14) {
const r6 = isContentShown2 ? isDismissibleContentDismissed_UNSAFE : !isContentShown2;
r14 = r6 ? !!isFavoritesGuildId(SelectedGuildStore.getGuildId()) || !!hasAccess && computeIsFavoritesGuildEnabled(isFreemium, FavoriteStore) : !r6;
}
return r14;
}, [isExperimentEnabled, isFreemium, hasAccess, isContentShown2, isDismissibleContentDismissed_UNSAFE]);
};
export function isFavoritesGuildVisible() {
const favoritesAccess = getFavoritesAccess();
const { isExperimentEnabled: isExperimentEnabled2, isFreemium: isFreemium2, hasAccess: hasAccess2 } = favoritesAccess;
const isContentShown3 = isContentShown(DismissibleContent.FAVORITES_SERVER_ONBOARDING_MENU_ITEM);
const r26 = UNSAFE_isDismissibleContentDismissed(DismissibleContent.FAVORITES_SERVER_ONBOARDING_INTRO);
let r28 = !!isExperimentEnabled2;
if (r28) {
const r29 = isContentShown3 ? r26 : !isContentShown3;
r28 = r29 ? !!isFavoritesGuildId(SelectedGuildStore.getGuildId()) || !!hasAccess2 && computeIsFavoritesGuildEnabled(isFreemium2, FavoriteStore) : !r29;
}
return r28;
}
@@ -0,0 +1,132 @@
// Metro module 2969 (f2970).
import { loadJsonAsset } from "../../asset_json/native/AssetJsonUtils";
import * as _Module2970 from "../../../_bundle/Module2970";
import * as _Module2971 from "../../../_bundle/Module2971";
import * as _Module2972 from "../../../_bundle/Module2972";
import * as _Module2973 from "../../../_bundle/Module2973";
import * as _Module2974 from "../../../_bundle/Module2974";
import * as _Module2975 from "../../../_bundle/Module2975";
import * as _Module2976 from "../../../_bundle/Module2976";
import * as _Module2977 from "../../../_bundle/Module2977";
import * as _Module2978 from "../../../_bundle/Module2978";
import * as _Module2979 from "../../../_bundle/Module2979";
import * as _Module2980 from "../../../_bundle/Module2980";
import * as _Module2981 from "../../../_bundle/Module2981";
import * as _Module2982 from "../../../_bundle/Module2982";
import * as _Module2983 from "../../../_bundle/Module2983";
import * as _Module2984 from "../../../_bundle/Module2984";
import * as _Module2985 from "../../../_bundle/Module2985";
import * as _Module2986 from "../../../_bundle/Module2986";
import * as _Module2987 from "../../../_bundle/Module2987";
import * as _Module2988 from "../../../_bundle/Module2988";
import * as _Module2989 from "../../../_bundle/Module2989";
import * as _Module2990 from "../../../_bundle/Module2990";
import * as _Module2991 from "../../../_bundle/Module2991";
import * as _Module2992 from "../../../_bundle/Module2992";
import * as _Module2993 from "../../../_bundle/Module2993";
import * as _Module2994 from "../../../_bundle/Module2994";
import * as _Module2995 from "../../../_bundle/Module2995";
import * as _Module2996 from "../../../_bundle/Module2996";
import * as _Module2997 from "../../../_bundle/Module2997";
import * as _Module2998 from "../../../_bundle/Module2998";
import * as _Module2999 from "../../../_bundle/Module2999";
import * as _Module3000 from "../../../_bundle/Module3000";
import { createLoader, makeMessagesProxy } from "../../../_bundle/Module1274";
const loader = createLoader({
bg: () => loadJsonAsset(_Module2970).then((result) => ({
default: result
})),
cs: () => loadJsonAsset(_Module2971).then((result) => ({
default: result
})),
da: () => loadJsonAsset(_Module2972).then((result) => ({
default: result
})),
de: () => loadJsonAsset(_Module2973).then((result) => ({
default: result
})),
el: () => loadJsonAsset(_Module2974).then((result) => ({
default: result
})),
"en-GB": () => loadJsonAsset(_Module2975).then((result) => ({
default: result
})),
"es-419": () => loadJsonAsset(_Module2976).then((result) => ({
default: result
})),
"es-ES": () => loadJsonAsset(_Module2977).then((result) => ({
default: result
})),
fi: () => loadJsonAsset(_Module2978).then((result) => ({
default: result
})),
fr: () => loadJsonAsset(_Module2979).then((result) => ({
default: result
})),
hi: () => loadJsonAsset(_Module2980).then((result) => ({
default: result
})),
hr: () => loadJsonAsset(_Module2981).then((result) => ({
default: result
})),
hu: () => loadJsonAsset(_Module2982).then((result) => ({
default: result
})),
it: () => loadJsonAsset(_Module2983).then((result) => ({
default: result
})),
ja: () => loadJsonAsset(_Module2984).then((result) => ({
default: result
})),
ko: () => loadJsonAsset(_Module2985).then((result) => ({
default: result
})),
lt: () => loadJsonAsset(_Module2986).then((result) => ({
default: result
})),
nl: () => loadJsonAsset(_Module2987).then((result) => ({
default: result
})),
no: () => loadJsonAsset(_Module2988).then((result) => ({
default: result
})),
pl: () => loadJsonAsset(_Module2989).then((result) => ({
default: result
})),
"pt-BR": () => loadJsonAsset(_Module2990).then((result) => ({
default: result
})),
ro: () => loadJsonAsset(_Module2991).then((result) => ({
default: result
})),
ru: () => loadJsonAsset(_Module2992).then((result) => ({
default: result
})),
"sv-SE": () => loadJsonAsset(_Module2993).then((result) => ({
default: result
})),
th: () => loadJsonAsset(_Module2994).then((result) => ({
default: result
})),
tr: () => loadJsonAsset(_Module2995).then((result) => ({
default: result
})),
uk: () => loadJsonAsset(_Module2996).then((result) => ({
default: result
})),
vi: () => loadJsonAsset(_Module2997).then((result) => ({
default: result
})),
"zh-CN": () => loadJsonAsset(_Module2998).then((result) => ({
default: result
})),
"zh-TW": () => loadJsonAsset(_Module2999).then((result) => ({
default: result
})),
"en-US": () => loadJsonAsset(_Module3000).then((result) => ({
default: result
}))
}, "en-US");
const r51 = makeMessagesProxy(loader);
export default r51;
export { loader as messagesLoader };
@@ -0,0 +1,44 @@
// Metro module 15127 (f15128).
import { useState, useCallback } from "react";
import { MAX_FAVORITE_CATEGORY_NAME_LENGTH } from "../FavoritesConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import * as _FavoritesUtils from "../FavoritesUtils";
import { addFavoriteCategory } from "../FavoritesActionCreators";
import ActionSheetActionCreators, { showActionSheet } from "../../action_sheet/native/ActionSheetActionCreators";
import { BottomSheet } from "../../../design/components/Sheet/native/BottomSheet.native";
import { BottomSheetTitleHeader } from "../../../design/components/Sheet/native/BottomSheetTitleHeader.native";
import { intl, t } from "../../../intl/index.native";
import { TextInput } from "../../../design/components/TextInput/native/TextInput.native";
import { Button } from "../../../design/components/Button/native/Button.native";
let key, useStyles;
const AddFavoriteCategoryActionSheet = function AddFavoriteCategoryActionSheet() {
const styles = useStyles();
const [state, onChange] = useState("");
const isFavoritesGuildCategoryNameValid = _FavoritesUtils.isFavoritesGuildCategoryNameValid(state);
const callback = useCallback(() => {
if (isFavoritesGuildCategoryNameValid) {
addFavoriteCategory(state, "modal");
ActionSheetActionCreators.hideActionSheet(key);
}
}, [isFavoritesGuildCategoryNameValid, state]);
return <BottomSheet contentStyles={styles.content} bodyStyles={styles.body} keyboardShouldPersistTaps="always" header={<BottomSheetTitleHeader title={intl.string(t["ISN+NM"])} />}>
<TextInput label={intl.string(t.OCAkGP)} placeholder={intl.string(t.eTVbtx)} value={state} onChange={onChange} maxLength={MAX_FAVORITE_CATEGORY_NAME_LENGTH} autoFocus isClearable returnKeyType="done" onSubmitEditing={callback} />
<Button text={intl.string(t.CumH4u)} onPress={callback} disabled={!isFavoritesGuildCategoryNameValid} />
</BottomSheet>;
};
key = "AddFavoriteCategoryActionSheet";
useStyles = createStyles({
content: {
paddingHorizontal: Module712.space.PX_16
},
body: {
gap: Module712.space.PX_16
}
});
export function openAddFavoriteCategoryActionSheet() {
showActionSheet({
content: <AddFavoriteCategoryActionSheet />,
key
});
}
@@ -0,0 +1,91 @@
// Metro module 11881 (f11882).
import { useEffect, useState, useCallback, useMemo } from "react";
import { View } from "react-native";
import { MAX_FAVORITES_ADD_CHANNEL_COUNT } from "../FavoritesConstants";
import { UserRowModes } from "../../main_tabs_v2/native/shared_components/user_list/UserRowConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { useFavoriteAdded } from "../FavoritesHooks";
import useFavoritesGuildChannelFilter from "../hooks/useFavoritesGuildChannelFilter";
import { trackFavoritesGuildAddModalOpened } from "../FavoritesAnalytics";
import { getOrResolveChannelIdFromDestinationId } from "../../share/formatResults";
import { isNotNullish } from "../../../utils/GlobalUtils";
import { addFavoriteChannels } from "../FavoritesActionCreators";
import useWindowDimensions_native from "../../screen/useWindowDimensions.native";
import { isAndroid } from "../../../utils/PlatformUtils";
import SearchableDestinationListHeader from "../../share/native/SearchableDestinationListHeader";
import { intl } from "../../../intl/index.native";
import FavoritesGuild_messages from "../intl/FavoritesGuild.messages";
import ThemedGradient from "../../client_themes/native/ThemedGradient";
import SearchableDestinationList from "../../share/native/SearchableDestinationList";
import { ModalFloatingAction } from "../../../design/components/Modal/native/ModalFloatingAction.native";
import { getFavoritesAddButtonLabel } from "../utils/getFavoritesAddButtonLabel";
import showSearchableDestinationListModal from "../../share/native/showSearchableDestinationListModal";
import ModalActionCreators from "../../../actions/ModalActionCreators";
let useStyles, c8147_12, closeAddFavoriteChannelModal;
const AddFavoriteChannelModal = function AddFavoriteChannelModal(props) {
let state, setState, height;
const { parentId, source } = props;
state = void 0;
setState = void 0;
height = void 0;
const styles = useStyles();
const notifyFavoriteAdded = useFavoriteAdded().notifyFavoriteAdded;
const favoritesGuildChannelFilter = useFavoritesGuildChannelFilter();
useEffect(() => {
trackFavoritesGuildAddModalOpened(source);
}, [source]);
[state, setState] = useState([]);
const length = state.length;
const callback2 = useCallback((a0) => {
setState(a0);
}, []);
const callback = useCallback(async () => {
let c27203_0, c27203_2;
c27203_2 = void 0;
let c30472_0 = (await Promise.all(state.map(getOrResolveChannelIdFromDestinationId))).filter(isNotNullish);
if (c30472_0.length > 0) {
(0, notifyFavoriteAdded)();
c27203_0 = parentId;
if (parentId == null) {
c27203_0 = null;
}
addFavoriteChannels(c30472_0, c27203_0, "modal");
}
(0, closeAddFavoriteChannelModal)();
}, [notifyFavoriteAdded, parentId, state]);
height = useWindowDimensions_native({
ignoreKeyboard: true
}).height;
return <View style={useMemo(() => ({
height: isAndroid() ? height : "100%"
}), [height])}>
<SearchableDestinationListHeader title={intl.string(FavoritesGuild_messages.Rp35U1)} onClose={closeAddFavoriteChannelModal} />
<View style={styles.container}>
<ThemedGradient absolute />
<SearchableDestinationList rowMode={UserRowModes.TOGGLE} initialSelectedDestinations={[]} onSelectedDestinationChange={callback2} channelFilter={favoritesGuildChannelFilter} insetEnd={0} disableGradient disableStickySections disableSelection={length >= MAX_FAVORITES_ADD_CHANNEL_COUNT} />
<ModalFloatingAction isVisible={length > 0} floatingBackgroundColor={styles.container.backgroundColor} text={getFavoritesAddButtonLabel(length)} onPress={callback} />
</View>
</View>;
};
closeAddFavoriteChannelModal = function closeAddFavoriteChannelModal() {
ModalActionCreators.popWithKey(c8147_12);
};
useStyles = createStyles({
container: {
flex: 1,
display: "flex",
backgroundColor: Module712.colors.MOBILE_ACTIONSHEET_BACKGROUND
}
});
c8147_12 = "add-favorite-channel-modal";
export const ADD_FAVORITE_CHANNEL_MODAL_KEY = "add-favorite-channel-modal";
export function openAddFavoriteChannelModal({ parentId: parentId2, source: source2 }) {
showSearchableDestinationListModal(Promise.resolve({
default: AddFavoriteChannelModal
}), {
parentId: parentId2,
source: source2
}, c8147_12);
}
export { closeAddFavoriteChannelModal };
@@ -0,0 +1,37 @@
// Metro module 15121 (f15122).
import useFavoritesGuildHideAction from "../hooks/useFavoritesGuildHideAction";
import useFavoritesGuildResetAction from "../hooks/useFavoritesGuildResetAction";
import { ActionSheet } from "../../../design/components/Sheet/native/ActionSheet.native";
import { BottomSheetTitleHeader } from "../../../design/components/Sheet/native/BottomSheetTitleHeader.native";
import { intl, t } from "../../../intl/index.native";
import { ActionSheetRow } from "../../../design/components/Sheet/native/ActionSheetRow.native";
import { XSmallIcon } from "../../../design/components/Icon/native/redesign/generated/XSmallIcon";
import { EyeSlashIcon } from "../../../design/components/Icon/native/redesign/generated/EyeSlashIcon";
import ActionSheetActionCreators, { showActionSheet } from "../../action_sheet/native/ActionSheetActionCreators";
import { TrashIcon } from "../../../design/components/Icon/native/redesign/generated/TrashIcon";
let key;
const FavoritesGuildActionSheet = function FavoritesGuildActionSheet() {
const favoritesGuildHideAction = useFavoritesGuildHideAction();
let c21694_0 = favoritesGuildHideAction;
const favoritesGuildResetAction = useFavoritesGuildResetAction();
let c21694_1 = favoritesGuildResetAction;
return <ActionSheet header={<BottomSheetTitleHeader title={intl.string(t.wMWyci)} />}>
<ActionSheetRow.Group hasIcons>
<ActionSheetRow label={favoritesGuildHideAction.label} subLabel={favoritesGuildHideAction.subLabel} icon={<ActionSheetRow.Icon IconComponent={favoritesGuildHideAction.isPreview ? XSmallIcon : EyeSlashIcon} />} variant={favoritesGuildHideAction.isPreview ? "default" : "danger"} onPress={() => {
ActionSheetActionCreators.hideActionSheet(key);
c21694_0.perform();
}} />
{favoritesGuildResetAction.isAvailable ? <ActionSheetRow label={favoritesGuildResetAction.label} subLabel={favoritesGuildResetAction.subLabel} icon={<ActionSheetRow.Icon IconComponent={TrashIcon} />} variant="danger" onPress={() => {
ActionSheetActionCreators.hideActionSheet(key);
c21694_1.perform();
}} /> : null}
</ActionSheetRow.Group>
</ActionSheet>;
};
key = "FavoritesGuildActionSheet";
export function openFavoritesGuildActionSheet() {
showActionSheet({
content: <FavoritesGuildActionSheet />,
key
});
}
@@ -0,0 +1,39 @@
// Metro module 15126 (f15127).
import ActionSheetActionCreators, { showActionSheet } from "../../action_sheet/native/ActionSheetActionCreators";
import { openAddFavoriteChannelModal } from "./AddFavoriteChannelModal";
import { openAddFavoriteCategoryActionSheet } from "./AddFavoriteCategoryActionSheet";
import { ActionSheet } from "../../../design/components/Sheet/native/ActionSheet.native";
import { BottomSheetTitleHeader } from "../../../design/components/Sheet/native/BottomSheetTitleHeader.native";
import { intl, t } from "../../../intl/index.native";
import { ActionSheetRow } from "../../../design/components/Sheet/native/ActionSheetRow.native";
import FavoritesGuild_messages from "../intl/FavoritesGuild.messages";
import { StarOutlineIcon } from "../../../design/components/Icon/native/redesign/generated/StarOutlineIcon";
import { FolderPlusIcon } from "../../../design/components/Icon/native/redesign/generated/FolderPlusIcon";
let key, handleCreateCategory, FavoritesGuildAddActionSheet;
const handleAddToFavorites = function handleAddToFavorites() {
ActionSheetActionCreators.hideActionSheet(key);
openAddFavoriteChannelModal({
source: "favorites_header_add_button_context_menu"
});
};
handleCreateCategory = function handleCreateCategory() {
ActionSheetActionCreators.hideActionSheet(key);
openAddFavoriteCategoryActionSheet();
};
FavoritesGuildAddActionSheet = function FavoritesGuildAddActionSheet() {
return <ActionSheet header={<BottomSheetTitleHeader title={intl.string(t.wMWyci)} />}>
<ActionSheetRow.Group hasIcons>
<ActionSheetRow label={intl.string(FavoritesGuild_messages.G9fGlP)} icon={<ActionSheetRow.Icon IconComponent={StarOutlineIcon} />} onPress={handleAddToFavorites} />
</ActionSheetRow.Group>
<ActionSheetRow.Group hasIcons>
<ActionSheetRow label={intl.string(t["ISN+NM"])} icon={<ActionSheetRow.Icon IconComponent={FolderPlusIcon} />} onPress={handleCreateCategory} />
</ActionSheetRow.Group>
</ActionSheet>;
};
key = "FavoritesGuildAddActionSheet";
export function openFavoritesGuildAddActionSheet() {
showActionSheet({
content: <FavoritesGuildAddActionSheet />,
key
});
}
@@ -0,0 +1,15 @@
// Metro module 15124 (f15125).
import useFavoritesGuildHeaderAction from "../hooks/useFavoritesGuildHeaderAction";
import { IconButton } from "../../../design/components/Button/native/IconButton.native";
import Module5176 from "../../../_bundle/Module5176";
import Module11373 from "../../../_bundle/Module11373";
import { openFavoritesGuildAddActionSheet } from "./FavoritesGuildAddActionSheet";
export function FavoritesGuildHeaderActionButton() {
const favoritesGuildHeaderAction = useFavoritesGuildHeaderAction();
const { isPreview, label } = favoritesGuildHeaderAction;
let exitPreview = favoritesGuildHeaderAction.exitPreview;
if (!isPreview) {
exitPreview = openFavoritesGuildAddActionSheet;
}
return <IconButton variant="secondary" size="sm" icon={isPreview ? Module5176 : Module11373} onPress={exitPreview} accessibilityLabel={label} maxFontSizeMultiplier={1} />;
}
@@ -0,0 +1,20 @@
// Metro module 11880 (f11881).
import { useCallback } from "react";
import { ChannelTypes } from "../../../../Constants";
import { isFavoritesGuildId } from "../../FavoritesUtils";
import { intl } from "../../../../intl/index.native";
import FavoritesGuild_messages from "../../intl/FavoritesGuild.messages";
export default function useFavoritesGuildCategoryAddAction(a0) {
const callback = useCallback(async () => {
let c27202_0;
c27202_0 = void 0;
(0, (await import("../AddFavoriteChannelModal")).openAddFavoriteChannelModal)({
parentId: a0.id,
source: "favorites_add_to_category"
});
}, [a0.id]);
return isFavoritesGuildId(a0.getGuildId()) ? a0.type === ChannelTypes.GUILD_CATEGORY ? {
label: intl.string(FavoritesGuild_messages["1QJmIL"]),
perform: callback
} : null : null;
};
@@ -0,0 +1,25 @@
// Metro module 10372 (f10373).
import AuthenticationStore from "../../../../stores/AuthenticationStore";
import GuildMemberStore from "../../../../stores/GuildMemberStore";
import FavoriteStore from "../../FavoriteStore";
import { useFavoritesAccess, useIsFavoritesGuildSelected } from "../../FavoritesHooks";
import { canFavoriteChannelType } from "../../FavoritesUtils";
import { useStateFromStores } from "../../../../_bundle/Module589";
export default function useFavoritesGuildChannelActions(a0, a1) {
const favoritesAccess = useFavoritesAccess(a1);
const hasAccess = favoritesAccess.hasAccess;
let canFavoriteChannel = canFavoriteChannelType(a0, favoritesAccess.hasHigherPrivileges);
const stateFromStores = useStateFromStores([FavoriteStore], () => FavoriteStore.isFavorite(a0.id));
const isFavoritesGuildSelected = useIsFavoritesGuildSelected();
const stateFromStores2 = useStateFromStores([GuildMemberStore, AuthenticationStore], () => a0.guild_id == null || GuildMemberStore.isMember(a0.guild_id, AuthenticationStore.getId()));
if (canFavoriteChannel) {
canFavoriteChannel = stateFromStores2;
}
return {
hasFavoritesAccess: hasAccess,
canFavoriteChannel,
isChannelInFavorites: stateFromStores,
isFavoritesGuild: isFavoritesGuildSelected,
channelId: a0.id
};
};
@@ -0,0 +1,53 @@
// Metro module 10213 (f10214).
import _slicedToArray from "../../../_bundle/_slicedToArray";
import ToastActionCreators from "../../toast/native/ToastActionCreators";
import { intl, t } from "../../../intl/index.native";
import { StarIcon } from "../../../design/components/Icon/native/redesign/generated/StarIcon";
import FavoritesGuild_messages from "../intl/FavoritesGuild.messages";
import { StarOutlineIcon } from "../../../design/components/Icon/native/redesign/generated/StarOutlineIcon";
let _removeChannelFromFavorites;
let _addChannelToFavorites = function _addChannelToFavorites() {
const r8 = async (c26635_0) => {
let c26635_2;
c26635_2 = void 0;
let c30205_0 = c26635_0;
ToastActionCreators.open({
key: "FAVORITE_ADDED",
content: intl.string(t["4tSWQg"]),
IconComponent: StarIcon
});
let c30205_1 = await Promise.all([import("../FavoritesActionCreators"), import("../hooks/useIsFavoritesGuildEnabled")]);
let c30205_2 = (0, _slicedToArray)(c30205_1, 2);
let c30205_3 = c30205_2[0];
if (!(0, c30205_2[1].getIsFavoritesGuildEnabled)()) {
c30205_3.setFavoritesGuildVisibility(true, "channel_context_menu");
}
c30205_3.addFavoriteChannel(c30205_0, null, "channel_context_menu");
};
_addChannelToFavorites = r8;
return r8.apply(this, arguments);
};
_removeChannelFromFavorites = function _removeChannelFromFavorites() {
const r8 = async (c26636_0) => {
let c30206_0 = c26636_0;
(await import("../FavoritesActionCreators")).removeFavoriteChannel(c30206_0);
};
_removeChannelFromFavorites = r8;
return r8.apply(this, arguments);
};
export default function buildFavoritesSectionButtons({ hasFavoritesAccess, canFavoriteChannel, isChannelInFavorites, isFavoritesGuild, channelId }) {
return hasFavoritesAccess ? canFavoriteChannel ? isChannelInFavorites ? {
label: intl.string(FavoritesGuild_messages.TN4nAX),
IconComponent: StarIcon,
isDestructive: true,
onPress: () => (function removeChannelFromFavorites() {
return _removeChannelFromFavorites.apply(this, arguments);
})(channelId)
} : isFavoritesGuild ? null : {
label: intl.string(FavoritesGuild_messages.G9fGlP),
IconComponent: StarOutlineIcon,
onPress: () => (function addChannelToFavorites() {
return _addChannelToFavorites.apply(this, arguments);
})(channelId)
} : null : null;
};
@@ -0,0 +1,15 @@
// Metro module 3816 (f3817).
import { ChannelTypes } from "../../../Constants";
export function createFavoritesGuildChannelRecord(a0, a1, a2) {
const constructor = new a2.constructor(a2.toJS());
constructor.position_ = a1.order;
if (a1.nickname != null && a2.type !== ChannelTypes.DM) {
constructor.name = a1.nickname;
}
if (a1.parentId != null && a1.parentId in a0) {
constructor.parent_id = a1.parentId;
} else if (constructor.parent_id === void 0) {
constructor.parent_id = null;
}
return constructor;
}
@@ -0,0 +1,8 @@
// Metro module 11883 (f11884).
import { intl } from "../../../intl/index.native";
import FavoritesGuild_messages from "../intl/FavoritesGuild.messages";
export function getFavoritesAddButtonLabel(a0) {
return a0 >= 2 ? intl.formatToPlainString(FavoritesGuild_messages.LbCa8x, {
count: a0
}) : intl.string(FavoritesGuild_messages.xKXcSu);
}