()
| 60 | } |
| 61 | |
| 62 | onLoaded () { |
| 63 | if (this.user.loaded) { |
| 64 | this.setMeta({ |
| 65 | title: $.i18n.t('user.user_title', { name: this.user.broadName() }) |
| 66 | }) |
| 67 | |
| 68 | if (!this.levelSessions) { |
| 69 | this.levelSessions = new LevelSessionsCollection(this.user.getSlugOrID()) |
| 70 | this.listenTo(this.levelSessions, 'sync', () => { |
| 71 | this.onSyncLevelSessions(this.levelSessions != null ? this.levelSessions.models : undefined) |
| 72 | return this.render() |
| 73 | }) |
| 74 | this.supermodel.loadCollection(this.levelSessions, 'levelSessions', { cache: false }) |
| 75 | } |
| 76 | |
| 77 | if (!this.earnedAchievements) { |
| 78 | this.earnedAchievements = new EarnedAchievementCollection(this.user.getSlugOrID()) |
| 79 | this.listenTo(this.earnedAchievements, 'sync', () => { |
| 80 | return this.render() |
| 81 | }) |
| 82 | this.supermodel.loadCollection(this.earnedAchievements, 'earnedAchievements', { cache: false }) |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | const sortClanList = function (a, b) { |
| 87 | if (a.get('members').length !== b.get('members').length) { |
| 88 | if (a.get('members').length < b.get('members').length) { return 1 } else { return -1 } |
| 89 | } else { |
| 90 | return b.id.localeCompare(a.id) |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | this.clans = new CocoCollection([], { url: `/db/user/${this.userID}/clans`, model: Clan, comparator: sortClanList }) |
| 95 | this.listenTo(this.clans, 'sync', () => { |
| 96 | this.onSyncClans(this.clans != null ? this.clans.models : undefined) |
| 97 | return (typeof this.render === 'function' ? this.render() : undefined) |
| 98 | }) |
| 99 | this.supermodel.loadCollection(this.clans, 'clans', { cache: false }) |
| 100 | if (utils.isCodeCombat) { |
| 101 | this.loadHeroPoseImage() |
| 102 | } |
| 103 | return super.onLoaded() |
| 104 | } |
| 105 | |
| 106 | onSyncClans (clans) { |
| 107 | if (clans == null) { return } |
nothing calls this directly
no test coverage detected