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

Introduce lazy loading #88

Merged
merged 16 commits into from
Apr 19, 2017

Conversation

daniellandau
Copy link
Member

This is related to #12

@eppfel eppfel added 3. to review Waiting for reviews enhancement New feature or request labels Jan 8, 2017
@eppfel
Copy link
Member

eppfel commented Jan 8, 2017

Thanks, for that detailed work. I would move the detailed explanation here, because you not only explain the problem, but also your solution.

I ping @nextcloud/contacts @ChristophWurst for review!

Copy link
Member

@skjnldsv skjnldsv left a comment

Choose a reason for hiding this comment

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

Amazing work! It was next on my todo list! 🎉
I will review it deeply as soon as possible!

@@ -1 +1 @@
<a ng-href="#/{{ctrl.group}}">{{ctrl.group}}</a>
<a ng-href="#/{{ctrl.group}}">{{ctrl.group}} ({{ctrl.groupCount}})</a>
Copy link
Member

Choose a reason for hiding this comment

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

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.

@@ -0,0 +1,12 @@
// from https://docs.nextcloud.com/server/11/developer_manual/app/css.html#menus
angular.module('contactsApp')
Copy link
Member

Choose a reason for hiding this comment

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

Please add tests (seehttps://github.com/owncloud/contacts/blob/31e403af1db859f85e84c2337134e20e5719c825/js/tests/filters/counterFormatter_filter.js)

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.

@@ -1 +1 @@
<a ng-href="#/{{ctrl.group}}">{{ctrl.group}} ({{ctrl.groupCount}})</a>
<a ng-href="#/{{ctrl.group}}">{{ ctrl.group }} ({{ ctrl.groupCount | counterFormatter }})</a>
Copy link
Member

Choose a reason for hiding this comment

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

Better, but you need to use the li element
<li class="app-navigation-entry-utils-counter">{{ count | counterFormatter }}</li>

capture d ecran_2017-01-08_17-43-40

Copy link
Member Author

Choose a reason for hiding this comment

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

In order to get right-aligning instead of parentheses I gather. Sure thing, fixed.

@@ -1 +1 @@
<li ng-repeat="group in ctrl.groups" group data="group" ng-click="ctrl.setSelected(group)" ng-class="{active: group === ctrl.getSelected}"></li>
<li ng-repeat="group in ctrl.groups" group group-name="group[0]" group-count="group[1]" ng-click="ctrl.setSelected(group[0])" ng-class="{active: group[0] === ctrl.getSelected}"></li>
Copy link
Member

Choose a reason for hiding this comment

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

you could do something like <li ng-repeat="(group, count) in ctrl.groups" group data="group" count="count" ng-click="ctrl.setSelected(group)" ng-class="{active: group === ctrl.getSelected}"></li> for better readibility :)

See my previous work: https://github.com/owncloud/contacts/pull/341/files

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, did not know that Angular does list destructuring, will fix.

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, it seems that that syntax is only used for going through the keys and values in an object.

Copy link
Member

Choose a reason for hiding this comment

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

Isn't there an alternative?

Copy link
Member Author

Choose a reason for hiding this comment

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

The order of keys in an object is arbitrary, so I don't want to have the whole ctrl.groups be an object. We want to guarantee All Contacts is first.

Copy link
Member

Choose a reason for hiding this comment

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

Too bad, it would have been great to improve the readability. But it's clearly not that important :)

ctrl.setSelectedId(ctrl.contactList[0].uid());
}
var firstNames = ctrl.contactList.slice(0, 20).map(function (c) { return c.displayName(); });
ContactService.getFullContacts(firstNames);
Copy link
Member

Choose a reason for hiding this comment

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

We still don't want to load the first contact in mobile mode.
We need a condition to prevent that like we had before ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

We now never blindly load the first contact, so not on mobile either.

Copy link
Member

Choose a reason for hiding this comment

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

By selecting the first uid after load, we display the first contact.
In mobile, since the list view and detail views are split, we need to stay on the contact list only. :)

Copy link
Member Author

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 are selecting the first uid at all. I tested with both a responsive design mode and an actual mobile browser.

Copy link
Member

@skjnldsv skjnldsv Jan 8, 2017

Choose a reason for hiding this comment

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

So the right app panel is blank on your contact installation? On fresh click of your.domain/index.php/apps/contacts, the app doesn't load a contact?

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly.

Copy link
Member

@skjnldsv skjnldsv Jan 8, 2017

Choose a reason for hiding this comment

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

