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,10 @@
// Metro module 10460 (f10461).
import useTrackImpression from "../../app_analytics/useTrackImpression";
import { ImpressionTypes, ImpressionNames } from "../../../_bundle/Module503";
export default function UnreadSettingNoticeImpressionTracking(a0) {
useTrackImpression({
type: ImpressionTypes.VIEW,
name: ImpressionNames.NOTIFICATION_SETTING_UNREAD_NUDGE
}, void 0, [a0.id]);
return null;
};
@@ -0,0 +1,271 @@
// Metro module 10456 (f10457).
import AuthenticationStore from "../../../stores/AuthenticationStore";
import ChannelStore from "../../../stores/ChannelStore";
import GuildStore from "../../../stores/GuildStore";
import SelectedChannelStore from "../../../stores/SelectedChannelStore";
import UserGuildSettingsStore from "../../../stores/UserGuildSettingsStore";
import { UserNotificationSettings } from "../../../Constants";
import { UnreadSetting } from "../../read_states/ReadStateConstants";
import { ChannelNotificationSettingsFlags } from "../../user_settings/UserSettingsConstants";
import Durations from "../../../utils/Durations";
import SnowflakeUtils from "../../../utils/SnowflakeUtils";
import { hasAnyFlag } from "../../../_bundle/Module1384";
import Module589 from "../../../_bundle/Module589";
import { updateChannelUnreadSetting } from "../settings/utils/notficationSettingsChannelFlagUtils";
import Dispatcher from "../../../Dispatcher";
let c7004_11, c7004_12, WEEK, c7004_14, c7004_15, channelId, c7004_17, c7004_18, shouldTrackChannel, c7004_21, $mk84699 = function() {
return () => {
let r11;
L7: {
const r2 = channelId == null;
r11 = false;
if (!r2) {
const shouldTrackChannel2 = shouldTrackChannel(channelId);
r11 = false;
if (shouldTrackChannel2) {
if (!(channelId in c7004_14.channels)) {
c7004_14.channels[channelId] = {
lastActionTime: 0,
viewDuration: 0,
numSends: 0
};
}
const r19 = c7004_14.channels[channelId];
if (r19.lastActionTime > Date.now() - Durations.Millis.DAY) {
const r33 = r19.viewDuration > c7004_12;
r11 = false;
if (r33) {
break L7;
}
}
const lastActionTime = Date.now();
r19.lastActionTime = lastActionTime;
r19.viewDuration = r19.viewDuration + (lastActionTime - c7004_17);
c7004_17 = lastActionTime;
r11 = true;
}
}
}
if (r11) {
c7004_21.emitChange();
}
};
};
const startInterval = function startInterval() {
if (c7004_18 !== 0) {
clearInterval(c7004_18);
c7004_18 = 0;
}
if (UserGuildSettingsStore.useNewNotifications) {
const r12 = setInterval;
const r20 = 15 * Durations.Millis.SECOND;
c7004_18 = r12($mk84699(), r20);
}
return false;
};
shouldTrackChannel = function shouldTrackChannel(channelId) {
if (UserGuildSettingsStore.useNewNotifications) {
if (c7004_15.has(channelId)) {
return false;
}
const basicChannel = ChannelStore.getBasicChannel(channelId);
if (basicChannel != null && basicChannel.guild_id != null) {
if (UserGuildSettingsStore.isGuildOrCategoryOrChannelMuted(basicChannel.guild_id, basicChannel.id)) {
return false;
}
const { guild_id, id } = basicChannel;
const r2 = id == null;
let r1 = false;
if (!r2) {
const r29 = UserGuildSettingsStore.getChannelOverrides(guild_id)[id];
r1 = r29 != null && (r29.message_notifications != null && r29.message_notifications !== UserNotificationSettings.NULL || !(r29.flags == null || !hasAnyFlag(r29.flags, ChannelNotificationSettingsFlags.UNREADS_ALL_MESSAGES | ChannelNotificationSettingsFlags.UNREADS_ONLY_MENTIONS)));
}
if (r1) {
return false;
}
const { guild_id: guild_id2, parent_id } = basicChannel;
const r47 = parent_id == null;
let r48 = false;
if (!r47) {
const r51 = UserGuildSettingsStore.getChannelOverrides(guild_id2)[parent_id];
r48 = r51 != null && (r51.message_notifications != null && r51.message_notifications !== UserNotificationSettings.NULL || !(r51.flags == null || !hasAnyFlag(r51.flags, ChannelNotificationSettingsFlags.UNREADS_ALL_MESSAGES | ChannelNotificationSettingsFlags.UNREADS_ONLY_MENTIONS)));
}
if (r48) {
return false;
}
const r73 = UserGuildSettingsStore.resolveUnreadSetting(basicChannel);
return UserGuildSettingsStore.getChannelUnreadSetting(basicChannel.guild_id, basicChannel.id) === UnreadSetting.UNSET && r73 !== UnreadSetting.ALL_MESSAGES;
}
return false;
}
return false;
};
c7004_11 = [{
timeSinceJoin: 1 * Durations.Millis.HOUR,
sends: 1,
viewTime: 1 * Durations.Millis.MINUTE
}, {
timeSinceJoin: 1 * Durations.Millis.DAY,
sends: 2,
viewTime: 2 * Durations.Millis.MINUTE
}, {
timeSinceJoin: 1 * Durations.Millis.WEEK,
sends: 5,
viewTime: 5 * Durations.Millis.MINUTE
}, {
timeSinceJoin: 1 * Durations.Millis.DAYS_30,
sends: 10,
viewTime: 30 * Durations.Millis.MINUTE
}];
c7004_12 = 5 * c7004_11[c7004_11.length - 1].viewTime;
WEEK = Durations.Millis.WEEK;
c7004_14 = {
channels: {}
};
c7004_15 = new Set();
channelId = null;
c7004_17 = 0;
c7004_18 = 0;
class UnreadSettingNoticeStore2Class extends Module589.PersistedStore {
static displayName = "UnreadSettingNoticeStore2";
static persistKey = "UnreadSettingNoticeStore2";
initialize(a0) {
if (a0 != null) {
c7004_14.channels = a0.channels;
}
this.syncWith([UserGuildSettingsStore], startInterval);
this.waitFor(AuthenticationStore, ChannelStore, GuildStore, SelectedChannelStore, UserGuildSettingsStore);
}
getState() {
return c7004_14;
}
getLastActionTime(a0) {
let r8 = c7004_14.channels[a0]?.lastActionTime;
if (r8 == null) {
r8 = 0;
}
return r8;
}
maybeAutoUpgradeChannel(a0) {
if (shouldTrackChannel(a0)) {
const basicChannel = ChannelStore.getBasicChannel(a0);
let r12 = basicChannel != null && basicChannel.guild_id != null;
if (r12) {
let r17 = !!(function isChannelNewEnough(a0) {
let r8 = GuildStore.getGuild(a0.guild_id)?.joinedAt;
if (r8 == null) {
r8 = new Date();
}
const r43 = Math.min(SnowflakeUtils.age(a0.id), Date.now() - r8.getTime());
const r47 = c7004_14.channels[a0.id];
if (r47 == null) {
return false;
}
if (r47.lastActionTime < Date.now() - WEEK) {
return false;
}
for (const item of c7004_11) {
if (!(r43 < item.timeSinceJoin)) {
continue;
}
if (!(r47.numSends >= item.sends) && !(r47.viewDuration >= item.viewTime)) {
continue;
}
return true;
}
return false;
})(basicChannel);
if (r17) {
delete c7004_14.channels[a0];
c7004_15.add(a0);
updateChannelUnreadSetting(basicChannel.guild_id, basicChannel.id, UnreadSetting.ALL_MESSAGES);
r17 = true;
}
r12 = r17;
}
return r12;
}
return false;
}
}
c7004_21 = new UnreadSettingNoticeStore2Class(Dispatcher, {
CHANNEL_SELECT: function handleChannelSelect() {
let r11;
L7: {
const r2 = channelId == null;
r11 = false;
if (!r2) {
const shouldTrackChannel2 = shouldTrackChannel(channelId);
r11 = false;
if (shouldTrackChannel2) {
if (!(channelId in c7004_14.channels)) {
c7004_14.channels[channelId] = {
lastActionTime: 0,
viewDuration: 0,
numSends: 0
};
}
const r19 = c7004_14.channels[channelId];
if (r19.lastActionTime > Date.now() - Durations.Millis.DAY) {
const r33 = r19.viewDuration > c7004_12;
r11 = false;
if (r33) {
break L7;
}
}
const lastActionTime = Date.now();
r19.lastActionTime = lastActionTime;
r19.viewDuration = r19.viewDuration + (lastActionTime - c7004_17);
c7004_17 = lastActionTime;
r11 = true;
}
}
}
channelId = SelectedChannelStore.getChannelId();
c7004_17 = Date.now();
return r11;
},
CONNECTION_OPEN: function handleConnectionOpen() {
channelId = SelectedChannelStore.getChannelId();
c7004_17 = Date.now();
if (c7004_18 !== 0) {
clearInterval(c7004_18);
c7004_18 = 0;
}
if (UserGuildSettingsStore.useNewNotifications) {
const r17 = setInterval;
const r25 = 15 * Durations.Millis.SECOND;
c7004_18 = r17($mk84699(), r25);
}
let c17968_0 = Date.now() - WEEK;
SnowflakeUtils.forEach(c7004_14.channels, (a0, a1) => {
if (a0.lastActionTime < c17968_0) {
delete c7004_14.channels[a1];
}
});
},
MESSAGE_CREATE: function handleMessageCreate(a0) {
if (!a0.optimistic && !a0.isPushNotification) {
if (a0.message.author?.id !== AuthenticationStore.getId()) {
return false;
}
if (shouldTrackChannel(a0.channelId)) {
const channelId2 = a0.channelId;
if (!(channelId2 in c7004_14.channels)) {
c7004_14.channels[channelId2] = {
lastActionTime: 0,
viewDuration: 0,
numSends: 0
};
}
const r25 = c7004_14.channels[channelId2];
r25.lastActionTime = Date.now();
r25.numSends = r25.numSends + 1;
return void 0;
}
return false;
}
return false;
}
});
export default c7004_21;
@@ -0,0 +1,58 @@
// Metro module 10459 (f10460).
import { View } from "react-native";
import { ChannelNotificationSettingsFlags } from "../../../user_settings/UserSettingsConstants";
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../_bundle/Module712";
import UnreadSettingNoticeImpressionTracking from "../UnreadSettingNoticeImpressionTracking";
import { Text } from "../../../../design/components/Text/native/Text";
import { intl, t } from "../../../../intl/index.native";
import { PressableOpacity } from "../../../../design/void/Pressables/native/Pressables";
import updateChannelUnreadSettings from "../utils/updateChannelUnreadSettings";
const useStyles = createStyles({
content: {
display: "flex",
flexDirection: "row",
paddingVertical: Module712.space.PX_12,
paddingHorizontal: Module712.space.PX_16,
borderBottomWidth: 1,
borderBottomColor: Module712.colors.BORDER_SUBTLE,
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW,
...Module712.shadows.SHADOW_LOW
},
informations: {
flex: 1
},
actions: {
display: "flex",
flexDirection: "row",
alignItems: "center",
marginLeft: 16
},
inlineTextWithIcon: {
display: "flex",
flexDirection: "row",
alignItems: "center"
}
});
export default function UnreadSettingNoticeConnected(props) {
let c17972_0 = props;
const styles = useStyles();
return <View style={styles.content}>
<UnreadSettingNoticeImpressionTracking id={props.channel.id} />
<View style={styles.informations}>
<Text variant="text-md/semibold">
{intl.string(t.i4xQ5o)}
</Text>
</View>
<View style={styles.actions}>
<PressableOpacity accessibilityRole="button" style={styles.inlineTextWithIcon} onPress={() => {
updateChannelUnreadSettings(c17972_0.channel.guild_id, c17972_0.channel.id, ChannelNotificationSettingsFlags.UNREADS_ONLY_MENTIONS);
c17972_0.clearUnreadsNotice();
}}>
<Text variant="text-xs/medium" color="text-link">
{intl.string(t.KyUKhT)}
</Text>
</PressableOpacity>
</View>
</View>;
};
@@ -0,0 +1,15 @@
// Metro module 10461 (f10462).
import UserGuildSettingsStore from "../../../../stores/UserGuildSettingsStore";
import { AnalyticsObjects } from "../../../../Constants";
import { UnreadSetting } from "../../../read_states/ReadStateConstants";
import { ChannelNotificationSettingsFlags } from "../../../user_settings/UserSettingsConstants";
import NotificationSettingsModalActionCreators from "../../../../actions/NotificationSettingsModalActionCreators";
import { withChannelUnreadFlags } from "../../settings/utils/notificationSettingsFlagUtils";
import { NotificationLabel } from "../../../../utils/NotificationSettingsUtils";
export default function updateChannelUnreadSettings(a0, a1, a2) {
NotificationSettingsModalActionCreators.updateChannelOverrideSettings(a0, a1, {
flags: withChannelUnreadFlags(UserGuildSettingsStore.getChannelIdFlags(a0, a1), a2)
}, NotificationLabel.unreads(a2 === ChannelNotificationSettingsFlags.UNREADS_ALL_MESSAGES ? UnreadSetting.ALL_MESSAGES : UnreadSetting.ONLY_MENTIONS), {
object: AnalyticsObjects.NOTIFICATION_SETTING_UNREAD_NOTICE
});
};
@@ -0,0 +1,22 @@
// Metro module 10455 (f10456).
import { useState, useEffect, useCallback } from "react";
import { CHANNEL_ELIGIBLE_FOR_UNREAD_SETTING } from "../../../../records/ChannelRecord";
import { useShouldUseNewNotificationSystem } from "../../NotificationUtils";
import { useStateFromStores } from "../../../../_bundle/Module589";
import UnreadSettingNoticeStore2 from "../UnreadSettingNoticeStore2";
export default function useUnreadSettingNotice(a0) {
const shouldUseNewNotificationSystem = useShouldUseNewNotificationSystem("useShouldRenderBanner");
const [state, setState] = useState("");
useEffect(() => {
setState("");
}, [a0.id]);
useEffect(() => {
if (CHANNEL_ELIGIBLE_FOR_UNREAD_SETTING.has(a0.type) && state !== a0.id && shouldUseNewNotificationSystem && UnreadSettingNoticeStore2.maybeAutoUpgradeChannel(a0.id)) {
setState(a0.id);
}
}, [state, shouldUseNewNotificationSystem, useStateFromStores([UnreadSettingNoticeStore2], () => UnreadSettingNoticeStore2.getLastActionTime(a0.id)), a0]);
return {
showUnreadsNotice: state === a0.id,
clearUnreadsNotice: useCallback(() => setState(""), [])
};
};