diff options
author | Mario Vavti <mario@mariovavti.com> | 2021-06-23 22:14:01 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2021-06-23 22:14:01 +0200 |
commit | 97d9764f015990b1df01463c45090c4cbc2192fa (patch) | |
tree | 8eb90981bec461325e3ca29f7fda8a56d14d5d52 | |
parent | dfcd8395d5aff83b8d6e1fa83346f0f0bd78f879 (diff) | |
download | volse-hubzilla-97d9764f015990b1df01463c45090c4cbc2192fa.tar.gz volse-hubzilla-97d9764f015990b1df01463c45090c4cbc2192fa.tar.bz2 volse-hubzilla-97d9764f015990b1df01463c45090c4cbc2192fa.zip |
if there are no messages display that there are no messages
-rw-r--r-- | Zotlabs/Widget/Messages.php | 9 | ||||
-rw-r--r-- | view/tpl/messages_widget.tpl | 36 |
2 files changed, 26 insertions, 19 deletions
diff --git a/Zotlabs/Widget/Messages.php b/Zotlabs/Widget/Messages.php index 95f3d4eb6..9679631c6 100644 --- a/Zotlabs/Widget/Messages.php +++ b/Zotlabs/Widget/Messages.php @@ -11,14 +11,10 @@ class Messages { if (!local_channel()) return EMPTY_STR; - $o = ''; $page = self::get_messages_page($options); - if (!$page['entries']) - return $o; - $tpl = get_markup_template('messages_widget.tpl'); - $o .= replace_macros($tpl, [ + $o = replace_macros($tpl, [ '$entries' => $page['entries'], '$offset' => $page['offset'], '$feature_star' => feature_enabled(local_channel(), 'star_posts'), @@ -26,7 +22,8 @@ class Messages { 'messages_title' => t('Public and restricted messages'), 'direct_messages_title' => t('Direct messages'), 'starred_messages_title' => t('Starred messages'), - 'loading' => t('Loading') + 'loading' => t('Loading'), + 'empty' => t('No messages') ] ]); diff --git a/view/tpl/messages_widget.tpl b/view/tpl/messages_widget.tpl index 6f888962d..2d7ab99df 100644 --- a/view/tpl/messages_widget.tpl +++ b/view/tpl/messages_widget.tpl @@ -49,6 +49,9 @@ <small>{{$e.info}}</small> </a> {{/foreach}} + <div id="messages-empty" class="list-group-item border-0"{{if $entries}} style="display: none;"{{/if}}> + {{$strings.empty}}... + </div> <div id="messages-loading" class="list-group-item" style="display: none;"> {{$strings.loading}}<span class="jumping-dots"><span class="dot-1">.</span><span class="dot-2">.</span><span class="dot-3">.</span></span> </div> @@ -90,6 +93,8 @@ get_messages_page_active = true; $('#messages-loading').show(); + $('#messages-empty').hide(); + $.ajax({ type: 'post', url: 'hq', @@ -102,19 +107,24 @@ messages_offset = obj.offset; let html; let tpl = $('#messages-template[rel=template]').html(); - obj.entries.forEach(function(e) { - html = tpl.format( - e.b64mid, - e.created, - e.summary, - e.info, - e.author_name, - e.author_addr, - e.href, - e.icon - ); - $('#messages-loading').before(html); - }); + if (obj.entries.length) { + obj.entries.forEach(function(e) { + html = tpl.format( + e.b64mid, + e.created, + e.summary, + e.info, + e.author_name, + e.author_addr, + e.href, + e.icon + ); + $('#messages-loading').before(html); + }); + } + else { + $('#messages-empty').show(); + } $('.message[data-b64mid=\'' + bParam_mid + '\']').addClass('active'); $('#messages-loading').hide(); $('.messages-timeago').timeago(); |