Fix a truly silly mistake in rpc.js and make the pad-not-pinned message get removed if a registered user joins

This commit is contained in:
Caleb James DeLisle 2017-12-08 14:46:32 +01:00
parent 008b2cc67e
commit 7a09bf43eb
2 changed files with 15 additions and 5 deletions

5
rpc.js
View File

@ -540,9 +540,8 @@ var addPinned = function (
{ {
Env.evPinnedPadsReady.reg(() => { Env.evPinnedPadsReady.reg(() => {
channelList.forEach((c) => { channelList.forEach((c) => {
const x = Env.pinnedPads[c]; const x = Env.pinnedPads[c] = Env.pinnedPads[c] || {};
if (!x) { return; } x[publicKey] = 1;
delete x[publicKey];
}); });
cb(); cb();
}); });

View File

@ -719,7 +719,7 @@ define([
return $titleContainer; return $titleContainer;
}; };
var createUnpinnedWarning = function (toolbar, config) { var createUnpinnedWarning0 = function (toolbar, config) {
if (Common.isLoggedIn()) { return; } if (Common.isLoggedIn()) { return; }
var pd = config.metadataMgr.getPrivateData(); var pd = config.metadataMgr.getPrivateData();
var o = pd.origin; var o = pd.origin;
@ -728,7 +728,11 @@ define([
var cid = Hash.hrefToHexChannelId(url); var cid = Hash.hrefToHexChannelId(url);
Common.sendAnonRpcMsg('IS_CHANNEL_PINNED', cid, function (x) { Common.sendAnonRpcMsg('IS_CHANNEL_PINNED', cid, function (x) {
if (x.error || !Array.isArray(x.response)) { return void console.log(x); } if (x.error || !Array.isArray(x.response)) { return void console.log(x); }
if (x.response[0] === true) { return; } if (x.response[0] === true) {
$('.cp-pad-not-pinned').remove();
return;
}
if ($('.cp-pad-not-pinned').length) { return; }
var pnpTitle = Messages._getKey('padNotPinned', ['','','','']); var pnpTitle = Messages._getKey('padNotPinned', ['','','','']);
var pnpMsg = Messages._getKey('padNotPinned', [ var pnpMsg = Messages._getKey('padNotPinned', [
'<a href="' + o + '/login" class="cp-pnp-login" target="blank" title>', '<a href="' + o + '/login" class="cp-pnp-login" target="blank" title>',
@ -759,6 +763,13 @@ define([
}); });
}; };
var createUnpinnedWarning = function (toolbar, config) {
config.metadataMgr.onChange(function () {
createUnpinnedWarning0(toolbar, config);
});
createUnpinnedWarning0(toolbar, config);
};
var createPageTitle = function (toolbar, config) { var createPageTitle = function (toolbar, config) {
if (config.title || !config.pageTitle) { return; } if (config.title || !config.pageTitle) { return; }
var $titleContainer = $('<span>', { var $titleContainer = $('<span>', {