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/controllers/user-summary.js.es6
2018-06-15 17:03:24 +02:00

33 lines
924 B
JavaScript

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