From f093bf05a9e80d55a7f89104768a5c2ba6d490a0 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 30 Apr 2019 22:37:53 -0600 Subject: [PATCH] Update NotificationCard.vue --- .../assets/js/components/NotificationCard.vue | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/resources/assets/js/components/NotificationCard.vue b/resources/assets/js/components/NotificationCard.vue index b5894f38d..d84fad229 100644 --- a/resources/assets/js/components/NotificationCard.vue +++ b/resources/assets/js/components/NotificationCard.vue @@ -42,6 +42,7 @@

+
{{timeAgo(n.created_at)}}
@@ -127,6 +128,38 @@ } return text.slice(0,15) + '...' + }, + + timeAgo(ts) { + let date = Date.parse(ts); + let seconds = Math.floor((new Date() - date) / 1000); + let interval = Math.floor(seconds / 31536000); + if (interval >= 1) { + return interval + "y"; + } + interval = Math.floor(seconds / 604800); + if (interval >= 1) { + return interval + "w"; + } + interval = Math.floor(seconds / 86400); + if (interval >= 1) { + return interval + "d"; + } + interval = Math.floor(seconds / 3600); + if (interval >= 1) { + return interval + "h"; + } + interval = Math.floor(seconds / 60); + if (interval >= 1) { + return interval + "m"; + } + return Math.floor(seconds) + "s"; + }, + + mentionUrl(status) { + let username = status.account.username; + let id = status.id; + return '/p/' + username + '/' + id; } } }