diff --git a/components/Author.vue b/components/Author.vue
index 54770d33..3981daf4 100644
--- a/components/Author.vue
+++ b/components/Author.vue
@@ -17,10 +17,11 @@
>
@@ -128,6 +129,7 @@
import HcFollowButton from '~/components/FollowButton.vue'
import HcBadges from '~/components/Badges.vue'
import Dropdown from '~/components/Dropdown'
+import differenceInMinutes from 'date-fns/differenceInMinutes'
export default {
name: 'HcAuthor',
@@ -156,6 +158,14 @@ export default {
name: 'Anonymus'
}
},
+ isOnline() {
+ if (this.author && this.author.lastActiveAt) {
+ // eslint-disable-next-line prettier/prettier
+ return differenceInMinutes(new Date(), new Date(this.author.lastActiveAt)) <= 15
+ } else {
+ return false
+ }
+ },
hasAuthor() {
return Boolean(this.post && this.post.author)
}
diff --git a/graphql/ModerationListQuery.js b/graphql/ModerationListQuery.js
index 8ae827d7..a449b107 100644
--- a/graphql/ModerationListQuery.js
+++ b/graphql/ModerationListQuery.js
@@ -21,6 +21,7 @@ export default app => {
author {
name
slug
+ lastActiveAt
}
post {
title
@@ -33,6 +34,7 @@ export default app => {
author {
name
slug
+ lastActiveAt
}
}
}
diff --git a/graphql/UserProfileQuery.js b/graphql/UserProfileQuery.js
index 30431602..62185c56 100644
--- a/graphql/UserProfileQuery.js
+++ b/graphql/UserProfileQuery.js
@@ -10,6 +10,7 @@ export default app => {
avatar
about
locationName
+ lastActiveAt
location {
name: name${lang}
}
@@ -30,6 +31,7 @@ export default app => {
avatar
followedByCount
followedByCurrentUser
+ lastActiveAt
contributionsCount
commentsCount
badges {
@@ -50,6 +52,7 @@ export default app => {
avatar
followedByCount
followedByCurrentUser
+ lastActiveAt
contributionsCount
commentsCount
badges {
@@ -81,6 +84,7 @@ export default app => {
id
avatar
name
+ lastActiveAt
location {
name: name${lang}
}
diff --git a/layouts/default.vue b/layouts/default.vue
index 7283bf30..889c9027 100644
--- a/layouts/default.vue
+++ b/layouts/default.vue
@@ -33,7 +33,7 @@
!post.deleted))
+ },
+ isOnline() {
+ if (this.user && this.user.lastActiveAt) {
+ // eslint-disable-next-line prettier/prettier
+ return differenceInMinutes(new Date(), new Date(this.user.lastActiveAt)) <= 15
+ } else {
+ return false
+ }
}
},
watch: {