element-web-synapse01pim.gr.jp

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

1436.js (11892B)


      1 "use strict";(self.webpackChunkelement_web=self.webpackChunkelement_web||[]).push([[1436],{"./src/stores/room-list-v3/RoomListStoreV3.ts":(t,e,s)=>{s.d(e,{LISTS_LOADED_EVENT:()=>U,LISTS_UPDATE_EVENT:()=>P,default:()=>T});var o=s("./node_modules/@babel/runtime/helpers/esm/defineProperty.js"),i=s("./node_modules/matrix-js-sdk/src/logger.ts"),r=s("./node_modules/matrix-js-sdk/src/matrix.ts"),n=s("./src/stores/AsyncStoreWithClient.ts"),a=s("./src/settings/SettingsStore.ts"),c=s("./src/stores/room-list/filters/VisibilityProvider.ts"),l=s("./src/dispatcher/dispatcher.ts"),m=s("./src/stores/spaces/SpaceStore.ts");class h{constructor(t){(0,o.A)(this,"_isInActiveSpace",!1),(0,o.A)(this,"next",[]),(0,o.A)(this,"previous",[]),(0,o.A)(this,"filterKeysSet",new Set),this.room=t}get isInActiveSpace(){return this._isInActiveSpace}checkIfRoomBelongsToActiveSpace(){const t=m.Ay.instance.activeSpace;this._isInActiveSpace=m.Ay.instance.isRoomInSpace(t,this.room.roomId)}doesRoomMatchFilters(t){return!t.some(t=>!this.filterKeysSet.has(t))}applyFilters(t){this.filterKeysSet=new Set;for(const e of t)e.matches(this.room)&&this.filterKeysSet.add(e.key)}}function d(){return Math.random()<.5}class u{get size(){return this._size}constructor(t){(0,o.A)(this,"head",void 0),(0,o.A)(this,"current",void 0),(0,o.A)(this,"_size",0),this.level=t}setNext(t){this.head||(this.head=t),this.current?(t.previous[this.level]=this.current,this.current.next[this.level]=t,this.current=t):this.current=t,this._size++}generateNextLevel(){const t=new u(this.level+1);let e=this.head;for(;e;)d()&&t.setNext(e),e=e.next[this.level];return t}removeNode(t){if(!(this.head===t||t.previous[this.level]))return;const e=t.previous[this.level];if(e){const s=t.next[this.level];e.next[this.level]=s,s&&(s.previous[this.level]=e)}else{const e=t.next[this.level];this.head=e,e&&(e.previous[this.level]=t.previous[this.level])}this._size--}insertAfter(t,e){const s=this.level,o=t.next[s];o&&(e.next[s]=o,o.previous[s]=e),t.next[s]=e,e.previous[s]=t,this._size++}insertAtHead(t){const e=this.head;this.head=t,e&&(t.next[this.level]=e,e.previous[this.level]=t),this._size++}}class v{constructor(t){this.current=t}next(){const t=this.current;return t?(this.current=t.next[0],{value:t.room}):{value:void 0,done:!0}}}class p{constructor(t,e){this.current=t,this.filters=e}[Symbol.iterator](){return this}next(){let t=this.current;for(;t&&(!t.isInActiveSpace||!t.doesRoomMatchFilters(this.filters));)t=t.next[0];return t?(this.current=t.next[0],{value:t.room}):{value:void 0,done:!0}}}class f{constructor(t,e=[]){(0,o.A)(this,"levels",[new u(0)]),(0,o.A)(this,"roomNodeMap",new Map),(0,o.A)(this,"initialized",!1),this.sorter=t,this.filters=e}reset(){this.levels=[new u(0)],this.roomNodeMap=new Map}seed(t){const e=this.sorter.sort(t).map(t=>new h(t));let s=this.levels[0];for(const t of e)t.applyFilters(this.filters),s.setNext(t),this.roomNodeMap.set(t.room.roomId,t);do{this.levels[s.level]=s,s=s.generateNextLevel()}while(s.size>1);this.calculateActiveSpaceForNodes(),this.initialized=!0}calculateActiveSpaceForNodes(){for(const t of this.roomNodeMap.values())t.checkIfRoomBelongsToActiveSpace()}useNewSorter(t,e){this.reset(),this.sorter=t,this.seed(e)}removeRoom(t){const e=this.roomNodeMap.get(t.roomId);if(this.roomNodeMap.delete(t.roomId),e)for(const t of this.levels)t.removeNode(e)}reInsertRoom(t){this.roomNodeMap.has(t.roomId)&&(this.removeRoom(t),this.addNewRoom(t))}addNewRoom(t){if(this.roomNodeMap.has(t.roomId))throw new Error(`Can't add room to skiplist: ${t.roomId} is already in the skiplist!`);this.insertRoom(t)}insertRoom(t){const e=new h(t);e.checkIfRoomBelongsToActiveSpace(),e.applyFilters(this.filters),this.roomNodeMap.set(t.roomId,e);const s=[];for(let e=this.levels.length-1;e>=0;--e){const o=this.levels[e];if(!o.head){s[e]=null;continue}let i=o.head,r=null;for(;i&&this.sorter.comparator(i.room,t)<0;)r=i,i=i.next[e];s[e]=r}for(const[t,o]of s.entries()){if(0!==t&&!d())break;{const s=this.levels[t];o?s.insertAfter(o,e):s.insertAtHead(e)}}}[Symbol.iterator](){return new v(this.levels[0].head)}getRoomsInActiveSpace(t=[]){return new p(this.levels[0].head,t)}get size(){return this.levels[0].size}get activeSortAlgorithm(){return this.sorter.type}}var S=s("./src/stores/room-list-v3/skip-list/sorters/index.ts"),g=s("./src/stores/room-list/algorithms/tag-sorting/RecentAlgorithm.ts"),A=s("./src/stores/notifications/RoomNotificationStateStore.ts"),R=s("./src/stores/room-list/models.ts");class w{constructor(t){this.myUserId=t}sort(t){const e={};return[...t].sort((t,s)=>this.comparator(t,s,e))}comparator(t,e,s){const o=this.getScore(t)-this.getScore(e);if(0!==o)return o;const i=this.getTs(t,s);return this.getTs(e,s)-i}get type(){return S.U.Recency}getScore(t){const e=!!t.tags[R.zO.LowPriority],s=A.n.instance.getRoomState(t).muted;return s&&e?5:s?10:e?2:0}getTs(t,e){var s;const o=null!==(s=null==e?void 0:e[t.roomId])&&void 0!==s?s:(0,g.Qi)(t,this.myUserId);return e&&(e[t.roomId]=o),o}}class k{constructor(){(0,o.A)(this,"collator",new Intl.Collator)}sort(t){return[...t].sort((t,e)=>this.comparator(t,e))}comparator(t,e){return this.collator.compare(t.name,e.name)}get type(){return S.U.Alphabetic}}var y=s("./src/utils/read-receipts.ts"),I=s("./src/utils/membership.ts"),L=s("./src/stores/spaces/index.ts"),x=s("./src/stores/room-list-v3/skip-list/filters/index.ts");var M=s("./src/utils/notifications.ts");var F=s("./src/utils/DMRoomMap.ts");var b=s("./src/settings/SettingLevel.ts"),_=s("./src/stores/room-list/utils/roomMute.ts"),E=s("./src/dispatcher/actions.ts");const N=[new class{matches(t){return!!t.tags[R.zO.Favourite]}get key(){return x.M.FavouriteFilter}},new class{matches(t){return A.n.instance.getRoomState(t).hasUnreadCount||!!(0,M.nx)(t)}get key(){return x.M.UnreadFilter}},new class{matches(t){return!!F.A.shared().getUserIdForRoomId(t.roomId)}get key(){return x.M.PeopleFilter}},new class{matches(t){return!F.A.shared().getUserIdForRoomId(t.roomId)}get key(){return x.M.RoomsFilter}},new class{matches(t){return t.getMyMembership()===r.KnownMembership.Invite}get key(){return x.M.InvitesFilter}},new class{matches(t){return A.n.instance.getRoomState(t).isMention}get key(){return x.M.MentionsFilter}},new class{matches(t){return!!t.tags[R.zO.LowPriority]}get key(){return x.M.LowPriorityFilter}}];let C=function(t){return t.ListsUpdate="lists_update",t.ListsLoaded="lists_loaded",t}({});const P=C.ListsUpdate,U=C.ListsLoaded;class z extends n.r{constructor(t){super(t),(0,o.A)(this,"roomSkipList",void 0),(0,o.A)(this,"msc3946ProcessDynamicPredecessor",void 0),this.msc3946ProcessDynamicPredecessor=a.A.getValue("feature_dynamic_room_predecessors"),m.Ay.instance.on(L.tw,()=>{this.onActiveSpaceChanged()}),m.Ay.instance.on(L.EC,()=>this.onActiveSpaceChanged())}getRooms(){var t,e;let s=null!==(t=null===(e=this.matrixClient)||void 0===e?void 0:e.getVisibleRooms(this.msc3946ProcessDynamicPredecessor))&&void 0!==t?t:[];return s=s.filter(t=>c.W.instance.isRoomVisible(t)),s}get isLoadingRooms(){var t;return!(null!==(t=this.roomSkipList)&&void 0!==t&&t.initialized)}getSortedRooms(){var t;return null!==(t=this.roomSkipList)&&void 0!==t&&t.initialized?Array.from(this.roomSkipList):[]}getSortedRoomsInActiveSpace(t){var e;const s=m.Ay.instance.activeSpace;return null!==(e=this.roomSkipList)&&void 0!==e&&e.initialized?{spaceId:s,filterKeys:t,rooms:Array.from(this.roomSkipList.getRoomsInActiveSpace(t))}:{spaceId:s,filterKeys:t,rooms:[]}}resort(t){if(!this.roomSkipList)throw new Error("Cannot resort room list before skip list is created.");if(!this.matrixClient)throw new Error("Cannot resort room list without matrix client.");if(this.roomSkipList.activeSortAlgorithm===t)return;const e=t===S.U.Alphabetic?new k:new w(this.matrixClient.getSafeUserId());this.roomSkipList.useNewSorter(e,this.getRooms()),this.emit(P),a.A.setValue("RoomList.preferredSorting",null,b.p.DEVICE,t)}get activeSortAlgorithm(){var t;return null===(t=this.roomSkipList)||void 0===t?void 0:t.activeSortAlgorithm}async onReady(){var t;if(null!==(t=this.roomSkipList)&&void 0!==t&&t.initialized||!this.matrixClient)return;const e=this.getPreferredSorter(this.matrixClient.getSafeUserId());this.roomSkipList=new f(e,N),await m.Ay.instance.storeReadyPromise;const s=this.getRooms();this.roomSkipList.seed(s),this.emit(U),this.emit(P)}async onAction(t){var e;if(this.matrixClient&&null!==(e=this.roomSkipList)&&void 0!==e&&e.initialized)switch(t.action){case"MatrixActions.Room.receipt":if((0,y.A)(t.event,this.matrixClient)){const e=t.room;if(!e)return void i.vF.warn(`Own read receipt was in unknown room ${e.roomId}`);this.addRoomAndEmit(e)}break;case"MatrixActions.Room.tags":{const e=t.room;this.addRoomAndEmit(e);break}case"MatrixActions.Room.accountData":{const e=t.event_type;if(e===M.uk||e===M.HG){const e=t.room;this.addRoomAndEmit(e)}break}case"MatrixActions.Event.decrypted":{const e=t.event.getRoomId();if(!e)return;const s=this.matrixClient.getRoom(e);if(!s)return void i.vF.warn(`Event ${t.event.getId()} was decrypted in an unknown room ${e}`);this.addRoomAndEmit(s);break}case"MatrixActions.accountData":this.handleAccountDataPayload(t);break;case"MatrixActions.Room.timeline":if(!t.isLiveEvent||!t.isLiveUnfilteredRoomTimelineEvent||!t.room)return;this.addRoomAndEmit(t.room);break;case"MatrixActions.Room.myMembership":{var s;const e=(0,I.Cs)(t.oldMembership),o=(0,I.E3)(t.room,t.membership),i=this.matrixClient.getSafeUserId();if(null===(s=t.room.getMember(i))||void 0===s?void 0:s.isKicked())return void this.addRoomAndEmit(t.room);if((e===I._T.Invite||e===I._T.Join)&&o===I._T.Leave)return this.roomSkipList.removeRoom(t.room),void this.emit(P);if(e!==I._T.Join&&o===I._T.Join){const e=t.room,s=e.client.getRoomUpgradeHistory(e.roomId,!0,this.msc3946ProcessDynamicPredecessor),o=s.slice(0,s.indexOf(e));for(const t of o)this.roomSkipList.removeRoom(t)}this.addRoomAndEmit(t.room,e===I._T.Leave);break}case E.r.AfterForgetRoom:{const e=t.room;this.roomSkipList.removeRoom(e),this.emit(P);break}}}handleAccountDataPayload(t){let e=!1;switch(t.event_type){case r.EventType.Direct:{const s=t.event.getContent();for(const t of Object.keys(s)){const o=s[t];for(const t of o){const s=this.matrixClient.getRoom(t);s?(this.roomSkipList.reInsertRoom(s),e=!0):i.vF.warn(`${t} was found in DMs but the room is not in the store`)}}break}case r.EventType.PushRules:{const s=(0,_.Q)(t);if(!s)return;const o=s.map(t=>{var e;return null===(e=this.matrixClient)||void 0===e?void 0:e.getRoom(t)}).filter(t=>!!t);for(const t of o)this.roomSkipList.reInsertRoom(t),e=!0;break}}e&&this.emit(P)}getPreferredSorter(t){switch(a.A.getValue("RoomList.preferredSorting")){case S.U.Alphabetic:return new k;case S.U.Recency:return new w(t);default:throw new Error("Got unknown sort preference from RoomList.preferredSorting setting")}}addRoomAndEmit(t,e=!1){if(!this.roomSkipList)throw new Error("roomSkipList hasn't been created yet!");if(e){if(!c.W.instance.isRoomVisible(t))return void i.vF.info(`RoomListStoreV3: Refusing to add new room ${t.roomId} because isRoomVisible returned false.`);this.roomSkipList.addNewRoom(t)}else this.roomSkipList.reInsertRoom(t);this.emit(P)}onActiveSpaceChanged(){this.roomSkipList&&(this.roomSkipList.calculateActiveSpaceForNodes(),this.emit(P))}}class T{static get instance(){if(!T.internalInstance){const t=new z(l.A);t.start(),T.internalInstance=t}return this.internalInstance}}(0,o.A)(T,"internalInstance",void 0),window.getRoomListStoreV3=()=>T.instance},"./src/stores/room-list-v3/skip-list/filters/index.ts":(t,e,s)=>{s.d(e,{M:()=>o});let o=function(t){return t[t.FavouriteFilter=0]="FavouriteFilter",t[t.UnreadFilter=1]="UnreadFilter",t[t.PeopleFilter=2]="PeopleFilter",t[t.RoomsFilter=3]="RoomsFilter",t[t.LowPriorityFilter=4]="LowPriorityFilter",t[t.MentionsFilter=5]="MentionsFilter",t[t.InvitesFilter=6]="InvitesFilter",t}({})}}]);
      2 //# sourceMappingURL=1436.js.map