From 60555f65a7b8f5662472a3f57eaa1a31c7d93ebe Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 28 Apr 2020 16:40:40 +0200 Subject: [PATCH] Little fixes and improvements to comments --- .../src/less2/include/comments.less | 5 ++-- www/common/notifications.js | 25 +++++++++++-------- www/common/outer/mailbox-handlers.js | 13 +++++----- www/pad/comments.js | 2 ++ 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/customize.dist/src/less2/include/comments.less b/customize.dist/src/less2/include/comments.less index b6b0a21dc..82647e2b4 100644 --- a/customize.dist/src/less2/include/comments.less +++ b/customize.dist/src/less2/include/comments.less @@ -24,8 +24,9 @@ .avatar_main(40px); display: flex; align-items: flex-start; - textarea { + div.cp-textarea { flex: 1; + min-height: 50px; height: 50px; padding: 2px 8px; } @@ -82,7 +83,7 @@ background-color: white; padding: 10px 5px 5px; white-space: pre-wrap; - word-break: break-all; + word-break: break-word; } .cp-comment-actions { display: none; diff --git a/www/common/notifications.js b/www/common/notifications.js index 7fa1bc6ad..771a84c3c 100644 --- a/www/common/notifications.js +++ b/www/common/notifications.js @@ -316,6 +316,7 @@ define([ }; Messages.comments_notification = 'Replies to your comment "{0}" in {1}'; // XXX + Messages.unknownPad = "Unknown pad"; // XXX handlers['COMMENT_REPLY'] = function (common, data) { var content = data.content; var msg = content.msg; @@ -326,16 +327,18 @@ define([ if (msg.content.comment.length > 20) { comment += '...'; } - var title = Util.fixHTML(msg.content.title); + var title = Util.fixHTML(msg.content.title || Messages.unknownPad); var href = msg.content.href; content.getFormatText = function () { return Messages._getKey('comments_notification', [comment, title]); }; - content.handler = function () { - common.openURL(href); - defaultDismiss(common, data)(); - }; + if (href) { + content.handler = function () { + common.openURL(href); + defaultDismiss(common, data)(); + }; + } if (!content.archived) { content.dismissHandler = defaultDismiss(common, data); } @@ -348,16 +351,18 @@ define([ // Display the notification var name = Util.fixHTML(msg.content.user.displayName) || Messages.anonymous; - var title = Util.fixHTML(msg.content.title); + var title = Util.fixHTML(msg.content.title || Messages.unknownPad); var href = msg.content.href; content.getFormatText = function () { return Messages._getKey('mentions_notification', [name, title]); }; - content.handler = function () { - common.openURL(href); - defaultDismiss(common, data)(); - }; + if (href) { + content.handler = function () { + common.openURL(href); + defaultDismiss(common, data)(); + }; + } if (!content.archived) { content.dismissHandler = defaultDismiss(common, data); } diff --git a/www/common/outer/mailbox-handlers.js b/www/common/outer/mailbox-handlers.js index ea9af5778..841dadaf3 100644 --- a/www/common/outer/mailbox-handlers.js +++ b/www/common/outer/mailbox-handlers.js @@ -546,12 +546,12 @@ define([ var title, href; // Check if the pad is in our drive - if (!res.some(function (obj) { + res.some(function (obj) { if (!obj.data) { return; } - href = obj.data.href; + href = obj.data.href || obj.data.roHref; title = obj.data.filename || obj.data.title; return true; - })) { return void cb(true); } + }); // If we don't have the edit url, ignore this notification if (!href) { return void cb(true); } @@ -596,16 +596,17 @@ define([ var channel = content.channel; if (!channel) { return void cb(true); } var res = ctx.store.manager.findChannel(channel); + console.log(res); if (!res.length) { return void cb(true); } var title, href; // Check if the pad is in our drive - if (!res.some(function (obj) { + res.some(function (obj) { if (!obj.data) { return; } - href = obj.data.href || obj.data.roHref; // XXX send the href when we mention? + href = obj.data.href || obj.data.roHref; title = obj.data.filename || obj.data.title; return true; - })) { return void cb(true); } + }); // Add the title content.href = href; diff --git a/www/pad/comments.js b/www/pad/comments.js index dc2bffead..0133a47c4 100644 --- a/www/pad/comments.js +++ b/www/pad/comments.js @@ -195,7 +195,9 @@ define([ // Send notification var privateData = Env.metadataMgr.getPrivateData(); + var userData = Env.metadataMgr.getUserData(); Object.keys(notify).forEach(function (curve) { + if (curve === userData.curvePublic) { return; } Env.common.mailbox.sendTo("MENTION", { channel: privateData.channel, }, {