This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/app/controllers/user-summary.js
Bianca Nenciu 68497bddf2
UX: Add title to read time stats from user page (#16501)
The title attributes were added to explain the difference between "read
time" and "recent read time" stats from user summary page.
2022-04-19 20:48:08 +03:00

47 lines
1.4 KiB
JavaScript

import Controller, { inject as controller } from "@ember/controller";
import { alias } from "@ember/object/computed";
import discourseComputed from "discourse-common/utils/decorators";
import { duration } from "discourse/lib/formatter";
// should be kept in sync with 'UserSummary::MAX_BADGES'
const MAX_BADGES = 6;
export default Controller.extend({
userController: controller("user"),
user: alias("userController.model"),
@discourseComputed("model.badges.length")
moreBadges(badgesLength) {
return badgesLength >= MAX_BADGES;
},
@discourseComputed("model.time_read")
timeRead(timeReadSeconds) {
return duration(timeReadSeconds, { format: "tiny" });
},
@discourseComputed("model.time_read")
timeReadMedium(timeReadSeconds) {
return duration(timeReadSeconds, { format: "medium" });
},
@discourseComputed("model.time_read", "model.recent_time_read")
showRecentTimeRead(timeRead, recentTimeRead) {
return timeRead !== recentTimeRead && recentTimeRead !== 0;
},
@discourseComputed("model.recent_time_read")
recentTimeRead(recentTimeReadSeconds) {
return recentTimeReadSeconds > 0
? duration(recentTimeReadSeconds, { format: "tiny" })
: null;
},
@discourseComputed("model.recent_time_read")
recentTimeReadMedium(recentTimeReadSeconds) {
return recentTimeReadSeconds > 0
? duration(recentTimeReadSeconds, { format: "medium" })
: null;
},
});