Files
discord-decomp/sources/stores/native/PushNotificationPermissionStore.tsx
T
2026-07-27 16:20:00 +03:00

193 lines
9.7 KiB
TypeScript

/* Metro module 11872; source: stores/native/PushNotificationPermissionStore.tsx; dependencies: [6, 7, 15, 17, 18, 10741, 566, 694, 2] */
function _fun91035(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#91035, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12058:6, offset: 0x020513e0, size: 702 bytes, params: 8, frame: 25
var object4;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_2 = importDefault(6) /* metro dependency 6 */;
const env0_3 = importDefault(7) /* metro dependency 7 */;
const env0_4 = importDefault(15) /* metro dependency 15 */;
const env0_5 = importDefault(17) /* metro dependency 17 */;
const env0_6 = importDefault(18) /* metro dependency 18 */;
object4 = {INIT: 0};
object4[0] = 'INIT';
object4.REQUESTED = 1;
object4[1] = 'REQUESTED';
object4.PROMPT_SEEN = 2;
object4[2] = 'PROMPT_SEEN';
object4.PROMPT_SKIPPED = 3;
object4[3] = 'PROMPT_SKIPPED';
const object5 = {MESSAGE_SENT: 0};
object5[0] = 'MESSAGE_SENT';
object5.INVITE_ACCEPTED = 1;
object5[1] = 'INVITE_ACCEPTED';
object5.FRIEND_REQUEST_SENT = 2;
object5[2] = 'FRIEND_REQUEST_SENT';
object5.DM_SPACE = 3;
object5[3] = 'DM_SPACE';
object5.CHANNEL_BANNER = 5;
object5[5] = 'CHANNEL_BANNER';
object5.POST_REACTION_BANNER = 6;
object5[6] = 'POST_REACTION_BANNER';
object5.GUILD_OPEN_BOTTOM_SHEET = 7;
object5[7] = 'GUILD_OPEN_BOTTOM_SHEET';
object5.CALL_DISCONNECT_BOTTOM_SHEET = 8;
object5[8] = 'CALL_DISCONNECT_BOTTOM_SHEET';
const object6 = {};
const INIT = object4.INIT;
object6.permissionState = INIT;
const MESSAGE_SENT = object5.MESSAGE_SENT;
const INVITE_ACCEPTED = object5.INVITE_ACCEPTED;
const FRIEND_REQUEST_SENT = object5.FRIEND_REQUEST_SENT;
const DM_SPACE = object5.DM_SPACE;
const CHANNEL_BANNER = object5.CHANNEL_BANNER;
const POST_REACTION_BANNER = object5.POST_REACTION_BANNER;
const GUILD_OPEN_BOTTOM_SHEET = object5.GUILD_OPEN_BOTTOM_SHEET;
const CALL_DISCONNECT_BOTTOM_SHEET = object5.CALL_DISCONNECT_BOTTOM_SHEET;
object6.promptLastSeen = {[MESSAGE_SENT]: null, [INVITE_ACCEPTED]: null, [FRIEND_REQUEST_SENT]: null,
[DM_SPACE]: null, [CHANNEL_BANNER]: null, [POST_REACTION_BANNER]: null, [GUILD_OPEN_BOTTOM_SHEET]: null,
[CALL_DISCONNECT_BOTTOM_SHEET]: null};
const Set = global.Set;
let set = new Set([]);
object6.eligiblePromptTypes = set;
const DeviceSettingsStore = (importDefault(566) /* metro dependency 566: flux */).DeviceSettingsStore;
set = _fun91039(DeviceSettingsStore);
set.displayName = 'PushNotificationPermissionStore';
set.persistKey = 'PushNotificationPermissionStoreKey_1';
set.migrations = [_fun91048];
set = new set(importDefault(694) /* metro dependency 694: Dispatcher */,
{PUSH_NOTIFICATION_PERMISSION_SET_STATE: PUSH_NOTIFICATION_PERMISSION_SET_STATE,
PUSH_NOTIFICATION_PERMISSION_REACTIVATION_SEEN: PUSH_NOTIFICATION_PERMISSION_REACTIVATION_SEEN,
PUSH_NOTIFICATION_PERMISSION_SET_ELIGIBLE: PUSH_NOTIFICATION_PERMISSION_SET_ELIGIBLE,
PUSH_NOTIFICATION_AUTHORIZATION_STATUS_UPDATE: function(a0) {
env0_11 = a0.authorizationStatus;
}});
(require(2) /* metro dependency 2 */).fileFinishedImporting('stores/native/PushNotificationPermissionStore.tsx');
exports.default = set;
exports.PermissionStateType = object4;
exports.PermissionPromptType = object5;
}
function _isNativeReflectConstruct_91036() { // fn#91036, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12058:148, offset: 0x0205169e, size: 98 bytes, params: 1, frame: 18
var Boolean;
var prototype;
var valueOf;
var call;
var Reflect;
var construct;
var closure;
var value;
var error;
try {
Boolean = global.Boolean;
prototype = Boolean.prototype;
valueOf = prototype.valueOf;
call = valueOf.call;
Reflect = global.Reflect;
construct = Reflect.construct;
Boolean = global.Boolean;
closure = function() {
};
value = Reflect.apply(construct, Reflect, [Boolean, [], closure]);
value = Reflect.apply(call, valueOf, [value]);
var result = !value;
} catch (error) {
}
return (_isNativeReflectConstruct_91036_isNativeReflectConstruct = function() {
return !!result;
})();
}
function _fun91039(a0) { // fn#91039, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12058:1199, offset: 0x02051700, size: 174 bytes, params: 2, frame: 16
const closure = PushNotificationPermissionStore;
env0_6(closure, a0);
return env0_3(closure, [{key: 'initialize', value: value_91041}, {key: 'getUserAgnosticState', value: value_91044},
{key: 'permissionState', get: get_91045}, {key: 'promptSeen', get: get_91046}, {key: 'authorizationStatus',
get: get_91047}]);
}
function _fun91048(a0) { // fn#91048, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12058:2378, offset: 0x02051948, size: 244 bytes, params: 2, frame: 15
const object3 = {};
const binding = env0_9;
copyDataProperties(object3, binding, undefined);
copyDataProperties(object3, a0, undefined);
const object4 = {};
copyDataProperties(object4, binding.promptLastSeen, undefined);
copyDataProperties(object4, a0.promptLastSeen, undefined);
object3['promptLastSeen'] = object4;
object3['eligiblePromptTypes'] = a0.eligiblePromptTypes == null ? new global.Set([]) : global.Array.isArray(a0.eligiblePromptTypes) ? new global.Set(a0.eligiblePromptTypes) : a0.eligiblePromptTypes instanceof global.Set ? a0.eligiblePromptTypes : new global.Set([]);
return object3;
}
function PUSH_NOTIFICATION_PERMISSION_SET_STATE({permissionState}) { // fn#91049, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12058:2712, offset: 0x02051a3c, size: 26 bytes, params: 2, frame: 2
env0_10.permissionState = permissionState;
}
function PUSH_NOTIFICATION_PERMISSION_REACTIVATION_SEEN({promptType}) { // fn#91050, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12058:2845, offset: 0x02051a56, size: 58 bytes, params: 2, frame: 11
const promptLastSeen = env0_10.promptLastSeen;
const Date = global.Date;
promptLastSeen[promptType] = new Date();
return true;
}
function PUSH_NOTIFICATION_PERMISSION_SET_ELIGIBLE({promptType}) { // fn#91051, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12058:2986, offset: 0x02051a90, size: 74 bytes, params: 2, frame: 13
const binding = env0_10;
const Set = global.Set;
binding.eligiblePromptTypes = new Set(env0_10.eligiblePromptTypes).add(promptType);
return true;
}
function value_91041(a0) { // fn#91041, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12058:1584, offset: 0x020517ae, size: 257 bytes, params: 2, frame: 21
let value = a0;
const object3 = {};
copyDataProperties(object3, env1_9, undefined);
const value3 = null;
copyDataProperties(object3, value3 != value ? value : value3, undefined);
const object4 = {};
copyDataProperties(object4, env1_9.promptLastSeen, undefined);
const value4 = undefined;
copyDataProperties(object4, value3 == value ? value4 : value.promptLastSeen, undefined);
object3['promptLastSeen'] = object4;
const Set = global.Set;
let eligiblePromptTypes = env1_9.eligiblePromptTypes;
const items2 = [];
const value5 = arraySpread(items2, eligiblePromptTypes, 0, undefined);
const value6 = value3 == value;
eligiblePromptTypes = value6 ? value4 : value.eligiblePromptTypes;
arraySpread(items2, value3 != eligiblePromptTypes ? eligiblePromptTypes : [], value5, value6);
value = items2.filter(_fun91042);
const value7 = Object.create(Set.prototype, {constructor: {value: Set}});
const set = new Set(value);
object3['eligiblePromptTypes'] = set instanceof Object ? set : value7;
(importDefault(10741) /* metro dependency 10741: PushNotification */).checkPermissions(_fun91043);
return value4;
}
function get_91045() { // fn#91045, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12058:2039, offset: 0x02051904, size: 15 bytes, params: 1, frame: 1
return env1_10.permissionState;
}
function get_91046() { // fn#91046, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12058:2099, offset: 0x02051913, size: 53 bytes, params: 1, frame: 12
const binding = env1_7;
const PROMPT_SEEN = binding.PROMPT_SEEN;
const items2 = [PROMPT_SEEN];
const PROMPT_SKIPPED = binding.PROMPT_SKIPPED;
items2[1] = PROMPT_SKIPPED;
return items2.includes(env1_10.permissionState);
}
function _fun91042(a0) { // fn#91042, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12058:1818, offset: 0x020518af, size: 22 bytes, params: 2, frame: 2
const POST_REACTION_BANNER = env2_8.POST_REACTION_BANNER;
return a0 !== POST_REACTION_BANNER;
}
function _fun91043({alert, sound, badge}) { // fn#91043, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12058:1878, offset: 0x020518c5, size: 63 bytes, params: 2, frame: 4
var value;
let r0 = alert || sound;
r0 = !r0 ? badge : r0;
if (r0) {
value = environment.__proto__.__proto__;
env2_10.permissionState = env2_7.REQUESTED;
}
}