Strange, it changes the url with an uid and then load a contact in my installation.
Anyway, we need to keep the old mechanic in place.

  1. If mobile, do not load contact details and stay on the contacts list EXCEPT if there is a matching uid specified in the url
  2. If not in mobile, load the first contact

Edit: error in my environment. It doesn't load a thing indeed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, added that back in. It adds ~400 ms rendering time, but in the scheme of things that's probably fine.

Copy link
Member

Choose a reason for hiding this comment

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

You're awesome! :)

@skjnldsv
Copy link
Member

skjnldsv commented Jan 8, 2017

If no contacts, I get errors on the console:

Uncaught TypeError: Cannot read property 'length' of undefined
    at contactList_controller.js:22
  • TODO: fix if no contacts

@daniellandau
Copy link
Member Author

I added a defense in contactList_controller.

@skjnldsv skjnldsv added this to the 1.5.3 milestone Jan 8, 2017
} else {
// custom console
// eslint-disable-next-line no-console
Copy link
Member

Choose a reason for hiding this comment

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

Nice! 😆

@daniellandau
Copy link
Member Author

@skjnldsv did you want me to still do things? Like rebase with signed off commits?

@skjnldsv
Copy link
Member

Not really. But we need to wait for the 3rdparty patch/sabre release.

@skjnldsv skjnldsv removed this from the 1.5.3 milestone Jan 17, 2017
@skjnldsv skjnldsv added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Jan 23, 2017
@jancborchardt
Copy link
Member

Any idea when this sabre patch release is coming? cc @evert

@daniellandau
Copy link
Member Author

I don't know. I asked on their IRC channel a couple of weeks ago and got no reply. I asked two days ago on Github (https://github.com/fruux/sabre-dav/issues/936), but haven't gotten any reply yet.

@Henni
Copy link
Member

Henni commented Jan 24, 2017

I'd suggest to split this up into two separate pull requests:

  • one for the the partial carddav requests, which is blocked by sabre-dav
  • and another one which loads the contacts list piece by piece

I'd like to merge the second one as soon as possible, because it might introduce a nice performance improvement and also to reduce merge conflicts in the future.

@daniellandau what do you think about this? would you do the job of splitting this PR up?

@daniellandau
Copy link
Member Author

Do you mean as the second part the thing that renders the contact list piece by piece? I'd rather just merge the sabre-dav patch and merge this whole thing. All in all that would be much less maintenance work in my opinion, and the sabre-dav patch is merged in all branches upstream, so it shouldn't cause conflicts or problems later on either.

@Henni
Copy link
Member

Henni commented Jan 24, 2017

@daniellandau shouldn't cause any conflicts. But I also understand that the guys over at nextcloud/server don't want to patch anything unreleased into their 3rdparty repo.

Let's wait a bit longer for a response by sabre/dav.

@daniellandau
Copy link
Member Author

Just a quick update, the sabre/dav release has come, and the current PR on 3rdparty is nextcloud/3rdparty#40

Signed-off-by: Daniel Landau <daniel@landau.fi>
Signed-off-by: Daniel Landau <daniel@landau.fi>
It's a really heavy operation that hangs the browser

Signed-off-by: Daniel Landau <daniel@landau.fi>
If we render the whole thing at once, the browser hangs. This way we can
render the beginning of the list and the user can start to either scroll
or search for better results.

Signed-off-by: Daniel Landau <daniel@landau.fi>
Signed-off-by: Daniel Landau <daniel@landau.fi>
This requires an updated SabreDav in core. The contents of address-data
are ignored before https://github.com/fruux/sabre-dav/issues/889

Signed-off-by: Daniel Landau <daniel@landau.fi>
Signed-off-by: Daniel Landau <daniel@landau.fi>
Signed-off-by: Daniel Landau <daniel@landau.fi>
Signed-off-by: Daniel Landau <daniel@landau.fi>
This is to ensure that they really are loaded when changeContact is run

Signed-off-by: Daniel Landau <daniel@landau.fi>
Signed-off-by: Daniel Landau <daniel@landau.fi>
Signed-off-by: Daniel Landau <daniel@landau.fi>
Signed-off-by: Daniel Landau <daniel@landau.fi>
Signed-off-by: Daniel Landau <daniel@landau.fi>
Signed-off-by: Daniel Landau <daniel@landau.fi>
Signed-off-by: Daniel Landau <daniel@landau.fi>
@daniellandau daniellandau force-pushed the introduce-lazy-loading branch from a5b210b to e628a73 Compare March 16, 2017 20:12
@daniellandau
Copy link
Member Author

I rebased the PR to current master, ping @skjnldsv.

@codecov-io
Copy link

codecov-io commented Mar 17, 2017

Codecov Report

Merging #88 into master will decrease coverage by 0.53%.
The diff coverage is 6.45%.

@@            Coverage Diff             @@
##           master      #88      +/-   ##
==========================================
- Coverage   16.42%   15.89%   -0.54%     
==========================================
  Files          50       51       +1     
  Lines        1023     1095      +72     
==========================================
+ Hits          168      174       +6     
- Misses        855      921      +66
Impacted Files Coverage Δ
js/components/group/group_directive.js 50% <ø> (ø)
js/models/contact_model.js 40.6% <ø> (ø)
...ts/newContactButton/newContactButton_controller.js 8.33% <0%> (ø)
js/services/contact_service.js 0.74% <0%> (-0.27%)
...onents/contactDetails/contactDetails_controller.js 2% <0%> (ø)
js/components/groupList/groupList_controller.js 6.66% <0%> (ø)
js/filters/counterFormatter_filter.js 100% <100%> (ø)
...s/components/contactList/contactList_controller.js 1.76% <2.94%> (+0.55%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2692185...e628a73. Read the comment docs.

@irgendwie
Copy link
Member

If I'm not mistaken, the REPORT functionality (https://github.com/fruux/sabre-dav/issues/889) is only included starting from sabre-dav 3.0.10 (https://github.com/fruux/sabre-dav/blob/master/CHANGELOG.md#3010-2016--) which isn't released (by now?) and only sabre-dav 3.2.1 (https://github.com/fruux/sabre-dav/blob/master/CHANGELOG.md#321-2017-01-28) seems to support the REPORT functionality .

sabre-dav in Nextcloud 9 was only bumped to sabre-dav 3.0.9 (https://github.com/nextcloud/3rdparty/tree/stable9/sabre), which means we wouldn't support Nextcloud 9 anymore by now.

And sabre-dav in Nextcloud 10 was also only bumped to sabre-dav 3.0.9 (https://github.com/nextcloud/3rdparty/tree/stable10/sabre), which also means no support for Nextcloud 10 anymore by now.

And sabre-dav in Nextcloud 11 was also only bumped to sabre-dav 3.2.0 (https://github.com/nextcloud/3rdparty/tree/stable11/sabre), which also means no support for Nextcloud 11 anymore by now.

👎 I'm not willing to merge this PR into the master branch, which would basically mean that the next version of contacts would only be compatible with Nextcloud 12.
We need a solution for this, before we merge this.

---> After some testing, if the REPORT feature is not supported, it still seems to work (requested properties are ignored?)

@daniellandau
Copy link
Member Author

---> After some testing, if the REPORT feature is not supported, it still seems to work (requested properties are ignored?)

Yes, the properties are simply ignored. There's some extra network traffic when the browsers asks for the visible cards again (as they are already fully downloaded in the beginning).

@jancborchardt
Copy link
Member

@LukasReschke @MorrisJobke care to check this out? :) Would be great to get your opinion on this.

@MorrisJobke
Copy link
Member

@LukasReschke @MorrisJobke care to check this out? :) Would be great to get your opinion on this.

Sadly I don't have time for this :/

@jancborchardt
Copy link
Member

Anyone else who can help here? @rullzer @schiessle @nickvergessen @georgehrke

@irgendwie irgendwie merged commit daece9d into nextcloud:master Apr 19, 2017
@skjnldsv
Copy link
Member

🎉

@skjnldsv skjnldsv added 4. to release Ready to be released and/or waiting for tests to finish and removed 2. developing Work in progress labels Apr 19, 2017
@jancborchardt
Copy link
Member

Great work everyone! :)

@timreeves
Copy link

Does "renders the contact list piece by piece" translate to "infinite scrolling", 'cos that would be really great. I have 4 adress books shared with different people, totalling around 1300 contacts, and the load time is lousy, even on a fast linux PC with fast cable internet. It would be great, really great, if I could select which of the adress books should be displayed (BEFORE they are) - I would have thought that an elementary feature.

And a client of mine uploaded about 15.000 contacts to one adress book; since then it has been unusable and would have to be deleted manually from the DB (igitt).

So yes, infinite scrolling / lazy loading or whatever we call it would imho be neccessary for professional use. Or even/also the possibility to limit the display to first name / last name beginning with...

Many thanks to all working on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants