This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 832
Display whether the group summary/room list is loading #1560
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
775468e
Display whether the group summary/room list is loading
45e15fd
Merge branch 'develop' into luke/groups-expose-ready-state
lukebarnard1 d6cbc44
If groupRoomsLoading, replace RoomDetailList entirely with Spinner
5bfed67
Merge branch 'luke/groups-expose-ready-state' of github.com:matrix-or…
16dca08
Use constants instead of string literals
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,9 @@ export default class GroupStore extends EventEmitter { | |
this._matrixClient = matrixClient; | ||
this._summary = {}; | ||
this._rooms = []; | ||
this._members = []; | ||
this._invitedMembers = []; | ||
this._ready = {}; | ||
|
||
this.on('error', (err) => { | ||
console.error(`GroupStore for ${this.groupId} encountered error`, err); | ||
|
@@ -40,6 +43,7 @@ export default class GroupStore extends EventEmitter { | |
this._members = result.chunk.map((apiMember) => { | ||
return groupMemberFromApiObject(apiMember); | ||
}); | ||
this._ready['GroupStore.GroupMembers'] = true; | ||
this._notifyListeners(); | ||
}).catch((err) => { | ||
console.error("Failed to get group member list: " + err); | ||
|
@@ -50,6 +54,7 @@ export default class GroupStore extends EventEmitter { | |
this._invitedMembers = result.chunk.map((apiMember) => { | ||
return groupMemberFromApiObject(apiMember); | ||
}); | ||
this._ready['GroupStore.GroupInvitedMembers'] = true; | ||
this._notifyListeners(); | ||
}).catch((err) => { | ||
// Invited users not visible to non-members | ||
|
@@ -64,6 +69,7 @@ export default class GroupStore extends EventEmitter { | |
_fetchSummary() { | ||
this._matrixClient.getGroupSummary(this.groupId).then((resp) => { | ||
this._summary = resp; | ||
this._ready['GroupStore.Summary'] = true; | ||
this._notifyListeners(); | ||
}).catch((err) => { | ||
this.emit('error', err); | ||
|
@@ -75,6 +81,7 @@ export default class GroupStore extends EventEmitter { | |
this._rooms = resp.chunk.map((apiRoom) => { | ||
return groupRoomFromApiObject(apiRoom); | ||
}); | ||
this._ready['GroupStore.GroupRooms'] = true; | ||
this._notifyListeners(); | ||
}).catch((err) => { | ||
this.emit('error', err); | ||
|
@@ -87,6 +94,8 @@ export default class GroupStore extends EventEmitter { | |
|
||
registerListener(fn) { | ||
this.on('update', fn); | ||
// Call to set initial state (before fetching starts) | ||
this.emit('update'); | ||
this._fetchSummary(); | ||
this._fetchRooms(); | ||
this._fetchMembers(); | ||
|
@@ -96,6 +105,10 @@ export default class GroupStore extends EventEmitter { | |
this.removeListener('update', fn); | ||
} | ||
|
||
isStateReady(id) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is quite nice but I feel like we now need to doc what string values are acceptable to it. How about defining some constants on the GroupStore class and and using these instead? |
||
return this._ready[id]; | ||
} | ||
|
||
getSummary() { | ||
return this._summary; | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for passing this into
RoomDetailList
and letting it deal with the loading state rather than just showing a spinner in lieu of it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, TBH. Happy do to the simpler thing of replacing it entirely with a spinner.