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 827
Improve RoomList performance via side-stepping React #807
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0a91511
cmd-k for quick search
ara4n 691639d
track RoomTile focus in RoomList, and stop the RoomList from updating…
ara4n da569c2
add constantTimeDispatcher and use it for strategic refreshes.
ara4n 9591ad3
fix bugs, experiment with focus pulling, make it vaguely work
ara4n 4fb9635
nudge focus shortcut code further to working
ara4n 062963b
move focus-via-up/down cursors to LeftPanel
ara4n c1c3956
fix bugs, and handle shortcircuit react when updating roomtile
ara4n 015a448
oops, wire up Room.receipt again, and refresh roomtiles on Room.timeline
ara4n 8389a67
we don't need RoomTile specific focus in the end
ara4n 093b9a0
kick the roomtile on RoomState.members
ara4n abf2300
highlight invites correctly
ara4n 4a9c168
fix invite highlights
ara4n fb6252a
fix invite highlights take 3
ara4n 9f99224
fix bugs from PR review
ara4n 8da0774
bump react-gemini-scrollbar
ara4n 90f526b
autofocus doesn't seem to work on this button
ara4n 5a3b4b6
various bug fixes:
ara4n 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
Copyright 2017 Vector Creations Ltd | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
// singleton which dispatches invocations of a given type & argument | ||
// rather than just a type (as per EventEmitter and Flux's dispatcher etc) | ||
// | ||
// This means you can have a single point which listens for an EventEmitter event | ||
// and then dispatches out to one of thousands of RoomTiles (for instance) rather than | ||
// having each RoomTile register for the EventEmitter event and having to | ||
// iterate over all of them. | ||
class ConstantTimeDispatcher { | ||
constructor() { | ||
// type -> arg -> [ listener(arg, params) ] | ||
this.listeners = {}; | ||
} | ||
|
||
register(type, arg, listener) { | ||
if (!this.listeners[type]) this.listeners[type] = {}; | ||
if (!this.listeners[type][arg]) this.listeners[type][arg] = []; | ||
this.listeners[type][arg].push(listener); | ||
} | ||
|
||
unregister(type, arg, listener) { | ||
if (this.listeners[type] && this.listeners[type][arg]) { | ||
var i = this.listeners[type][arg].indexOf(listener); | ||
if (i > -1) { | ||
this.listeners[type][arg].splice(i, 1); | ||
} | ||
} | ||
else { | ||
console.warn("Unregistering unrecognised listener (type=" + type + ", arg=" + arg + ")"); | ||
} | ||
} | ||
|
||
dispatch(type, arg, params) { | ||
if (!this.listeners[type] || !this.listeners[type][arg]) { | ||
console.warn("No registered listeners for dispatch (type=" + type + ", arg=" + arg + ")"); | ||
return; | ||
} | ||
this.listeners[type][arg].forEach(listener=>{ | ||
listener.call(arg, params); | ||
}); | ||
} | ||
} | ||
|
||
if (!global.constantTimeDispatcher) { | ||
global.constantTimeDispatcher = new ConstantTimeDispatcher(); | ||
} | ||
module.exports = global.constantTimeDispatcher; |
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 |
---|---|---|
|
@@ -32,4 +32,5 @@ module.exports = { | |
DELETE: 46, | ||
KEY_D: 68, | ||
KEY_E: 69, | ||
KEY_K: 75, | ||
}; |
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
Oops, something went wrong.
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.
What makes
ConstantTimeDispatcher
different from just using the type and arg as the key name? E.g:From what I can see, there is no difference at all other than sugar coating and not needing to decide on a suitable delimiter (
" "
in this case). If you want to be pedantic,unregister
operations are more expensive inConstantTimeDispatcher
because it requires you to loop over all the listeners for a giventype
, whereas theEventEmitter
form is just a hash lookup.I'd rather we didn't re-invent the wheel on this.
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.
Answer: CTD actually exposes an API with the right shape & (in future) typing rather than relying on the kludge of concatenating the keys into the event type. Also, we're not using EventEmitter anywhere in matrix-react-sdk (or riot-web) yet, other than receiving events from matrix-js-sdk, so if we're adding a new dispatcher it might as well be CTD as much as EventEmitter.
That said, I'd be happy if CTD became an API facade for EventEmitter in future - or if we skipped it entirely in favour of some other dispatch mechanism in future; see comments below...