Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#7469 - stop ignoring from hovercards #7748

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

lu-x
Copy link

@lu-x lu-x commented Mar 25, 2018

No description provided.

@lu-x lu-x force-pushed the 7469-stop-ignoring-for-hovercards branch 2 times, most recently from caccb63 to 3d954c4 Compare March 25, 2018 17:22
@lu-x lu-x changed the title #7469 - stop ignoring for hovercards #7469 - stop ignoring for hovercards (wip) Mar 25, 2018
@lu-x lu-x force-pushed the 7469-stop-ignoring-for-hovercards branch 2 times, most recently from b0da839 to 7b2f271 Compare March 26, 2018 18:30
@lu-x
Copy link
Author

lu-x commented Mar 26, 2018

@Flaburgan I pushed my first try. Tests are still missing. I'll add them later.

@lu-x lu-x force-pushed the 7469-stop-ignoring-for-hovercards branch from 7b2f271 to a2c5b2b Compare March 31, 2018 12:43
status: 200,
responseText: JSON.stringify({id: 1337, block: {id: 5}})
});
expect(this.view.aspectDropdownOrUnblock.templateName).toEqual('unblock_person');

Choose a reason for hiding this comment

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

Strings must use doublequote.

@lu-x lu-x changed the title #7469 - stop ignoring for hovercards (wip) #7469 - stop ignoring for hovercards Mar 31, 2018
@lu-x lu-x force-pushed the 7469-stop-ignoring-for-hovercards branch from a2c5b2b to 592b1de Compare March 31, 2018 12:46
@lu-x
Copy link
Author

lu-x commented Mar 31, 2018

I updated the specs. Ready for some reviewing.

Copy link
Member

@SuperTux88 SuperTux88 left a comment

Choose a reason for hiding this comment

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

Thanks for your PR, I tested it locally, but I found a problem. In some cases the hovercard doesn't reload properly (see comment below), also it would be cool to have some more tests for this.

block.fail(function() {
app.flashMessages.error(Diaspora.I18.t("unblock_failed"));
});
this.parent._populateHovercard();
Copy link
Member

Choose a reason for hiding this comment

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

There is a race-condition with this. The unblock happens in parallel with the reload, so when the reload reloads the hovercard.json before the unblock is persisted, the hovercard is stuck in an inconsistent state (happens in about 50% of my tries):

image

There is an event triggered when the unblock is done, see:

app.events.on("person:unblock:"+id, this.reload, this);

Maybe you can do it similar?

@lu-x lu-x force-pushed the 7469-stop-ignoring-for-hovercards branch from 592b1de to a271616 Compare April 21, 2018 14:49
@lu-x
Copy link
Author

lu-x commented Apr 21, 2018

I tried something like app.events.on("person:unblock:" + id, this.parent.reload, this); in the unblock person view. But somehow the event action always triggers on initialization and therefore caused an endless loop.
I now do the refresh, if the unblocking is done.

@SuperTux88
Copy link
Member

Thanks for the update and sorry for the slow response.

I tried something like app.events.on("person:unblock:" + id, this.parent.reload, this); in the unblock person view.

It works for me with app.events.on("person:unblock:" + this.person.id, this.parent._populateHovercard, this.parent);, however the event is added everytime the hovercard opens, so when you open/close it multiple times before clicking the button, the hovercard is reloaded multiple times afterwards (not visible, but there are multiple requests visible in the dev-tools). So the event should be removed again when the hovercard is closed, so there is only one event.

However your current solution seems to work too, but I don't know which is the cleaner solution. I'm not a frontend guy and this is becoming to much javascript for my knowledge. Hopefully somebody with more JS knowhow can review the PR and tell if the current solution is OK to merge.

@SuperTux88 SuperTux88 dismissed their stale review May 15, 2018 23:03

See above.

});

unblock.done(function() {
that.parent._populateHovercard();
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that this method is called outside of the class it should probably drop the leading underscore since it is no longer private use. The method itself assumes that parent has been set with a parent that has the href attr which is only true if the parent used already went through the showHovercardOn: _.debounce path. It seems any time someone would use it that it would have been through that path already but if want to do some more defensive programming could catch/check that too perhaps.

@HankG
Copy link
Contributor

HankG commented Nov 1, 2018

Not a core member but think this looks pretty good. It works well in the browser in testing on my instance too. I had a comment on the formerly "private" member. I know the name should change but not sure if we need to cover case where it is invoked before the card is shown (which triggers the event that populates the parent of the hovercard).

Copy link
Member

@denschub denschub left a comment

Choose a reason for hiding this comment

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

See previous comment.

@Flaburgan Flaburgan changed the title #7469 - stop ignoring for hovercards #7469 - stop ignoring from hovercards Apr 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants