Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

T3chguy/hide join part (attempt) 2 #1243

Merged
merged 28 commits into from
Jul 26, 2017
Merged

Conversation

t3chguy
Copy link
Member

@t3chguy t3chguy commented Jul 21, 2017

Ignore for now, using to easier follow Jenkins because tests never seem to fail on my Windows machines...

Replaces #1104 - Maybe... Diff seems near-identical

kegsay and others added 9 commits May 31, 2017 13:36
- Doesn't work with MELS
- Doesn't work with read markers
- Doesn't work with jumping to events

Shelving this for now as I fix some of this mess.
…rix-org/matrix-react-sdk into kegan/hide-join-part

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

# Conflicts:
#	src/components/structures/UserSettings.js
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
@matrixbot
Copy link
Member

Can one of the admins verify this patch?

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
@t3chguy t3chguy changed the base branch from master to develop July 21, 2017 18:35
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
this is needed so that if a client which does not hide any events
sets and RM at bottom of timeline, then riot-web which hides events
sets the RM it'd set it at X-N where X is bottom and N is the amount of
hidden events at bottom of the timeline, this way now an RM will
fall through to the hidden events below a seen event.

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
@t3chguy
Copy link
Member Author

t3chguy commented Jul 22, 2017

Does not fix the broken visible var hoisting luke verified, that'll need to be done in another PR

@t3chguy t3chguy mentioned this pull request Jul 22, 2017
// of MemberEventListSummary, render each member event as if the previous
// one was itself. This way, the timestamp of the previous event === the
// timestamp of the current event, and no DateSeperator is inserted.
const ret = this._getTilesForEvent(e, e, last);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it OK if last is not computed for e but instead for the first event in the MELS?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that change was Kegan's - fc93517#diff-dbc0a683dd11c32adf8c9532eb9ebb27R386
I'll figure out why its needed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would guess that it's needed for when you've expanded the MELS at the front of the timeline, (i.e. the most recent events are member events) and the last event should be indicated with last=true but last is calculated with i where i is the index of the first event in the MELS. I think last should be recalculated for each event in the summary (so within the inner for that iterates i).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't do it within that for-loop because it doesn't use the last value, the map afterwards does, so it'd set the last value to the same for all events in MELS as the last event in the MELS

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

best way I can see is changing it from lastShownEventIndex to lastShownEvent and then just checking it against the event itself, other way is to recalculate last inside that interior for loop and then if last && index === summarisedEvents.length - 1 (where index is the index passed to the mapper function)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ended up implementing in the former manner:
image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(memory pointer check)

@@ -1023,7 +1020,14 @@ var TimelinePanel = React.createClass({
var boundingRect = node.getBoundingClientRect();
if ((allowPartial && boundingRect.top < wrapperRect.bottom) ||
(!allowPartial && boundingRect.bottom < wrapperRect.bottom)) {
return i;
let latestReadEventIndex = i;
// Place the RM at a hidden event below the latest seen event (if exists)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: if it exists

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this is confusing, the event is just the latest read visible event... event (if exists) should be probably be visible event

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}

// this only applies to joins/leaves not invites/kicks/bans
return membership === 'join' || (membership === 'leave' && ev.getStateKey() === ev.getSender());
Copy link
Contributor

@lukebarnard1 lukebarnard1 Jul 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about unbans and invites? An unban = ban to join, invite acception = invite to join?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/me votes for a helper in js-sdk to figure out what a member event does...

Copy link
Contributor

@lukebarnard1 lukebarnard1 Jul 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Different apps may feel differently about how to group certain events and hiding joins/parts is a good example of how an app treats fairly arbitrary events specially.

Anyway, either the logic or the comment above needs to change; if the intention is to return true for accepting invites (type of join) and being unbanned (type of join), then this should be mentioned in the comment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by helper I meant a thing that took an event and spat out an enum val describing its effect 'ban'/'kick'/'unban'/'leave'/'join' etc

return membership === 'join' || (membership === 'leave' && ev.getStateKey() === ev.getSender());
}

export default function(ev, syncedSettings) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just import UserSettingsStore here instead of importing it in the files that use shouldHideEvent?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #1104 (comment)
plus getSyncedSettings has to json parse so doing it once per event is nasty.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough!

do not have the same i reference (namely MELS generation)
this way a member event at bottom of MELS (if is the last event
in the timeline will have last set appropriately)
@t3chguy
Copy link
Member Author

t3chguy commented Jul 26, 2017

I believe that is everything in Luke's review done

// this only applies to joins/leaves not invites/kicks/bans
return membership === 'join' || (membership === 'leave' && ev.getStateKey() === ev.getSender());
const isJoin = membership === 'join' && prevMembership !== 'ban';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be true if prevMembership is invite, so if the intention is to return true for invitation acceptations, then the comment above needs to be updated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated comment @lukebarnard1

@@ -1021,7 +1021,7 @@ var TimelinePanel = React.createClass({
if ((allowPartial && boundingRect.top < wrapperRect.bottom) ||
(!allowPartial && boundingRect.bottom < wrapperRect.bottom)) {
let latestReadEventIndex = i;
// Place the RM at a hidden event below the latest seen event (if exists)
// Place the RM at a hidden event below the latest visible event.
// to prevent RM going up the timeline between clients which do not hide the same events.
for (let j = i + 1; j < this.state.events.length; j++) {
if (messagePanel._shouldShowEvent(this.state.events[j])) break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We never check if i itself is visible, if it is surely we can return i immediately? In other words, let j = i;.

Copy link
Member Author

@t3chguy t3chguy Jul 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we know i is visible because its in the DOM
we want the last non-visible event to put the rm on
(last non-visible but still before the next visible, so it trickles down the timeline)

@@ -1021,7 +1021,7 @@ var TimelinePanel = React.createClass({
if ((allowPartial && boundingRect.top < wrapperRect.bottom) ||
(!allowPartial && boundingRect.bottom < wrapperRect.bottom)) {
let latestReadEventIndex = i;
// Place the RM at a hidden event below the latest seen event (if exists)
// Place the RM at a hidden event below the latest visible event.
// to prevent RM going up the timeline between clients which do not hide the same events.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wording still seems confusing. How about something like "if the RM is on an event that is not visible, find the first event that is visible and place the RM on the event before it."

@lukebarnard1 lukebarnard1 merged commit c4f049e into develop Jul 26, 2017
@t3chguy t3chguy deleted the t3chguy/hide-join-part-2 branch December 8, 2017 21:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants