mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 03:52:14 +00:00
groups: very precarious placement of query motifs and subscription /
fetch order due to https://github.com/codeparty/racer/issues/57 for guilds, party, habitRPG group, and publicGroups.
This commit is contained in:
parent
01b9a420b8
commit
8a1aae37a8
2 changed files with 18 additions and 15 deletions
|
|
@ -32,11 +32,18 @@ setupSubscriptions = (page, model, params, next, cb) ->
|
|||
selfQ = model.query('users').withId(uuid) #keep this for later
|
||||
groupsQ = model.query('groups').withMember(uuid)
|
||||
|
||||
# Fetch public groups as _publicGroups - not it has to come at very end due to racer bug
|
||||
model.query('groups').publicGroups().fetch (err, pg) ->
|
||||
return next(err) if err
|
||||
model.set '_publicGroups', _.sortBy(pg.get(), (g) -> -_.size(g.members))
|
||||
|
||||
groupsQ.fetch (err, groups) ->
|
||||
return next(err) if err
|
||||
finished = (descriptors, paths) ->
|
||||
# Add public "Tavern" guild in
|
||||
descriptors.push('groups.habitrpg'); paths.push('_habitRPG')
|
||||
# descriptors.unshift model.query('groups').publicGroups()
|
||||
# paths.unshift('_publicGroups')
|
||||
|
||||
# Subscribe to each descriptor
|
||||
model.subscribe.apply model, descriptors.concat ->
|
||||
|
|
@ -47,11 +54,6 @@ setupSubscriptions = (page, model, params, next, cb) ->
|
|||
console.error "User not found - this shouldn't be happening!"
|
||||
return page.redirect('/logout') #delete model.session.userId
|
||||
|
||||
# Fetch public groups as _publicGroups - not it has to come at very end due to racer bug
|
||||
model.query('groups').publicGroups().fetch (err, pg) ->
|
||||
return next(err) if err
|
||||
model.set '_publicGroups', _.sortBy pg.get(), (g) -> -_.size(g.members)
|
||||
|
||||
return cb()
|
||||
|
||||
groupsObj = groups.get()
|
||||
|
|
|
|||
|
|
@ -130,22 +130,23 @@ groupSystem = (store) ->
|
|||
Find group which has member by id
|
||||
###
|
||||
store.query.expose "groups", "withMember", (id, type) ->
|
||||
q = @where('members').contains([id]).only(['id','members','type'])
|
||||
q = @where('members').contains([id])#.only(['id','members','type'])
|
||||
q = q.where('type').equals(type) if type?
|
||||
store.queryAccess 'groups', 'withMember', publicAccess
|
||||
|
||||
###
|
||||
Public Groups Info
|
||||
Public Groups Info
|
||||
###
|
||||
store.query.expose "groups", "publicGroups", ->
|
||||
@where("privacy").equals('public')
|
||||
.only [
|
||||
'name'
|
||||
'description'
|
||||
'users'
|
||||
'members'
|
||||
'privacy'
|
||||
]
|
||||
@where('privacy').equals('public')
|
||||
.where('type').equals('guild')
|
||||
# .only [
|
||||
# 'name'
|
||||
# 'description'
|
||||
# 'users'
|
||||
# 'members'
|
||||
# 'privacy'
|
||||
# ]
|
||||
store.queryAccess "groups", "publicGroups", publicAccess
|
||||
|
||||
###
|
||||
|
|
|
|||
Loading…
Reference in a new issue