diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a73987c1..17b96cfd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ v0.20 (trunk) * Remove the old API code * Add support of XEP-0393: Message Styling * Add a BundleCapabilityResolver to link OMEMO bundles with the capability/info table +* Add pagination for Pictures and Links in the ContactDrawer v0.19 --------------------------- diff --git a/app/widgets/ContactActions/ContactActions.php b/app/widgets/ContactActions/ContactActions.php index b5859ae13..ec2bf893d 100644 --- a/app/widgets/ContactActions/ContactActions.php +++ b/app/widgets/ContactActions/ContactActions.php @@ -13,6 +13,9 @@ include_once WIDGETS_PATH . 'Post/Post.php'; class ContactActions extends Base { + private $_picturesPagination = 20; + private $_linksPagination = 12; + public function load() { $this->addjs('contactactions.js'); @@ -53,18 +56,21 @@ class ContactActions extends Base $tpl = $this->tpl(); $tpl->assign('contact', \App\Contact::firstOrNew(['id' => $jid])); + + $picturesCount = 0; + $linksCount = 0; + if ($jid != $this->user->id) { - $tpl->assign('pictures', \App\Message::jid($jid) - ->where('picture', true) - ->orderBy('published', 'desc') - ->take(24) - ->get()); - $tpl->assign('links', \App\Message::jid($jid) - ->where('picture', false) - ->whereNotNull('urlid') - ->orderBy('published', 'desc') - ->take(24) - ->get()); + $picturesCount = \App\Message::jid($jid) + ->where('picture', true) + ->orderBy('published', 'desc') + ->count(); + $linksCount = \App\Message::jid($jid) + ->where('picture', false) + ->whereNotNull('urlid') + ->count(); + $tpl->assign('picturesCount', $picturesCount); + $tpl->assign('linksCount', $linksCount); $tpl->assign('roster', $this->user->session->contacts()->where('jid', $jid)->first()); } else { $tpl->assign('pictures', collect()); @@ -88,6 +94,14 @@ class ContactActions extends Base Drawer::fill($tpl->draw('_contactactions_drawer')); $this->rpc('Tabs.create'); + if ($picturesCount > 0) { + $this->rpc('ContactActions_ajaxHttpGetPictures', $jid); + } + + if ($linksCount > 0) { + $this->rpc('ContactActions_ajaxHttpGetLinks', $jid); + } + if ($hasFingerprints) { $this->rpc('ContactActions.getDrawerFingerprints', $jid); } @@ -150,6 +164,55 @@ class ContactActions extends Base $this->rpc('MovimUtils.redirect', $this->route('chat', $jid)); } + public function ajaxHttpGetPictures($jid, $page = 0) + { + $tpl = $this->tpl(); + + $more = false; + $pictures = \App\Message::jid($jid) + ->where('picture', true) + ->orderBy('published', 'desc') + ->take($this->_picturesPagination + 1) + ->skip($this->_picturesPagination * $page) + ->get(); + + if ($pictures->count() == $this->_picturesPagination + 1) { + $pictures->pop(); + $more = true; + } + $tpl->assign('pictures', $pictures); + $tpl->assign('more', $more); + $tpl->assign('page', $page); + $tpl->assign('jid', $jid); + + $this->rpc('MovimTpl.append', '#contact_pictures', $tpl->draw('_contactactions_drawer_pictures')); + } + + public function ajaxHttpGetLinks($jid, $page = 0) + { + $tpl = $this->tpl(); + + $more = false; + $links = \App\Message::jid($jid) + ->where('picture', false) + ->whereNotNull('urlid') + ->orderBy('published', 'desc') + ->take($this->_linksPagination + 1) + ->skip($this->_linksPagination * $page) + ->get(); + + if ($links->count() == $this->_linksPagination + 1) { + $links->pop(); + $more = true; + } + $tpl->assign('links', $links); + $tpl->assign('more', $more); + $tpl->assign('page', $page); + $tpl->assign('jid', $jid); + + $this->rpc('MovimTpl.append', '#contact_links', $tpl->draw('_contactactions_drawer_links')); + } + public function prepareEmbedUrl(EmbedLight $embed) { return (new \Chat)->prepareEmbed($embed, true); diff --git a/app/widgets/ContactActions/_contactactions_drawer.tpl b/app/widgets/ContactActions/_contactactions_drawer.tpl index bb84fc62d..b3ba5eb7a 100644 --- a/app/widgets/ContactActions/_contactactions_drawer.tpl +++ b/app/widgets/ContactActions/_contactactions_drawer.tpl @@ -138,32 +138,12 @@ - {if="$pictures->count() > 0"} -
- -
+ {if="$picturesCount > 0"} +
{/if} - {if="$links->count() > 0"} - + {if="$linksCount > 0"} + {/if} {if="$roster && $roster->presences->count() > 0"} diff --git a/app/widgets/ContactActions/_contactactions_drawer_links.tpl b/app/widgets/ContactActions/_contactactions_drawer_links.tpl new file mode 100644 index 000000000..8200af3ee --- /dev/null +++ b/app/widgets/ContactActions/_contactactions_drawer_links.tpl @@ -0,0 +1,26 @@ + + +{if="$more"} + +{/if} \ No newline at end of file diff --git a/app/widgets/ContactActions/_contactactions_drawer_pictures.tpl b/app/widgets/ContactActions/_contactactions_drawer_pictures.tpl new file mode 100644 index 000000000..bd1c0974c --- /dev/null +++ b/app/widgets/ContactActions/_contactactions_drawer_pictures.tpl @@ -0,0 +1,24 @@ + + +{if="$more"} + +{/if} \ No newline at end of file diff --git a/app/widgets/ContactActions/contactactions.js b/app/widgets/ContactActions/contactactions.js index cb34ee464..4f12b79b9 100644 --- a/app/widgets/ContactActions/contactactions.js +++ b/app/widgets/ContactActions/contactactions.js @@ -5,6 +5,14 @@ var ContactActions = { ContactActions_ajaxGetDrawerFingerprints(jid, deviceId); }); }, + morePictures(button, jid, page) { + button.remove(); + ContactActions_ajaxHttpGetPictures(jid, page); + }, + moreLinks(button, jid, page) { + button.remove(); + ContactActions_ajaxHttpGetLinks(jid, page); + }, resolveSessionsStates : function(jid) { var store = new ChatOmemoStorage(); diff --git a/app/widgets/Publish/publish.css b/app/widgets/Publish/publish.css index 48fdbbac6..036b6617b 100644 --- a/app/widgets/Publish/publish.css +++ b/app/widgets/Publish/publish.css @@ -48,4 +48,8 @@ #publish span.privacy form > div .checkbox > input[type="checkbox"]:checked + label i:before { content: 'wifi_tethering'; +} + +#publishreply { + margin-bottom: -1rem; } \ No newline at end of file diff --git a/app/widgets/Publish/publish.tpl b/app/widgets/Publish/publish.tpl index 6de2dbcfa..a9b63bb72 100644 --- a/app/widgets/Publish/publish.tpl +++ b/app/widgets/Publish/publish.tpl @@ -74,7 +74,7 @@ close
-