Files
discord-decomp/sources/modules/notifications/native/NotifSettingsUtils.android.tsx
T
2026-07-28 01:06:53 +03:00

455 lines
19 KiB
TypeScript

/* Metro module 13003; source: modules/notifications/native/NotifSettingsUtils.android.tsx; dependencies: [12999, 1244, 13004, 13005, 1216, 2] */
import SentryUtilsNative from '../../../utils/SentryUtils.native.tsx'; /* Metro dependency 1216 */
import * as FileImportTrackerModule from '../../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as IndexNativeModule from '../../../intl/index.native.tsx'; /* Metro dependency 1244 */
import * as NotificationSettingsConstantsModule from '../NotificationSettingsConstants.tsx'; /* Metro dependency 12999 */
import * as NotificationSettingsUtilsModule from '../NotificationSettingsUtils.tsx'; /* Metro dependency 13005 */
function _fun99177(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#99177, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13193:6, offset: 0x021be740, size: 317 bytes, params: 8, frame: 18
const env0_0 = require;
const _arrayLikeToArray_99180 = function(a0, a1) {
var r0;
var r1;
var r2;
var value3;
var length;
var value5;
var value = undefined;
var value2 = value == null;
reducibleJoin2: while (true) {
if (value2) {
r0 = value2;
break reducibleJoin2;
}
value3 = value > a0.length;
r0 = value3;
break reducibleJoin2;
}
reducibleJoin4: while (true) {
if (r0) {
length = a0.length;
r1 = length;
break reducibleJoin4;
}
r1 = value;
break reducibleJoin4;
}
value = (0, global.Array)(r1);
var value4 = 0;
if (value4 < r1) {
r2 = value4;
reducibleLoop5: while (true) {
value[r2] = a0[r2];
value5 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
if (value5 < r1) {
r2 = value5;
continue reducibleLoop5;
}
break reducibleLoop5;
}
}
return value;
};
const formatCategory = function(a0) {
var object = {id: a0.string_id};
object.name = require(dependencyMap[1]).intl.string(a0.title);
return object;
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
object = {NONE: 0};
object[0] = 'NONE';
object.MIN = 1;
object[1] = 'MIN';
object.LOW = 2;
object[2] = 'LOW';
object.DEFAULT = 3;
object[3] = 'DEFAULT';
object.HIGH = 4;
object[4] = 'HIGH';
object = {clear: clear_99186, registerDeclarativeNotificationCategories: registerDeclarativeNotificationCategories};
(FileImportTrackerModule).fileFinishedImporting('modules/notifications/native/NotifSettingsUtils.android.tsx');
exports.default = object;
function _createForOfIteratorHelperLoose_99178(a0, a1) { // fn#99178, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13193:177, offset: 0x021be87d, size: 372 bytes, params: 3, frame: 20
var r6;
var r9;
var r5;
var value3;
var regexp;
const env0_0 = a0;
const Symbol = global.Symbol;
let value = typeof Symbol !== 'undefined';
let r1 = value && a0[global.Symbol.iterator];
r1 = !r1 ? a0['@@iterator'] : r1;
if (r1) {
value = r1.call(a0);
return value.next.bind(value);
}
const Array = global.Array;
if (Array.isArray(a0)) {
if (r1) {
}
return _fun99179;
}
value = undefined;
if (a0) {
if (typeof a0 === 'string') {
value = _arrayLikeToArray_99180(a0, value);
r5 = value;
} else {
value3 = ({}).toString.call(a0).slice(8, -1);
r6 = value3 === 'Object' && a0.constructor;
r9 = r6 ? a0.constructor.name : value3;
if (r9 === 'Map') {
r6 = global.Array.from(a0);
} else if (r9 === 'Set') {
r6 = global.Array.from(a0);
} else if (r9 === 'Arguments') {
value = _arrayLikeToArray_99180(a0, value);
r6 = value;
} else {
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
if (regexp.test(r9)) {
value = _arrayLikeToArray_99180(a0, value);
r6 = value;
} else {
r6 = value;
}
}
r5 = r6;
}
} else {
r5 = value;
}
if (r5) {
if (r5) {
}
return _fun99179;
}
const TypeError = global.TypeError;
throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.');
function _fun99179() { // fn#99179, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13193:748, offset: 0x00c39d73, size: 69 bytes, params: 1, frame: 5
return env0_1 >= env0_0.length ? {done: true} : {done: false,
value: env0_0[typeof env0_1 === 'bigint' ? env0_1 : +env0_1]};
}
}
function inferImportanceFromBehavior(a0) { // fn#99181, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13193:1219, offset: 0x021be9f1, size: 118 bytes, params: 2, frame: 3
return 'ringtone' in a0 && a0.ringtone != null || a0.visibility === 'popup' ? env0_6.HIGH : a0.visibility === 'hidden' ? env0_6.MIN : a0.sound ? env0_6.DEFAULT : env0_6.LOW;
}
function formatSetting(a0, a1) { // fn#99183, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13193:1468, offset: 0x021beaa9, size: 175 bytes, params: 3, frame: 16
const value = a1;
const object = {};
object.id = a0.string_id;
object.groupId = a0.category;
const value3 = undefined;
const intl = (IndexNativeModule).intl;
object.name = intl.string(a0.title);
object.importance = value ?? inferImportanceFromBehavior(a0.behavior);
object.ringtone = 'ringtone' in a0.behavior ? a0.behavior.ringtone : value3;
object.badge = a0.behavior.badge;
object.vibrate = a0.behavior.vibrate;
return object;
}
function buildChannelsAndMapping() { // fn#99184, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13193:1744, offset: 0x021beb58, size: 783 bytes, params: 1, frame: 42
var getAndroidNotifChannelStates;
var r6;
var r13;
var r29;
var r4;
var value6;
var value7;
var value8;
var value9;
var done;
var value10;
var set;
var channelId;
var importance;
var value11;
var value12;
var value13;
var value14;
var value15;
var value16;
var id;
var value17;
var value18;
var value19;
var value20;
var notifType;
var notifSetting;
var property;
var value21;
var value22;
var value23;
var get;
var value24;
var string_id;
var value25;
var inferImportanceFromBehaviorBinding;
var behavior;
var value26;
var value27;
var value32;
var push;
var formatSettingBinding;
var value33;
const value2 = undefined;
const {settings,
mappings} = (NotificationSettingsUtilsModule).getAssignedNotifSettingsAndMappings();
let Map = global.Map;
let prototype = Map.prototype;
const value4 = Object.create(prototype, {constructor: {value: Map}});
let map = new Map();
const value5 = map instanceof Object ? map : value4;
reducibleJoin2: while (true) {
if ((importDefault(13004) /* metro dependency 13004: NativeNotifSettingsModule */) == null) {
getAndroidNotifChannelStates = value2;
break reducibleJoin2;
}
getAndroidNotifChannelStates = (importDefault(13004) /* metro dependency 13004: NativeNotifSettingsModule */).getAndroidNotifChannelStates;
break reducibleJoin2;
}
reducibleJoin17: while (true) {
if (getAndroidNotifChannelStates == null) {
break reducibleJoin17;
}
Map = global.Map;
prototype = Map.prototype;
value6 = Object.create(prototype, {constructor: {value: Map}});
map = new Map();
value7 = map instanceof Object ? map : value6;
value8 = _createForOfIteratorHelperLoose_99178(getAndroidNotifChannelStates());
value9 = value8();
done = value9.done;
if (!done) {
r6 = value9;
reducibleLoop4: while (true) {
value10 = r6.value;
set = value7.set;
channelId = value10.channelId;
importance = value10.importance;
Reflect.apply(set, value7, [channelId, importance]);
value11 = value8();
done = value11.done;
if (done) {
break reducibleLoop4;
}
r6 = value11;
continue reducibleLoop4;
}
}
Map = global.Map;
prototype = Map.prototype;
value12 = Object.create(prototype, {constructor: {value: Map}});
map = new Map();
value13 = map instanceof Object ? map : value12;
value14 = _createForOfIteratorHelperLoose_99178(NOTIF_SETTINGS);
value15 = value14();
done = value15.done;
if (!done) {
r6 = value15;
reducibleLoop6: while (true) {
value16 = r6.value;
set = value13.set;
id = value16.id;
Reflect.apply(set, value13, [id, value16]);
value17 = value14();
done = value17.done;
if (done) {
break reducibleLoop6;
}
r6 = value17;
continue reducibleLoop6;
}
}
value18 = _createForOfIteratorHelperLoose_99178(mappings);
value19 = value18();
done = value19.done;
if (done) {
break reducibleJoin17;
}
r13 = value19;
reducibleLoop8: while (true) {
value20 = r13.value;
notifType = value20.notifType;
notifSetting = value20.notifSetting;
property = NOTIF_SETTING_MAPPING[notifType];
reducibleJoin16: while (true) {
if (property == null) {
break reducibleJoin16;
}
value21 = _createForOfIteratorHelperLoose_99178(property);
value22 = value21();
done = value22.done;
if (done) {
break reducibleJoin16;
}
r29 = value22;
reducibleLoop10: while (true) {
value23 = r29.value;
if (value23 !== notifSetting) {
get = value13.get;
value24 = Reflect.apply(get, value13, [value23]);
reducibleJoin14: while (true) {
if (value24 == null) {
break reducibleJoin14;
}
get = value7.get;
string_id = value24.string_id;
value25 = Reflect.apply(get, value7, [string_id]);
if (value25 == null) {
break reducibleJoin14;
}
inferImportanceFromBehaviorBinding = inferImportanceFromBehavior;
behavior = value24.behavior;
if (value25 !== inferImportanceFromBehaviorBinding(behavior)) {
set = value5.set;
Reflect.apply(set, value5, [notifSetting, value25]);
break reducibleJoin16;
}
break reducibleJoin14;
}
}
value26 = value21();
done = value26.done;
if (done) {
break reducibleJoin16;
}
r29 = value26;
continue reducibleLoop10;
}
}
value27 = value18();
done = value27.done;
if (done) {
break reducibleJoin17;
}
r13 = value27;
continue reducibleLoop8;
}
}
const items2 = [];
Map = global.Map;
map = new Map();
const value30 = _createForOfIteratorHelperLoose_99178(settings);
const value31 = value30();
done = value31.done;
if (!done) {
r4 = value31;
reducibleLoop18: while (true) {
value32 = r4.value;
push = items2.push;
formatSettingBinding = formatSetting;
get = value5.get;
id = value32.id;
Reflect.apply(push, items2, [formatSettingBinding(value32, Reflect.apply(get, value5, [id]))]);
set = map.set;
id = value32.id;
string_id = value32.string_id;
Reflect.apply(set, map, [id, string_id]);
value33 = value30();
done = value33.done;
if (done) {
break reducibleLoop18;
}
r4 = value33;
continue reducibleLoop18;
}
}
const object = {};
object.mapping = mappings.flatMap(_fun99185);
object.channels = items2;
object.inheritedImportances = value5;
return object;
function _fun99185({notifType, notifSetting}) { // fn#99185, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13193:2747, offset: 0x021bee67, size: 56 bytes, params: 2, frame: 12
const value = env0_0.get(notifSetting);
return value == null ? [] : {type: notifType, channel: value};
}
}
function clear_99186() { // fn#99186, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13193:2883, offset: 0x021bee9f, size: 97 bytes, params: 1, frame: 15
const r2 = (importDefault(13004) /* metro dependency 13004: NativeNotifSettingsModule */) ?? ({});
const registerAndroidNotifGroupsAndChannels = r2.registerAndroidNotifGroupsAndChannels;
const registerAndroidNotifTypeMappings = r2.registerAndroidNotifTypeMappings;
if (registerAndroidNotifGroupsAndChannels != null) {
registerAndroidNotifGroupsAndChannels([], []);
}
if (registerAndroidNotifTypeMappings != null) {
registerAndroidNotifTypeMappings([]);
}
}
function registerDeclarativeNotificationCategories() { // fn#99187, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13193:3086, offset: 0x021bef00, size: 264 bytes, params: 1, frame: 24
let r1 = (importDefault(13004) /* metro dependency 13004: NativeNotifSettingsModule */) ?? ({});
const registerAndroidNotifGroupsAndChannels = r1.registerAndroidNotifGroupsAndChannels;
const registerAndroidNotifTypeMappings = r1.registerAndroidNotifTypeMappings;
if (registerAndroidNotifGroupsAndChannels == null) {
return false;
}
if (registerAndroidNotifTypeMappings == null) {
return false;
}
const {channels, mapping, inheritedImportances} = buildChannelsAndMapping();
const defaultImport3 = SentryUtilsNative;
const addBreadcrumb = defaultImport3.addBreadcrumb;
const object2 = {};
object2.channels = channels.map(function(a0) {
return a0.id;
});
const Array = global.Array;
object2.inheritedImportances = Array.from(inheritedImportances.entries()).map(function(a0) {
var r0;
var r1;
var r3;
var item3;
var value3;
var iterator = a0[Symbol.iterator]();
var iterator2 = iterator.next;
var item2 = Reflect.apply(iterator2, iterator, []);
var item = item2.value;
item2 = item2.done ? undefined : iterator;
var value = undefined;
var value2 = item2 === value;
var r4 = value2 ? value : item;
if (value2) {
r0 = item2;
r1 = value2;
r3 = value;
} else {
item3 = Reflect.apply(iterator2, item2, []);
item = item3.value;
item3 = item3.done ? undefined : item2;
value3 = item3 === value;
if (value3) {
r0 = item3;
r1 = value3;
r3 = value;
} else {
r0 = item3;
r1 = value3;
r3 = item;
}
}
if (!r1) {
r0.return();
}
return 'NotifSettings#' + r4 + ' -> ' + r3;
});
Reflect.apply(addBreadcrumb, defaultImport3, [{message: 'Registering declarative notification categories',
data: object2}]);
registerAndroidNotifGroupsAndChannels(NOTIF_CATEGORIES.map(formatCategory), channels);
registerAndroidNotifTypeMappings(mapping);
return true;
}
}
global.__d(_fun99177, 13003, [12999, 1244, 13004, 13005, 1216,
2]) /* metro module 13003, dependencies: [12999, 1244, 13004, 13005, 1216, 2] */;