summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-06-07 01:59:02 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-06-07 01:59:02 +0900
commit8f5bdd34a83a1222025176d7547a0d4e2055ddcb (patch)
tree650aa3c580c0c59ec76527bee6b0374f071cf678 /src
parent[Client] Fix bug (diff)
downloadsharkey-8f5bdd34a83a1222025176d7547a0d4e2055ddcb.tar.gz
sharkey-8f5bdd34a83a1222025176d7547a0d4e2055ddcb.tar.bz2
sharkey-8f5bdd34a83a1222025176d7547a0d4e2055ddcb.zip
#359
Diffstat (limited to 'src')
-rw-r--r--src/web/app/desktop/tags/notifications.tag57
-rw-r--r--src/web/app/mobile/tags/notifications.tag55
2 files changed, 99 insertions, 13 deletions
diff --git a/src/web/app/desktop/tags/notifications.tag b/src/web/app/desktop/tags/notifications.tag
index e076ee3310..d5ca9e2eb7 100644
--- a/src/web/app/desktop/tags/notifications.tag
+++ b/src/web/app/desktop/tags/notifications.tag
@@ -63,8 +63,11 @@
<p class="date" if={ i != notifications.length - 1 && notification._date != notifications[i + 1]._date }><span><i class="fa fa-angle-up"></i>{ notification._datetext }</span><span><i class="fa fa-angle-down"></i>{ notifications[i + 1]._datetext }</span></p>
</virtual>
</div>
+ <button class="more" if={ moreNotifications } onclick={ fetchMoreNotifications } disabled={ fetchingMoreNotifications }>
+ { fetchingMoreNotifications ? '%i18n:common.loading%' : '%i18n:desktop.tags.mk-notifications.more%' }
+ </button>
<p class="empty" if={ notifications.length == 0 && !loading }>ありません!</p>
- <p class="loading" if={ loading }><i class="fa fa-spinner fa-pulse fa-fw"></i>読み込んでいます<mk-ellipsis/></p>
+ <p class="loading" if={ loading }><i class="fa fa-spinner fa-pulse fa-fw"></i>%i18n:common.loading%<mk-ellipsis/></p>
<style>
:scope
display block
@@ -168,6 +171,12 @@
i
margin-right 8px
+ > .more
+ display block
+ width 100%
+ padding 16px
+ color #555
+
> .empty
margin 0
padding 16px
@@ -197,7 +206,16 @@
this.loading = true;
this.on('mount', () => {
- this.api('i/notifications').then(notifications => {
+ const max = 10;
+
+ this.api('i/notifications', {
+ limit: max + 1
+ }).then(notifications => {
+ if (notifications.length == max + 1) {
+ this.moreNotifications = true;
+ notifications.pop();
+ }
+
this.update({
loading: false,
notifications: notifications
@@ -211,11 +229,6 @@
this.stream.off('notification', this.onNotification);
});
- this.onNotification = notification => {
- this.notifications.unshift(notification);
- this.update();
- };
-
this.on('update', () => {
this.notifications.forEach(notification => {
const date = new Date(notification.created_at).getDate();
@@ -224,5 +237,35 @@
notification._datetext = `${month}月 ${date}日`;
});
});
+
+ this.onNotification = notification => {
+ this.notifications.unshift(notification);
+ this.update();
+ };
+
+ this.fetchMoreNotifications = () => {
+ this.update({
+ fetchingMoreNotifications: true
+ });
+
+ const max = 30;
+
+ this.api('i/notifications', {
+ folder_id: this.folder ? this.folder.id : null,
+ limit: max + 1,
+ max_id: this.notifications[this.notifications.length - 1]._id
+ }).then(notifications => {
+ if (notifications.length == max + 1) {
+ this.moreNotifications = true;
+ notifications.pop();
+ } else {
+ this.moreNotifications = false;
+ }
+ this.update({
+ notifications: this.notifications.concat(notifications),
+ fetchingMoreNotifications: false
+ });
+ });
+ };
</script>
</mk-notifications>
diff --git a/src/web/app/mobile/tags/notifications.tag b/src/web/app/mobile/tags/notifications.tag
index 85a8fe3793..0f9e0b0a65 100644
--- a/src/web/app/mobile/tags/notifications.tag
+++ b/src/web/app/mobile/tags/notifications.tag
@@ -5,6 +5,9 @@
<p class="date" if={ i != notifications.length - 1 && notification._date != notifications[i + 1]._date }><span><i class="fa fa-angle-up"></i>{ notification._datetext }</span><span><i class="fa fa-angle-down"></i>{ notifications[i + 1]._datetext }</span></p>
</virtual>
</div>
+ <button class="more" if={ moreNotifications } onclick={ fetchMoreNotifications } disabled={ fetchingMoreNotifications }>
+ { fetchingMoreNotifications ? '%i18n:common.loading%' : '%i18n:mobile.tags.mk-notifications.more%' }
+ </button>
<p class="empty" if={ notifications.length == 0 && !loading }>%i18n:mobile.tags.mk-notifications.empty%</p>
<p class="loading" if={ loading }><i class="fa fa-spinner fa-pulse fa-fw"></i>%i18n:common.loading%<mk-ellipsis/></p>
<style>
@@ -38,6 +41,12 @@
i
margin-right 8px
+ > .more
+ display block
+ width 100%
+ padding 16px
+ color #555
+
> .empty
margin 0
padding 16px
@@ -65,7 +74,16 @@
this.loading = true;
this.on('mount', () => {
- this.api('i/notifications').then(notifications => {
+ const max = 10;
+
+ this.api('i/notifications', {
+ limit: max + 1
+ }).then(notifications => {
+ if (notifications.length == max + 1) {
+ this.moreNotifications = true;
+ notifications.pop();
+ }
+
this.update({
loading: false,
notifications: notifications
@@ -81,11 +99,6 @@
this.stream.off('notification', this.onNotification);
});
- this.onNotification = notification => {
- this.notifications.unshift(notification);
- this.update();
- };
-
this.on('update', () => {
this.notifications.forEach(notification => {
const date = new Date(notification.created_at).getDate();
@@ -94,5 +107,35 @@
notification._datetext = `${month}月 ${date}日`;
});
});
+
+ this.onNotification = notification => {
+ this.notifications.unshift(notification);
+ this.update();
+ };
+
+ this.fetchMoreNotifications = () => {
+ this.update({
+ fetchingMoreNotifications: true
+ });
+
+ const max = 30;
+
+ this.api('i/notifications', {
+ folder_id: this.folder ? this.folder.id : null,
+ limit: max + 1,
+ max_id: this.notifications[this.notifications.length - 1]._id
+ }).then(notifications => {
+ if (notifications.length == max + 1) {
+ this.moreNotifications = true;
+ notifications.pop();
+ } else {
+ this.moreNotifications = false;
+ }
+ this.update({
+ notifications: this.notifications.concat(notifications),
+ fetchingMoreNotifications: false
+ });
+ });
+ };
</script>
</mk-notifications>