@@ -4,7 +4,7 @@ import { debounce } from '@ember/runloop';
4
4
import Service , { service } from '@ember/service' ;
5
5
import { cached , tracked } from '@glimmer/tracking' ;
6
6
7
- import { restartableTask , task } from 'ember-concurrency' ;
7
+ import { task , dropTask } from 'ember-concurrency' ;
8
8
import window from 'ember-window-mock' ;
9
9
import { cloneDeep } from 'lodash' ;
10
10
import {
@@ -119,7 +119,7 @@ import type ResetService from './reset';
119
119
120
120
import type * as MatrixSDK from 'matrix-js-sdk' ;
121
121
122
- const { matrixURL, environment } = ENV ;
122
+ const { matrixURL } = ENV ;
123
123
const MAX_CARD_SIZE_KB = 60 ;
124
124
const STATE_EVENTS_OF_INTEREST = [ 'm.room.create' , 'm.room.name' ] ;
125
125
const SLIDING_SYNC_AI_ROOM_LIST_NAME = 'ai-room' ;
@@ -181,7 +181,7 @@ export default class MatrixService extends Service {
181
181
182
182
private slidingSync : SlidingSync | undefined ;
183
183
private aiRoomIds : Set < string > = new Set ( ) ;
184
- @tracked private isLoadingMoreAIRooms = false ;
184
+ @tracked private _isLoadingMoreAIRooms = false ;
185
185
186
186
constructor ( owner : Owner ) {
187
187
super ( owner ) ;
@@ -555,7 +555,7 @@ export default class MatrixService extends Service {
555
555
filters : {
556
556
is_dm : true ,
557
557
} ,
558
- timeline_limit : 1 ,
558
+ timeline_limit : SLIDING_SYNC_LIST_TIMELINE_LIMIT ,
559
559
required_state : [ [ '*' , '*' ] ] ,
560
560
} ) ;
561
561
this . slidingSync = new this . matrixSdkLoader . SlidingSync (
@@ -565,7 +565,7 @@ export default class MatrixService extends Service {
565
565
timeline_limit : SLIDING_SYNC_LIST_TIMELINE_LIMIT ,
566
566
} ,
567
567
this . client as any ,
568
- environment === 'test' ? 200 : 2000 ,
568
+ 500 ,
569
569
) ;
570
570
this . slidingSync . on (
571
571
SlidingSyncEvent . Lifecycle ,
@@ -1224,7 +1224,7 @@ export default class MatrixService extends Service {
1224
1224
return await this . client . isUsernameAvailable ( username ) ;
1225
1225
}
1226
1226
1227
- private loadAllTimelineEvents = restartableTask ( async ( roomId : string ) => {
1227
+ private loadAllTimelineEvents = dropTask ( async ( roomId : string ) => {
1228
1228
let roomData = this . ensureRoomData ( roomId ) ;
1229
1229
let room = this . client . getRoom ( roomId ) ;
1230
1230
let roomResource = this . roomResources . get ( roomId ) ;
@@ -1669,8 +1669,12 @@ export default class MatrixService extends Service {
1669
1669
this . loadMoreAIRoomsTask . perform ( ) ;
1670
1670
}
1671
1671
1672
- private loadMoreAIRoomsTask = restartableTask ( async ( ) => {
1673
- if ( ! this . slidingSync ) return ;
1672
+ private loadMoreAIRoomsTask = dropTask ( async ( ) => {
1673
+ if ( ! this . slidingSync ) {
1674
+ throw new Error (
1675
+ 'To load more AI rooms, sliding sync must be initialized' ,
1676
+ ) ;
1677
+ }
1674
1678
1675
1679
let currentList = this . slidingSync . getListParams (
1676
1680
SLIDING_SYNC_AI_ROOM_LIST_NAME ,
@@ -1686,22 +1690,26 @@ export default class MatrixService extends Service {
1686
1690
1687
1691
let newEndRange = currentRange [ 1 ] + 10 ;
1688
1692
1689
- this . isLoadingMoreAIRooms = true ;
1693
+ this . _isLoadingMoreAIRooms = true ;
1690
1694
try {
1691
1695
await this . slidingSync . setListRanges ( SLIDING_SYNC_AI_ROOM_LIST_NAME , [
1692
1696
[ 0 , newEndRange ] ,
1693
1697
] ) ;
1694
1698
} finally {
1695
- this . isLoadingMoreAIRooms = false ;
1699
+ this . _isLoadingMoreAIRooms = false ;
1696
1700
}
1697
1701
} ) ;
1698
1702
1699
- get loadingMoreAIRooms ( ) {
1700
- return this . isLoadingMoreAIRooms ;
1703
+ get isLoadingMoreAIRooms ( ) {
1704
+ return this . _isLoadingMoreAIRooms ;
1701
1705
}
1702
1706
1703
1707
async loadMoreAuthRooms ( realms : string [ ] ) {
1704
- if ( ! this . slidingSync ) return ;
1708
+ if ( ! this . slidingSync ) {
1709
+ throw new Error (
1710
+ 'To load more auth rooms, sliding sync must be initialized' ,
1711
+ ) ;
1712
+ }
1705
1713
1706
1714
let currentList = this . slidingSync . getListParams (
1707
1715
SLIDING_SYNC_AUTH_ROOM_LIST_NAME ,
0 commit comments