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
Control currently viewed event via RoomViewStore #1058
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
d3cf78f
Control currently viewied event via RoomViewStore
f320f7d
Remove redundant action id
ea97d16
Merge branch 'develop' into luke/fix-event-id-state
aa20ad7
Remove redundant `currentRoomAlias`
8ddc38c
Doc _viewRoom highlighted
2e82bf4
Explain setting of highlighted in room/$eventId showScreen handling.
dca2be6
Add RoomView initial state and docs
e58e4db
Explain why search results are cleared when eventId changes
59e649f
Add comment about roomId potentially not being resolved following an …
1792fa4
Null-guard roomId before sending a dispatch to update scroll state
000a045
Rename RVS state (event -> initialEvent) and redocument
36f72cc
Don't alter members of payload (when defaulting an event to scroll to…
1ff2be1
Update docs for RVS
c02dbd1
Rename initial state variables
8cfdb4c
Clarify initial event
cd8093d
Explicit undefined initialEventPixelOffset
c72edab
Update doc for getInitialEventId
9892566
Highlighted means highlighted
5588e11
Clarify doc for highlighted
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 |
---|---|---|
|
@@ -607,6 +607,8 @@ module.exports = React.createClass({ | |
// @param {boolean=} roomInfo.show_settings Makes RoomView show the room settings dialog. | ||
// @param {string=} roomInfo.event_id ID of the event in this room to show: this will cause a switch to the | ||
// context of that particular event. | ||
// @param {boolean=} roomInfo.highlighted If true, add event_id to the hash of the URL | ||
// and alter the EventTile to appear highlighted. | ||
// @param {Object=} roomInfo.third_party_invite Object containing data about the third party | ||
// we received to join the room, if any. | ||
// @param {string=} roomInfo.third_party_invite.inviteSignUrl 3pid invite sign URL | ||
|
@@ -618,40 +620,20 @@ module.exports = React.createClass({ | |
this.focusComposer = true; | ||
|
||
const newState = { | ||
initialEventId: roomInfo.event_id, | ||
highlightedEventId: roomInfo.event_id, | ||
initialEventPixelOffset: undefined, | ||
page_type: PageTypes.RoomView, | ||
thirdPartyInvite: roomInfo.third_party_invite, | ||
roomOobData: roomInfo.oob_data, | ||
currentRoomAlias: roomInfo.room_alias, | ||
autoJoin: roomInfo.auto_join, | ||
}; | ||
|
||
if (!roomInfo.room_alias) { | ||
newState.currentRoomId = roomInfo.room_id; | ||
} | ||
|
||
// if we aren't given an explicit event id, look for one in the | ||
// scrollStateMap. | ||
// | ||
// TODO: do this in RoomView rather than here | ||
if (!roomInfo.event_id && this.refs.loggedInView) { | ||
const scrollState = this.refs.loggedInView.getScrollStateForRoom(roomInfo.room_id); | ||
if (scrollState) { | ||
newState.initialEventId = scrollState.focussedEvent; | ||
newState.initialEventPixelOffset = scrollState.pixelOffset; | ||
} | ||
} | ||
|
||
if (roomInfo.room_alias) { | ||
console.log( | ||
`Switching to room alias ${roomInfo.room_alias} at event ` + | ||
newState.initialEventId, | ||
roomInfo.event_id, | ||
); | ||
} else { | ||
console.log(`Switching to room id ${roomInfo.room_id} at event ` + | ||
newState.initialEventId, | ||
roomInfo.event_id, | ||
); | ||
} | ||
|
||
|
@@ -680,7 +662,7 @@ module.exports = React.createClass({ | |
} | ||
} | ||
|
||
if (roomInfo.event_id) { | ||
if (roomInfo.event_id && roomInfo.highlighted) { | ||
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. can you add this to the jsdoc please |
||
presentedId += "/" + roomInfo.event_id; | ||
} | ||
this.notifyNewScreen('room/' + presentedId); | ||
|
@@ -1137,6 +1119,10 @@ module.exports = React.createClass({ | |
const payload = { | ||
action: 'view_room', | ||
event_id: eventId, | ||
// If an event ID is given in the URL hash, notify RoomViewStore to mark | ||
// it as highlighted, which will propagate to RoomView and highlight the | ||
// associated EventTile. | ||
highlighted: Boolean(eventId), | ||
third_party_invite: thirdPartyInvite, | ||
oob_data: oobData, | ||
}; | ||
|
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.
surely it means way more than that? like, the event will also be highlighted in the view.
Bear in mind this is documenting the parameters on the view_room more than the parameters to the function - the docs just got left behind when view_room started going to more places :/
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.
I don't think we should document things that happen elsewhere. If someone wants to know what the
view_room
dispatch does, they should look for all the things that receive it (namely, RoomViewStore).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.
I'm not convinced by that. The
view_room
dispatch is an API, like any other. You don't refuse to document your methods and say "look at these other methods which I call". I want to know: what does it mean, conceptually, to set the 'highlighted' param in a view_room dispatch. I don't think at its heart it means 'add the event_id' to the location bar.There's a (very strong) argument that this is not the place for that documentation, but we have nowhere else right now.
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.
OK, but I feel that someone is going to get confused when the documentation for this function doesn't match what the function does.