mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-03 08:21:07 +00:00
fix(groupsServices): allow for direct modification of data @lefnire it is necessary for mobile but does not break anything
This commit is contained in:
parent
6d251aeb91
commit
6db5b53c81
1 changed files with 13 additions and 9 deletions
|
|
@ -23,25 +23,25 @@ angular.module('groupServices', ['ngResource']).
|
|||
});
|
||||
|
||||
// Defer loading everything until they're requested
|
||||
var party, myGuilds, publicGuilds, tavern;
|
||||
var data = {party: undefined, myGuilds: undefined, publicGuilds: undefined, tavern: undefined};
|
||||
|
||||
return {
|
||||
party: function(cb){
|
||||
if (!party) return (party = Group.get({gid: 'party'}, cb));
|
||||
return (cb) ? cb(party) : party;
|
||||
if (!data.party) return (data.party = Group.get({gid: 'party'}, cb));
|
||||
return (cb) ? cb(party) : data.party;
|
||||
},
|
||||
publicGuilds: function(){
|
||||
//TODO combine these as {type:'guilds,public'} and create a $filter() to separate them
|
||||
if (!publicGuilds) publicGuilds = Group.query({type:'public'});
|
||||
return publicGuilds;
|
||||
if (!data.publicGuilds) data.publicGuilds = Group.query({type:'public'});
|
||||
return data.publicGuilds;
|
||||
},
|
||||
myGuilds: function(){
|
||||
if (!myGuilds) myGuilds = Group.query({type:'guilds'});
|
||||
return myGuilds;
|
||||
if (!data.myGuilds) data.myGuilds = Group.query({type:'guilds'});
|
||||
return data.myGuilds;
|
||||
},
|
||||
tavern: function(){
|
||||
if (!tavern) tavern = Group.get({gid:'habitrpg'});
|
||||
return tavern;
|
||||
if (!data.tavern) data.tavern = Group.get({gid:'habitrpg'});
|
||||
return data.tavern;
|
||||
},
|
||||
|
||||
// On enter, set chat message to "seen"
|
||||
|
|
@ -50,6 +50,10 @@ angular.module('groupServices', ['ngResource']).
|
|||
if (User.user.newMessages) User.user.newMessages[gid] = false;
|
||||
},
|
||||
|
||||
// Pass reference to party, myGuilds, publicGuilds, tavern; inside data in order to
|
||||
// be able to modify them directly (otherwise will be stick with cached version)
|
||||
data: data,
|
||||
|
||||
Group: Group
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue