MCPcopy Create free account
hub / github.com/codecombat/codecombat / loadData

Method loadData

app/views/clans/ClansView.js:78–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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')

Callers 1

constructorMethod · 0.95

Calls 3

refreshNamesMethod · 0.95
renderMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected