Build 545032stable
Module 252431
7,172 characters · in no known chunkDependencies
Source Raw
function(e,t,n){"use strict";n.d(t,{A:()=>O}),n(321073);var i=n(17928),r=n(228366),s=n(736056),a=n(698441),o=n(320095),l=n(383233),u=n(994500),c=n(287809),d=n(935208),_=n(322387),f=n(995273),h=n(652215);let p={loading:!1,initialized:!1,errored:!1,isDataStale:!1,notifCenterItems:[],staleNotifCenterItems:[],notifCenterIds:new Set,notifCenterLocalItems:[],paginationHasMore:!0,paginationCursor:void 0,notifCenterActive:!1,notifCenterTabFocused:!1};function E(e){return null!=e.id&&null!=e.type}function m(){let{keepLocalItems:e=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};p={loading:!1,initialized:!1,errored:!1,isDataStale:!1,notifCenterItems:[],staleNotifCenterItems:[],notifCenterIds:new Set,notifCenterLocalItems:e?p.notifCenterLocalItems:[],paginationHasMore:!0,paginationCursor:void 0,notifCenterActive:!1,notifCenterTabFocused:!1}}function g(){m({keepLocalItems:!0})}function A(e){return{...e,kind:"notification-center-item",message:null!=e.message?(0,o.rh)(e.message):void 0,applicationId:null!=e.application?e.application.id:void 0}}function I(e){let t="NOTIFICATION_CENTER_ITEM_CREATE"===e.type?A(e.item):e.item;if(!p.initialized||!E(t)||p.notifCenterIds.has(t.id))return!1;p.notifCenterIds.add(t.id),p.notifCenterItems=[t,...p.notifCenterItems],p.notifCenterItems.sort((e,t)=>d.default.compare(t.id,e.id))}function T(e,t){p.notifCenterItems=p.notifCenterItems.map(n=>e.includes(n.id)?{...n,acked:t}:n).filter(E)}function S(e,t,n){return e.type===t&&e.other_user?.id===n}function N(e,t,n,i){return S(e,t,n)&&e.applicationId===i}function y(e){let{relationship:t}=e,{id:n,type:i,isSpamRequest:r,userIgnored:s,user:a,since:o,originApplicationId:l}=t;if(i===h.eA$.PENDING_INCOMING&&!r&&!s){if(null==o)return null;if(null!=a){let e=c.default.getUser(a.id);null!=e&&(p.notifCenterLocalItems=[...p.notifCenterLocalItems,(0,f.Qi)(e,o,l)])}}i!==h.eA$.FRIEND||null==t.user||s||(p.notifCenterLocalItems=p.notifCenterLocalItems.map(e=>S(e,_.Uo.INCOMING_FRIEND_REQUESTS,t.user.id)?{...e,acked:!0,forceUnacked:!1,local_id:`incoming_friend_requests_accepted_${a.id}_${e.id}`,type:_.Uo.INCOMING_FRIEND_REQUESTS_ACCEPTED}:e)),(i===h.eA$.BLOCKED||s)&&(p.notifCenterLocalItems=p.notifCenterLocalItems.filter(e=>!S(e,_.Uo.INCOMING_FRIEND_REQUESTS,n)&&!S(e,_.Uo.INCOMING_FRIEND_REQUESTS_ACCEPTED,n)&&!S(e,_.Uo.INCOMING_GAME_FRIEND_REQUESTS,n)&&!S(e,_.Uo.INCOMING_GAME_FRIEND_REQUESTS_ACCEPTED,n)))}function C(e){(0,a.AZ)(e)&&(p.notifCenterItems=p.notifCenterItems.map(t=>t.type===_.hW.GUILD_SCHEDULED_EVENT_STARTED&&t.guild_scheduled_event_id===e.id?{...t,disable_action:!0}:t))}class v extends i.Ay.PersistedStore{static displayName="NotificationCenterItemsStore";static persistKey="NotificationCenterItemsStore_v2";initialize(e){if(this.waitFor(c.default,u.A,s.A),null!=e){let t=e.notifCenterItems.map(e=>({...e,message:null!=e.message?new l.Ay(e.message):void 0}));t.length>0&&(p={...p,initialized:!0,isDataStale:!0,notifCenterItems:[],staleNotifCenterItems:t})}}getState(){let e=e=>({...e,message:null!=e.message?e.message.toJS():void 0});return{...p,notifCenterItems:p.notifCenterItems.map(e),staleNotifCenterItems:p.staleNotifCenterItems.map(e)}}get loading(){return p.loading}get initialized(){return p.initialized}get items(){return p.isDataStale?p.staleNotifCenterItems:p.notifCenterItems}get hasMore(){return p.paginationHasMore}get cursor(){return p.paginationCursor}get errored(){return p.errored}get active(){return p.notifCenterActive}get localItems(){return p.notifCenterLocalItems}get tabFocused(){return p.notifCenterTabFocused}}let O=new v(r.h,{CONNECTION_OPEN:function(e){m();let t=[],n=new Set;e.relationships.forEach(e=>{let{id:i,type:r,since:s,is_spam_request:a,user_ignored:o,origin_application_id:l}=e;if(o&&n.add(i),r!==h.eA$.PENDING_INCOMING||a||o||null==s)return null;let u=c.default.getUser(i);if(null==u)return null;t.push((0,f.Qi)(u,s,l))}),e.gameRelationships.forEach(e=>{let{type:i,id:r,application_id:s,since:a}=e;if(i!==h.eA$.PENDING_INCOMING||n.has(r))return;let o=c.default.getUser(r);null!=o&&t.push((0,f.KS)(o,a,s))}),e.guilds.forEach(e=>{e.guild_scheduled_events.forEach(e=>{C(e)})}),p.notifCenterLocalItems=t},LOGOUT:()=>m(),NOTIFICATION_CENTER_ITEMS_ACK:function(e){let{ids:t}=e;T(t,!0)},NOTIFICATION_CENTER_ITEMS_ACK_FAILURE:function(e){let{ids:t}=e;T(t,!1)},GUILD_SCHEDULED_EVENT_UPDATE:function(e){let{guildScheduledEvent:t}=e;C(t)},NOTIFICATION_CENTER_ITEM_CREATE:I,NOTIFICATION_CENTER_ITEM_DELETE:function(e){let{id:t}=e;if(!p.notifCenterIds.has(t))return!1;p.notifCenterIds.delete(t),p.notifCenterItems=p.notifCenterItems.filter(e=>e.id!==t)},NOTIFICATION_CENTER_ITEM_DELETE_FAILURE:I,LOAD_NOTIFICATION_CENTER_ITEMS:function(){p.loading=!0},LOAD_NOTIFICATION_CENTER_ITEMS_FAILURE:function(){p.loading=!1,p.initialized=!0,p.errored=!0},LOAD_NOTIFICATION_CENTER_ITEMS_SUCCESS:function(e){let{items:t,hasMore:n,cursor:i}=e;p.loading&&(p.loading=!1,p.initialized=!0,p.errored=!1,p.isDataStale=!1,null!=i&&p.notifCenterIds.has(i)||(p.paginationHasMore=t.length>0&&n,p.paginationCursor=t.length>0?i:void 0),p.notifCenterItems=[...p.notifCenterItems,...t.map(A).filter(e=>!p.notifCenterIds.has(e.id))],p.notifCenterItems.sort((e,t)=>d.default.compare(t.id,e.id)),t.forEach(e=>p.notifCenterIds.add(e.id)))},RESET_NOTIFICATION_CENTER:()=>g(),NOTIFICATION_CENTER_SET_ACTIVE:function(e){let{active:t}=e;p.notifCenterActive=t},NOTIFICATION_CENTER_TAB_FOCUSED:function(e){let{focused:t}=e;p.notifCenterTabFocused=t},RELATIONSHIP_ADD:y,RELATIONSHIP_UPDATE:y,RELATIONSHIP_REMOVE:function(e){p.notifCenterLocalItems=p.notifCenterLocalItems.filter(t=>!S(t,_.Uo.INCOMING_FRIEND_REQUESTS,e.relationship.id)&&!S(t,_.Uo.INCOMING_FRIEND_REQUESTS_ACCEPTED,e.relationship.id))},GAME_RELATIONSHIP_ADD:function(e){let{gameRelationship:t}=e,{id:n,type:i,since:r,applicationId:s}=t;if(u.A.isBlockedOrIgnored(n))return!1;if(i===h.eA$.PENDING_INCOMING){let e=c.default.getUser(n);null!=r&&null!=e&&(p.notifCenterLocalItems=[...p.notifCenterLocalItems,(0,f.KS)(e,r,s)])}else{if(i!==h.eA$.FRIEND)return!1;p.notifCenterLocalItems=p.notifCenterLocalItems.map(e=>N(e,_.Uo.INCOMING_GAME_FRIEND_REQUESTS,n,s)?{...e,acked:!0,forceUnacked:!1,local_id:`incoming_game_friend_requests_accepted_${n}_${e.id}`,type:_.Uo.INCOMING_GAME_FRIEND_REQUESTS_ACCEPTED}:e)}},GAME_RELATIONSHIP_REMOVE:function(e){let{userId:t,applicationId:n}=e;p.notifCenterLocalItems=p.notifCenterLocalItems.filter(e=>!N(e,_.Uo.INCOMING_GAME_FRIEND_REQUESTS,t,n)&&!N(e,_.Uo.INCOMING_GAME_FRIEND_REQUESTS_ACCEPTED,t,n))},NOTIFICATION_CENTER_ITEM_COMPLETED:function(e){let{item_enum:t}=e;p.notifCenterItems=p.notifCenterItems.map(e=>e.item_enum===t?{...e,completed:!0,acked:!0}:e).filter(E)},SET_RECENT_MENTIONS_FILTER:()=>g(),MOBILE_NATIVE_UPDATE_CHECK_FINISHED:function(e){let{newBuild:t}=e;if(null!==t){let e=(0,f._u)(t);void 0===p.notifCenterLocalItems.find(t=>t.local_id===e.local_id)&&(p.notifCenterLocalItems=[...p.notifCenterLocalItems.filter(t=>t.kind!==e.kind),e])}},APPLICATIONS_FETCH_SUCCESS:function(e){let{unknownApplicationIds:t}=e;if(null==t)return;let n=new Set(t);p.notifCenterLocalItems=p.notifCenterLocalItems.filter(e=>null==e.applicationId||!n.has(e.applicationId))}})}