Profile refactoring with friend request

This commit is contained in:
yflory
2019-05-24 17:45:03 +02:00
parent 64b0a8c5e3
commit df7a2f35fb
8 changed files with 376 additions and 211 deletions

View File

@@ -168,6 +168,31 @@ define([
});
};
// Universal direct channel
var modules = {};
funcs.makeUniversal = function (type, cfg) {
if (modules[type]) { return; }
var sframeChan = funcs.getSframeChannel();
modules[type] = {
onEvent: cfg.onEvent || function () {}
};
return {
execCommand: function (cmd, data, cb) {
sframeChan.query("Q_UNIVERSAL_COMMAND", {
type: type,
data: {
cmd: cmd,
data: data
}
}, function (err, obj) {
if (err) { return void cb({error: err}); }
cb(obj);
});
}
};
};
// Chat
var padChatChannel;
// common-ui-elements needs to be able to get the chat channel to put it in metadata when
@@ -575,6 +600,12 @@ define([
});
});
ctx.sframeChan.on('EV_UNIVERSAL_EVENT', function (obj) {
var type = obj.type;
if (!type || !modules[type]) { return; }
modules[type].onEvent(obj.data);
});
ctx.metadataMgr.onReady(waitFor());
funcs.addShortcuts();