Files
discord-decomp/sources/lib/pushnotification/PushNotification.tsx
T
2026-07-27 16:20:00 +03:00

372 lines
19 KiB
TypeScript

/* Metro module 10741; source: lib/pushnotification/PushNotification.tsx; dependencies: [27, 477, 10742, 10743, 10744, 2] */
function _fun82510(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#82510, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:6, offset: 0x01ef9c1b, size: 497 bytes, params: 8, frame: 19
var object2;
var nativeEventEmitter;
let env0_0 = require;
const createNotification = function(a0) {
var env0_0 = a0;
var value = null;
return value == a0 ? value : {getData: _fun82512, getMessage: _fun82513, getSound: _fun82514,
getCategory: _fun82515, getAlert: _fun82516, getContentAvailable: _fun82517, getBadgeCount: _fun82518,
finish: _fun82519};
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const {NativeModules, NativeEventEmitter} = require(27) /* metro dependency 27 */;
const PushNotificationAndroid = NativeModules.PushNotificationAndroid;
if (PushNotificationAndroid != null) {
nativeEventEmitter = new NativeEventEmitter(NativeModules.PushNotificationAndroid);
}
object2 = {getInitialNotification: getInitialNotification, setCurrentUser: function(a0, a1) {
if (require(dependencyMap[1]).isAndroid()) {
PushNotificationAndroid.setCurrentUser(a0, a1);
}
}, setMultiAccountUsers: setMultiAccountUsers, clearPushNotificationLogs: function() {
if (require(dependencyMap[1]).isAndroid()) {
require(dependencyMap[3]).default.clearLogs();
}
}, setApplicationIconBadgeNumber: setApplicationIconBadgeNumber, clearAllNotifications: clearAllNotifications,
presentLocalNotification: presentLocalNotification, getDeliveredNotifications: getDeliveredNotifications,
removeDeliveredNotifications: removeDeliveredNotifications,
scheduleLocalNotification: scheduleLocalNotification,
getScheduledLocalNotifications: getScheduledLocalNotifications,
cancelLocalNotifications: cancelLocalNotifications, cancelAllLocalNotifications: cancelAllLocalNotifications,
checkPermissions: checkPermissions, requestPermissions: requestPermissions,
openNotificationSettings: function() {
importDefault(dependencyMap[4])();
}, addNotificationEventListener: addNotificationEventListener, addRegisterEventListener: addRegisterEventListener,
getSoundsEnabled: function() {
var Promise = global.Promise;
var value = Object.create(Promise.prototype, {constructor: {value: Promise}});
var value2 = new Promise(_fun82546);
return value2 instanceof Object ? value2 : value;
}, getVibrationsEnabled: function() {
var Promise = global.Promise;
var value = Object.create(Promise.prototype, {constructor: {value: Promise}});
var value2 = new Promise(_fun82549);
return value2 instanceof Object ? value2 : value;
}, getLightsEnabled: function() {
var Promise = global.Promise;
var value = Object.create(Promise.prototype, {constructor: {value: Promise}});
var value2 = new Promise(_fun82552);
return value2 instanceof Object ? value2 : value;
}, setSoundsEnabled: function(a0) {
if (require(dependencyMap[1]).isAndroid()) {
PushNotificationAndroid.setSoundsEnabled(a0);
}
}, setVibrationsEnabled: function(a0) {
if (require(dependencyMap[1]).isAndroid()) {
PushNotificationAndroid.setVibrationsEnabled(a0);
}
}, setLightsEnabled: function(a0) {
if (require(dependencyMap[1]).isAndroid()) {
PushNotificationAndroid.setLightsEnabled(a0);
}
}, setAndroidNotifyEveryTime: function(a0) {
if (require(dependencyMap[1]).isAndroid()) {
PushNotificationAndroid.setNotifyEveryTime(a0);
}
}, shouldAndroidNotifyEveryTime: function() {
var Promise = global.Promise;
var value = Object.create(Promise.prototype, {constructor: {value: Promise}});
var value2 = new Promise(_fun82559);
return value2 instanceof Object ? value2 : value;
}};
(require(2) /* metro dependency 2 */).fileFinishedImporting('lib/pushnotification/PushNotification.tsx');
exports.default = object2;
}
function createNotification(a0) { // fn#82511, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:223, offset: 0x01ef9e0c, size: 121 bytes, params: 2, frame: 4
const env0_0 = a0;
let value = null;
return value == a0 ? value : {getData: getData_82512, getMessage: function() {
var Error = global.Error;
throw new Error('TODO: Implement on Android');
}, getSound: function() {
var Error = global.Error;
throw new Error('TODO: Implement on Android');
}, getCategory: function() {
var Error = global.Error;
throw new Error('TODO: Implement on Android');
}, getAlert: function() {
var Error = global.Error;
throw new Error('TODO: Implement on Android');
}, getContentAvailable: function() {
var Error = global.Error;
throw new Error('TODO: Implement on Android');
}, getBadgeCount: function() {
var Error = global.Error;
throw new Error('TODO: Implement on Android');
}, finish: function(a0) {
var Error = global.Error;
var value = 'Not implemented on Android: ' + a0;
value = new Error(value);
throw value;
}};
}
function getInitialNotification() { // fn#82520, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:810, offset: 0x01ef9f28, size: 109 bytes, params: 1, frame: 12
var r0;
var value;
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
if (platformUtilsModule.isAndroid()) {
r0 = new global.Promise(_fun82521);
} else {
value = importDefault(10742) /* metro dependency 10742 */;
value = value.getInitialNotification();
r0 = value;
}
return r0;
}
function setMultiAccountUsers(a0) { // fn#82524, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:1016, offset: 0x01efa021, size: 152 bytes, params: 2, frame: 15
var NSUserDefaultsBridge;
const JSON = global.JSON;
const value = JSON.stringify(a0);
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
if (platformUtilsModule.isAndroid()) {
if (!(PushNotificationAndroid == null || PushNotificationAndroid.setMultiAccountUsernames == null)) {
PushNotificationAndroid.setMultiAccountUsernames(value);
}
} else {
NSUserDefaultsBridge = NativeModules.NSUserDefaultsBridge;
if (!(NSUserDefaultsBridge == null || NSUserDefaultsBridge.setMultiAccountUsersJSONString == null)) {
NSUserDefaultsBridge.setMultiAccountUsersJSONString(value);
}
}
}
function setApplicationIconBadgeNumber(a0) { // fn#82526, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:1348, offset: 0x01efa104, size: 74 bytes, params: 2, frame: 12
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
if (!platformUtilsModule.isAndroid()) {
(importDefault(10742) /* metro dependency 10742 */).setApplicationIconBadgeNumber(a0);
}
}
function clearAllNotifications() { // fn#82527, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:1444, offset: 0x01efa14e, size: 89 bytes, params: 1, frame: 13
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
if (platformUtilsModule.isAndroid()) {
PushNotificationAndroid.clearAllNotifications();
} else {
(importDefault(10742) /* metro dependency 10742 */).setApplicationIconBadgeNumber(0);
}
}
function presentLocalNotification(a0) { // fn#82528, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:1556, offset: 0x01efa1a7, size: 91 bytes, params: 2, frame: 14
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
if (platformUtilsModule.isAndroid()) {
PushNotificationAndroid.presentLocalNotification(a0);
} else {
(importDefault(10742) /* metro dependency 10742 */).presentLocalNotification(a0);
}
}
function getDeliveredNotifications() { // fn#82529, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:1697, offset: 0x01efa202, size: 93 bytes, params: 1, frame: 12
let value = require(477) /* metro dependency 477: PlatformUtils */;
value = value.isAndroid();
const Promise = global.Promise;
return value ? Promise.resolve([]) : new Promise(_fun82530);
}
function removeDeliveredNotifications(a0) { // fn#82531, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:1798, offset: 0x01efa288, size: 74 bytes, params: 2, frame: 12
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
if (!platformUtilsModule.isAndroid()) {
(importDefault(10742) /* metro dependency 10742 */).removeDeliveredNotifications(a0);
}
}
function scheduleLocalNotification(a0) { // fn#82532, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:1892, offset: 0x01efa2d2, size: 74 bytes, params: 2, frame: 12
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
if (!platformUtilsModule.isAndroid()) {
(importDefault(10742) /* metro dependency 10742 */).scheduleLocalNotification(a0);
}
}
function getScheduledLocalNotifications(a0) { // fn#82533, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:1980, offset: 0x01efa31c, size: 74 bytes, params: 2, frame: 12
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
if (!platformUtilsModule.isAndroid()) {
(importDefault(10742) /* metro dependency 10742 */).getScheduledLocalNotifications(a0);
}
}
function cancelLocalNotifications(a0) { // fn#82534, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:2078, offset: 0x01efa366, size: 74 bytes, params: 2, frame: 12
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
if (!platformUtilsModule.isAndroid()) {
(importDefault(10742) /* metro dependency 10742 */).cancelLocalNotifications(a0);
}
}
function cancelAllLocalNotifications() { // fn#82535, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:2164, offset: 0x01efa3b0, size: 70 bytes, params: 1, frame: 12
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
if (!platformUtilsModule.isAndroid()) {
(importDefault(10742) /* metro dependency 10742 */).cancelAllLocalNotifications();
}
}
function checkPermissions(a0) { // fn#82536, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:2254, offset: 0x01efa3f6, size: 83 bytes, params: 2, frame: 13
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
if (platformUtilsModule.isAndroid()) {
a0({});
} else {
(importDefault(10742) /* metro dependency 10742 */).checkPermissions(a0);
}
}
function requestPermissions(a0) { // fn#82537, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:2348, offset: 0x01efa449, size: 113 bytes, params: 2, frame: 12
var r0;
var value;
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
if (platformUtilsModule.isAndroid()) {
r0 = new global.Promise(function(a0) {
return a0({});
});
} else {
value = importDefault(10742) /* metro dependency 10742 */;
value = value.requestPermissions(a0);
r0 = value;
}
return r0;
}
function addNotificationEventListener(a0, a1) { // fn#82540, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:2463, offset: 0x01efa4e7, size: 165 bytes, params: 3, frame: 17
const env0_0 = a1;
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
if (platformUtilsModule.isAndroid()) {
if (a0 === 'notification') {
env0_5.addListener('notification', _fun82541);
}
if (a0 === 'localNotification') {
env0_5.addListener('localNotification', _fun82542);
}
PushNotificationAndroid.registerEventListener(a0);
} else {
(importDefault(10742) /* metro dependency 10742 */).addEventListener(a0, a1);
}
}
function addRegisterEventListener(a0) { // fn#82543, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:2785, offset: 0x01efa5b1, size: 129 bytes, params: 2, frame: 16
const env0_0 = a0;
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
if (platformUtilsModule.isAndroid()) {
env0_5.addListener('register', _fun82544);
PushNotificationAndroid.registerEventListener('register');
} else {
(importDefault(10742) /* metro dependency 10742 */).addEventListener('register', a0);
}
}
function getSoundsEnabled() { // fn#82545, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:2976, offset: 0x01efa64b, size: 39 bytes, params: 1, frame: 11
const Promise = global.Promise;
const value = Object.create(Promise.prototype, {constructor: {value: Promise}});
const promise = new Promise(_fun82546);
return promise instanceof Object ? promise : value;
}
function getVibrationsEnabled() { // fn#82548, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:3084, offset: 0x01efa6cb, size: 39 bytes, params: 1, frame: 11
const Promise = global.Promise;
const value = Object.create(Promise.prototype, {constructor: {value: Promise}});
const promise = new Promise(_fun82549);
return promise instanceof Object ? promise : value;
}
function getLightsEnabled() { // fn#82551, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:3192, offset: 0x01efa74b, size: 39 bytes, params: 1, frame: 11
const Promise = global.Promise;
const value = Object.create(Promise.prototype, {constructor: {value: Promise}});
const promise = new Promise(_fun82552);
return promise instanceof Object ? promise : value;
}
function shouldAndroidNotifyEveryTime() { // fn#82558, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:3583, offset: 0x01efa8b5, size: 39 bytes, params: 1, frame: 11
const Promise = global.Promise;
const value = Object.create(Promise.prototype, {constructor: {value: Promise}});
const promise = new Promise(_fun82559);
return promise instanceof Object ? promise : value;
}
function createNotificationGetData() { // fn#82512, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:283, owner: createNotification.getData, offset: 0x01ef9e85, size: 72 bytes, params: 1, frame: 14
const object2 = {};
const binding = env0_0;
copyDataProperties(object2, binding, undefined);
const message = binding.message;
const value2 = null;
object2['message'] = value2 != message ? global.JSON.parse(env0_0.message) : value2;
return object2;
}
function _fun82521(a0) { // fn#82521, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:847, offset: 0x01ef9f95, size: 47 bytes, params: 2, frame: 11
var environment;
const env0_0 = a0;
const value = environment.__proto__;
PushNotificationAndroid.getInitialNotification().then(_fun82522);
}
function _fun82530(a0) { // fn#82530, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:1754, offset: 0x01efa25f, size: 41 bytes, params: 2, frame: 12
const value = environment.__proto__;
(importDefault(10742) /* metro dependency 10742 */).getDeliveredNotifications(a0);
}
function _fun82541(a0) { // fn#82541, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:2568, offset: 0x01efa58c, size: 37 bytes, params: 2, frame: 11
let value = environment.__proto__;
value = createNotification(a0);
if (value != null) {
require(value);
}
}
function _fun82544({token}) { // fn#82544, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:2860, offset: 0x01efa632, size: 25 bytes, params: 2, frame: 11
env0_0(token);
}
function _fun82546(a0) { // fn#82546, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:2993, offset: 0x01efa672, size: 89 bytes, params: 2, frame: 14
var environment;
const env0_0 = a0;
const value = environment.__proto__;
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
if (platformUtilsModule.isAndroid()) {
PushNotificationAndroid.getSoundsEnabled().then(_fun82547);
} else {
a0(false);
}
}
function _fun82549(a0) { // fn#82549, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:3101, offset: 0x01efa6f2, size: 89 bytes, params: 2, frame: 14
var environment;
const env0_0 = a0;
const value = environment.__proto__;
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
if (platformUtilsModule.isAndroid()) {
PushNotificationAndroid.getVibrationsEnabled().then(_fun82550);
} else {
a0(false);
}
}
function _fun82552(a0) { // fn#82552, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:3209, offset: 0x01efa772, size: 89 bytes, params: 2, frame: 14
var environment;
const env0_0 = a0;
const value = environment.__proto__;
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
if (platformUtilsModule.isAndroid()) {
PushNotificationAndroid.getLightsEnabled().then(_fun82553);
} else {
a0(false);
}
}
function _fun82559(a0) { // fn#82559, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:3600, offset: 0x01efa8dc, size: 91 bytes, params: 2, frame: 14
var environment;
const env0_0 = a0;
const value = environment.__proto__;
const platformUtilsModule = require(477) /* metro dependency 477: PlatformUtils */;
if (platformUtilsModule.isAndroid()) {
PushNotificationAndroid.shouldNotifyEveryTime().then(_fun82560);
} else {
a0(false);
}
}
function _fun82522(a0) { // fn#82522, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10927:884, offset: 0x01ef9fc4, size: 31 bytes, params: 2, frame: 12
env0_0(createNotification(a0));
}