()
| 76 | } |
| 77 | |
| 78 | loadData () { |
| 79 | let left |
| 80 | const sortClanList = function (a, b) { |
| 81 | if (a.get('memberCount') !== b.get('memberCount')) { |
| 82 | if (a.get('memberCount') < b.get('memberCount')) { return 1 } else { return -1 } |
| 83 | } else { |
| 84 | return b.id.localeCompare(a.id) |
| 85 | } |
| 86 | } |
| 87 | this.publicClans = new CocoCollection([], { url: '/db/clan/-/public?excludeAutoclans=true', model: Clan, comparator: sortClanList }) |
| 88 | this.listenTo(this.publicClans, 'sync', () => { |
| 89 | this.refreshNames(this.publicClans.models) |
| 90 | return (typeof this.render === 'function' ? this.render() : undefined) |
| 91 | }) |
| 92 | this.supermodel.loadCollection(this.publicClans, 'public_clans', { cache: false }) |
| 93 | |
| 94 | this.myClans = new CocoCollection([], { url: `/db/user/${me.id}/clans`, model: Clan, comparator: sortClanList }) |
| 95 | this.listenTo(this.myClans, 'sync', () => { |
| 96 | this.refreshNames(this.myClans.models) |
| 97 | return (typeof this.render === 'function' ? this.render() : undefined) |
| 98 | }) |
| 99 | this.supermodel.loadCollection(this.myClans, 'my_clans', { cache: false }) |
| 100 | |
| 101 | this.listenTo(me, 'sync', () => (typeof this.render === 'function' ? this.render() : undefined)) |
| 102 | return this.myClanIDs = (left = me.get('clans')) != null ? left : [] |
| 103 | } |
| 104 | |
| 105 | refreshNames (clans) { |
| 106 | let clanIDs = _.filter(clans, clan => clan.get('type') === 'public') |
no test coverage detected