Преглед изворни кода

Merge pull request #5917 from pixelfed/staging

Fix timeAgo and notifications
daniel пре 3 месеци
родитељ
комит
e9aaeae758

BIN
public/_lang/en.json


BIN
public/_lang/pt.json



BIN
public/js/discover~hashtag.bundle.9e342ac5d1df33af.js


BIN
public/js/discover~hashtag.bundle.b783a54ac20f3e93.js


BIN
public/js/home.chunk.abfb6c7049f7833d.js


+ 0 - 0
public/js/home.chunk.fec949c588d3a0ec.js.LICENSE.txt → public/js/home.chunk.abfb6c7049f7833d.js.LICENSE.txt


BIN
public/js/home.chunk.fec949c588d3a0ec.js


BIN
public/js/manifest.js


BIN
public/js/notifications.chunk.a755ad4eb2972fbf.js


BIN
public/js/notifications.chunk.a8193668255b2c9a.js


BIN
public/js/post.chunk.192819f7b133173e.js


+ 0 - 0
public/js/post.chunk.48fdffa21ac83f3a.js.LICENSE.txt → public/js/post.chunk.192819f7b133173e.js.LICENSE.txt


BIN
public/js/post.chunk.48fdffa21ac83f3a.js



BIN
public/mix-manifest.json


+ 1 - 29
resources/assets/components/partials/timeline/Notification.vue

@@ -142,35 +142,7 @@
 			},
 
             timeAgo(ts) {
-                let date = new Date(ts);
-                let now = new Date();
-                let seconds = Math.floor((now - date) / 1000);
-                let interval = Math.floor(seconds / 31536000);
-                if (interval >= 1) {
-                    return new Intl.RelativeTimeFormat(this.$i18n.locale, { numeric: 'auto' }).format(-interval, 'year');
-                }
-                interval = Math.floor(seconds / 2592000);
-                if (interval >= 1) {
-                    return new Intl.RelativeTimeFormat(this.$i18n.locale, { numeric: 'auto' }).format(-interval, 'month');
-                }
-                interval = Math.floor(seconds / 604800);
-                if (interval >= 1) {
-                    return new Intl.RelativeTimeFormat(this.$i18n.locale, { numeric: 'auto' }).format(-interval, 'week');
-                }
-                interval = Math.floor(seconds / 86400);
-                if (interval >= 1) {
-                    return new Intl.RelativeTimeFormat(this.$i18n.locale, { numeric: 'auto' }).format(-interval, 'day');
-                }
-                interval = Math.floor(seconds / 3600);
-                if (interval >= 1) {
-                    return new Intl.RelativeTimeFormat(this.$i18n.locale, { numeric: 'auto' }).format(-interval, 'hour');
-                }
-                interval = Math.floor(seconds / 60);
-                if (interval >= 1) {
-                    return new Intl.RelativeTimeFormat(this.$i18n.locale, { numeric: 'auto' }).format(-interval, 'minute');
-                }
-                return new Intl.RelativeTimeFormat(this.$i18n.locale, { numeric: 'auto' }).format(-seconds, 'second');
-
+                return App.util.format.timeAgo(ts);
 			},
 
 			mentionUrl(status) {

+ 1 - 1
resources/assets/components/sections/Notifications.vue

@@ -151,7 +151,7 @@
 										</p>
 									</div>
 								</div>
-								<div class="small text-muted font-weight-bold"  style="font-size: 0.575em;"  st :title="n.created_at">{{timeAgo(n.created_at)}}</div>
+								<div class="small text-muted font-weight-bold"  style="font-size: 12px;" :title="n.created_at">{{timeAgo(n.created_at)}}</div>
 							</div>
 						</div>
 

+ 23 - 19
resources/assets/js/app.js

@@ -96,36 +96,40 @@ window.App.util = {
 			}
 			return new Intl.NumberFormat(locale, { notation: notation , compactDisplay: "short" }).format(count);
 		}),
-		timeAgo: (function(ts) {
-            let date = new Date(ts);
-            let now = new Date();
-            let seconds = Math.floor((now - date) / 1000);
-            let interval = Math.floor(seconds / 31536000);
-            if (interval >= 1) {
-                return new Intl.RelativeTimeFormat('en', { numeric: 'auto', style: 'short' }).format(-interval, 'year');
-            }
-            interval = Math.floor(seconds / 2592000);
+        timeAgo: (function(ts) {
+            const date = new Date(ts);
+            const now = new Date();
+
+            const seconds = Math.floor((now - date) / 1000);
+
+            const secondsInYear = 60 * 60 * 24 * 365.25;
+            let interval = Math.floor(seconds / secondsInYear);
             if (interval >= 1) {
-                return new Intl.RelativeTimeFormat('en', { numeric: 'auto', style: 'short' }).format(-interval, 'month');
+                return interval + "y";
             }
-            interval = Math.floor(seconds / 604800);
+
+            interval = Math.floor(seconds / (60 * 60 * 24 * 7));
             if (interval >= 1) {
-                return new Intl.RelativeTimeFormat('en', { numeric: 'auto', style: 'short' }).format(-interval, 'week');
+                return interval + "w";
             }
-            interval = Math.floor(seconds / 86400);
+
+            interval = Math.floor(seconds / (60 * 60 * 24));
             if (interval >= 1) {
-                return new Intl.RelativeTimeFormat('en', { numeric: 'auto', style: 'short' }).format(-interval, 'day');
+                return interval + "d";
             }
-            interval = Math.floor(seconds / 3600);
+
+            interval = Math.floor(seconds / (60 * 60));
             if (interval >= 1) {
-                return new Intl.RelativeTimeFormat('en', { numeric: 'auto', style: 'short' }).format(-interval, 'hour');
+                return interval + "h";
             }
+
             interval = Math.floor(seconds / 60);
             if (interval >= 1) {
-                return new Intl.RelativeTimeFormat('en', { numeric: 'auto', style: 'short' }).format(-interval, 'minute');
+                return interval + "m";
             }
-            return new Intl.RelativeTimeFormat('en', { numeric: 'auto', style: 'short' }).format(-seconds, 'second');
-		}),
+
+            return Math.floor(seconds) + "s";
+        }),
 		timeAhead: (function(ts, short = true) {
 			let date = Date.parse(ts);
 			let diff = date - Date.parse(new Date());

Разлика између датотеке није приказан због своје велике величине
+ 484 - 484
resources/assets/js/spa.js


Неке датотеке нису приказане због велике количине промена