Merge pull request #4785 from AAorris/develop

Allow for client notifications to user settings
This commit is contained in:
Alys 2015-03-11 08:20:51 +10:00
commit 63c57cce5d
2 changed files with 14 additions and 3 deletions

View file

@ -21,6 +21,7 @@
"communityGuidelinesRead2": "before chatting.",
"party": "Party",
"createAParty": "Create A Party",
"updatedParty": "Party settings updated. Please refresh the page to see the changes.",
"noPartyText": "You are either not in a party or your party is taking a while to load. You can either create one and invite friends, or if you want to join an existing party, have them enter your Unique User ID below and then come back here to look for the invitation:",
"LFG": "To advertise your new party or find one to join, go to the <%= linkStart %>Party Wanted (Looking for Group)<%= linkEnd %> Guild.",
"create": "Create",

View file

@ -5,12 +5,12 @@ angular.module('habitrpg')
this.setApiUrl = function(newUrl){
currentApiUrl = newUrl;
};
this.get = function(){
return currentApiUrl;
};
}])
/**
* Services that persists and retrieves user from localStorage.
*/
@ -29,6 +29,11 @@ angular.module('habitrpg')
var settings = {}; //habit mobile settings (like auth etc.) to be stored here
var user = {}; // this is stored as a reference accessible to all controllers, that way updates propagate
var userNotifications = {
"party.order" : env.t("updatedParty"),
"party.orderAscending" : env.t("updatedParty")
}; // this is a list of notifications to send to the user when changes are made, along with the message.
//first we populate user with schema
user.apiToken = user._id = ''; // we use id / apitoken to determine if registered
@ -93,7 +98,11 @@ angular.module('habitrpg')
_.each(user.ops, function(op,k){
user.ops[k] = function(req,cb){
if (cb) return op(req,cb);
op(req,function(err,response){
op(req,function(err,response) {
for(var updatedItem in req.body) {
var itemUpdateResponse = userNotifications[updatedItem]
if(itemUpdateResponse) Notification.text(itemUpdateResponse);
}
if (err) {
var message = err.code ? err.message : err;
console.log(message);
@ -149,6 +158,7 @@ angular.module('habitrpg')
set: function(updates) {
user.ops.update({body:updates});
},
online: function (status) {
if (status===true) {
settings.online = true;