Remove seconds from timer when over 1min

This commit is contained in:
Natsumi
2021-11-20 00:19:52 +13:00
parent 9c4e8e5ba9
commit 81db11f848
2 changed files with 3 additions and 29 deletions
+1 -27
View File
@@ -203,39 +203,13 @@ speechSynthesis.getVoices();
arr.push(`${Math.floor(n / 60)}m`); arr.push(`${Math.floor(n / 60)}m`);
n %= 60; n %= 60;
} }
if (n || arr.length === 0) { if (arr.length === 0 && n < 60) {
arr.push(`${n}s`); arr.push(`${n}s`);
} }
return arr.join(' '); return arr.join(' ');
}; };
Vue.filter('timeToText', timeToText); Vue.filter('timeToText', timeToText);
var timeToTextMin = function (sec) {
var n = Number(sec);
if (isNaN(n)) {
return escapeTag(sec);
}
n = Math.floor(n / 1000);
var arr = [];
if (n < 0) {
n = -n;
}
if (n >= 86400) {
arr.push(`${Math.floor(n / 86400)}d`);
n %= 86400;
}
if (n >= 3600) {
arr.push(`${Math.floor(n / 3600)}h`);
n %= 3600;
}
if (n >= 60) {
arr.push(`${Math.floor(n / 60)}m`);
n %= 60;
}
return arr.join(' ');
};
Vue.filter('timeToTextMin', timeToTextMin);
Vue.use(VueLazyload, { Vue.use(VueLazyload, {
preLoad: 1, preLoad: 1,
observer: true, observer: true,
+2 -2
View File
@@ -689,7 +689,7 @@ html
el-table-column(label="Join Count" width="120" prop="$joinCount" sortable) el-table-column(label="Join Count" width="120" prop="$joinCount" sortable)
el-table-column(label="Time Together" width="140" prop="$timeSpent" sortable) el-table-column(label="Time Together" width="140" prop="$timeSpent" sortable)
template(v-once #default="scope") template(v-once #default="scope")
span(v-if="scope.row.$timeSpent") {{ scope.row.$timeSpent | timeToTextMin }} span(v-if="scope.row.$timeSpent") {{ scope.row.$timeSpent | timeToText }}
el-table-column(label="Last Seen" width="170" prop="$lastSeen" sortable :sort-method="(a, b) => sortAlphabetically(a, b, '$lastSeen')") el-table-column(label="Last Seen" width="170" prop="$lastSeen" sortable :sort-method="(a, b) => sortAlphabetically(a, b, '$lastSeen')")
el-table-column(label="Last Login" width="170" prop="last_login" sortable :sort-method="(a, b) => sortAlphabetically(a, b, 'last_login')") el-table-column(label="Last Login" width="170" prop="last_login" sortable :sort-method="(a, b) => sortAlphabetically(a, b, 'last_login')")
el-table-column(label="Date Joined" width="120" prop="date_joined" sortable :sort-method="(a, b) => sortAlphabetically(a, b, 'date_joined')") el-table-column(label="Date Joined" width="120" prop="date_joined" sortable :sort-method="(a, b) => sortAlphabetically(a, b, 'date_joined')")
@@ -1267,7 +1267,7 @@ html
.detail .detail
span.name Time Together span.name Time Together
span.extra(v-if="userDialog.timeSpent === 0") - span.extra(v-if="userDialog.timeSpent === 0") -
span.extra(v-else) {{ userDialog.timeSpent | timeToTextMin }} span.extra(v-else) {{ userDialog.timeSpent | timeToText }}
.x-friend-item(style="cursor:default") .x-friend-item(style="cursor:default")
.detail .detail
span.name(v-if="userDialog.ref.state === 'online' && userDialog.ref.$online_for") Online For span.name(v-if="userDialog.ref.state === 'online' && userDialog.ref.$online_for") Online For