203 lines
6.0 KiB
TypeScript
203 lines
6.0 KiB
TypeScript
// Metro module 13513 (f13514).
|
|
import { NOTIF_CATEGORIES, NOTIF_SETTINGS, NOTIF_SETTING_MAPPING } from "../NotificationSettingsConstants";
|
|
import { intl } from "../../../intl/index.native";
|
|
import Module13514 from "../../../_bundle/Module13514";
|
|
import { getAssignedNotifSettingsAndMappings } from "../NotificationSettingsUtils";
|
|
import SentryUtils_native from "../../../utils/SentryUtils.native";
|
|
let c9378_6, formatCategory, formatSetting, buildChannelsAndMapping;
|
|
const inferImportanceFromBehavior = function inferImportanceFromBehavior(behavior) {
|
|
let MIN;
|
|
L11: {
|
|
if (!("ringtone" in behavior && behavior.ringtone != null) && behavior.visibility !== "popup") {
|
|
if (behavior.visibility === "hidden") {
|
|
MIN = c9378_6.MIN;
|
|
break L11;
|
|
}
|
|
if (behavior.sound) {
|
|
MIN = c9378_6.DEFAULT;
|
|
break L11;
|
|
}
|
|
MIN = c9378_6.LOW;
|
|
} else {
|
|
MIN = c9378_6.HIGH;
|
|
}
|
|
}
|
|
return MIN;
|
|
};
|
|
formatCategory = function formatCategory(a0) {
|
|
return {
|
|
id: a0.string_id,
|
|
name: intl.string(a0.title)
|
|
};
|
|
};
|
|
formatSetting = function formatSetting(item, a1) {
|
|
let MIN;
|
|
let importance = a1;
|
|
const r3 = {
|
|
id: item.string_id,
|
|
groupId: item.category,
|
|
name: intl.string(item.title),
|
|
importance: null,
|
|
ringtone: null,
|
|
badge: null,
|
|
vibrate: null
|
|
};
|
|
if (a1 == null) {
|
|
L12: {
|
|
const behavior = item.behavior;
|
|
if (!("ringtone" in behavior && behavior.ringtone != null) && behavior.visibility !== "popup") {
|
|
if (behavior.visibility === "hidden") {
|
|
MIN = c9378_6.MIN;
|
|
break L12;
|
|
}
|
|
if (behavior.sound) {
|
|
MIN = c9378_6.DEFAULT;
|
|
break L12;
|
|
}
|
|
MIN = c9378_6.LOW;
|
|
} else {
|
|
MIN = c9378_6.HIGH;
|
|
}
|
|
}
|
|
importance = MIN;
|
|
}
|
|
r3.importance = importance;
|
|
r3.ringtone = "ringtone" in item.behavior ? item.behavior.ringtone : void 0;
|
|
r3.badge = item.behavior.badge;
|
|
r3.vibrate = item.behavior.vibrate;
|
|
return r3;
|
|
};
|
|
buildChannelsAndMapping = function buildChannelsAndMapping() {
|
|
let c20504_0;
|
|
const assignedNotifSettingsAndMappings = getAssignedNotifSettingsAndMappings();
|
|
const { settings, mappings } = assignedNotifSettingsAndMappings;
|
|
const inheritedImportances = (function computeInheritedImportances(a0) {
|
|
let r30;
|
|
const map = new Map();
|
|
const getAndroidNotifChannelStates = Module13514?.getAndroidNotifChannelStates;
|
|
if (getAndroidNotifChannelStates == null) {
|
|
return map;
|
|
}
|
|
const map2 = new Map();
|
|
let r46 = getAndroidNotifChannelStates()[Symbol.iterator]();
|
|
const next = r46.next;
|
|
while (true) {
|
|
const r49 = r46 === void 0 ? void 0 : (r30 = next.call(r46)).done ? r46 = void 0 : r30.value;
|
|
if (r46 === void 0) {
|
|
const map3 = new Map();
|
|
for (const item2 of NOTIF_SETTINGS) {
|
|
map3.set(item2.id, item2);
|
|
}
|
|
loop12: for (const r76 of a0) {
|
|
const { notifType, notifSetting } = r76;
|
|
const r81 = NOTIF_SETTING_MAPPING[notifType];
|
|
if (r81 != null) {
|
|
for (const item of r81) {
|
|
if (item === notifSetting) {
|
|
continue;
|
|
}
|
|
const r92 = map3.get(item);
|
|
if (r92 == null) {
|
|
continue;
|
|
}
|
|
const r97 = map2.get(r92.string_id);
|
|
if (r97 == null) {
|
|
continue;
|
|
}
|
|
if (r97 === inferImportanceFromBehavior(r92.behavior)) {
|
|
continue;
|
|
}
|
|
map.set(notifSetting, r97);
|
|
continue loop12;
|
|
}
|
|
}
|
|
}
|
|
return map;
|
|
} else {
|
|
try {
|
|
map2.set(r49.channelId, r49.importance);
|
|
} catch (r53) {
|
|
if (r46 !== void 0 && typeof r46.return === "function") {
|
|
try {
|
|
r46.return();
|
|
} catch {}
|
|
}
|
|
throw r53;
|
|
}
|
|
}
|
|
}
|
|
})(mappings);
|
|
const channels = [];
|
|
const map = new Map();
|
|
c20504_0 = map;
|
|
for (const item of settings) {
|
|
channels.push(formatSetting(item, inheritedImportances.get(item.id)));
|
|
map.set(item.id, item.string_id);
|
|
}
|
|
return {
|
|
mapping: mappings.flatMap((mapping) => {
|
|
const notifType = mapping.notifType;
|
|
const channel = c20504_0.get(mapping.notifSetting);
|
|
return channel == null ? [] : {
|
|
type: notifType,
|
|
channel
|
|
};
|
|
}),
|
|
channels,
|
|
inheritedImportances
|
|
};
|
|
};
|
|
c9378_6 = {
|
|
NONE: 0,
|
|
0: "NONE",
|
|
MIN: 1,
|
|
1: "MIN",
|
|
LOW: 2,
|
|
2: "LOW",
|
|
DEFAULT: 3,
|
|
3: "DEFAULT",
|
|
HIGH: 4,
|
|
4: "HIGH"
|
|
};
|
|
const r34 = {
|
|
clear: function clear() {
|
|
let r8 = Module13514;
|
|
if (r8 == null) {
|
|
r8 = {};
|
|
}
|
|
const { registerAndroidNotifGroupsAndChannels, registerAndroidNotifTypeMappings } = r8;
|
|
if (registerAndroidNotifGroupsAndChannels != null) {
|
|
registerAndroidNotifGroupsAndChannels([], []);
|
|
}
|
|
if (registerAndroidNotifTypeMappings != null) {
|
|
registerAndroidNotifTypeMappings([]);
|
|
}
|
|
},
|
|
registerDeclarativeNotificationCategories: function registerDeclarativeNotificationCategories() {
|
|
let r16 = Module13514;
|
|
if (r16 == null) {
|
|
r16 = {};
|
|
}
|
|
const { registerAndroidNotifGroupsAndChannels, registerAndroidNotifTypeMappings } = r16;
|
|
if (registerAndroidNotifGroupsAndChannels != null && registerAndroidNotifTypeMappings != null) {
|
|
const r10 = buildChannelsAndMapping();
|
|
const { channels, mapping, inheritedImportances } = r10;
|
|
SentryUtils_native.addBreadcrumb({
|
|
message: "Registering declarative notification categories",
|
|
data: {
|
|
channels: channels.map((channel) => channel.id),
|
|
inheritedImportances: Array.from(inheritedImportances.entries()).map((item) => {
|
|
const [r7, r24] = item;
|
|
return `NotifSettings#${r7} -> ${r24}`;
|
|
})
|
|
}
|
|
});
|
|
registerAndroidNotifGroupsAndChannels(NOTIF_CATEGORIES.map(formatCategory), channels);
|
|
registerAndroidNotifTypeMappings(mapping);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
};
|
|
export default r34;
|