forwarding from channels and some other minor fixes

This commit is contained in:
or-else
2021-10-05 16:42:10 -07:00
parent 8f672405bc
commit fb2b4b337b
8 changed files with 37 additions and 19 deletions
+9 -4
View File
@@ -102,7 +102,7 @@ class MessagesView extends React.Component {
this.handleClosePreview = this.handleClosePreview.bind(this); this.handleClosePreview = this.handleClosePreview.bind(this);
this.handleFormResponse = this.handleFormResponse.bind(this); this.handleFormResponse = this.handleFormResponse.bind(this);
this.handleContextClick = this.handleContextClick.bind(this); this.handleContextClick = this.handleContextClick.bind(this);
this.handleShowContextMenuMessage = this.handleShowContextMenuMessage.bind(this); this.handleShowMessageContextMenu = this.handleShowMessageContextMenu.bind(this);
this.handleNewChatAcceptance = this.handleNewChatAcceptance.bind(this); this.handleNewChatAcceptance = this.handleNewChatAcceptance.bind(this);
this.handleEnablePeer = this.handleEnablePeer.bind(this); this.handleEnablePeer = this.handleEnablePeer.bind(this);
this.handleAttachFile = this.handleAttachFile.bind(this); this.handleAttachFile = this.handleAttachFile.bind(this);
@@ -642,7 +642,11 @@ class MessagesView extends React.Component {
this.props.showContextMenu({ topicName: this.state.topic, y: e.pageY, x: e.pageX }); this.props.showContextMenu({ topicName: this.state.topic, y: e.pageY, x: e.pageX });
} }
handleShowContextMenuMessage(params, messageSpecificMenuItems) { handleShowMessageContextMenu(params, messageSpecificMenuItems) {
if (params.userFrom == 'chan') {
params.userFrom = this.state.topic;
params.userName = this.state.title;
}
params.topicName = this.state.topic; params.topicName = this.state.topic;
const menuItems = messageSpecificMenuItems || []; const menuItems = messageSpecificMenuItems || [];
const topic = this.props.tinode.getTopic(params.topicName); const topic = this.props.tinode.getTopic(params.topicName);
@@ -950,7 +954,7 @@ class MessagesView extends React.Component {
let previousFrom = null; let previousFrom = null;
let chatBoxClass = null; let chatBoxClass = null;
topic.messages((msg, prev, next, i) => { topic.messages((msg, prev, next, i) => {
let nextFrom = next ? (next.from || null) : 'chan'; let nextFrom = next ? (next.from || 'chan') : null;
let sequence = 'single'; let sequence = 'single';
let thisFrom = msg.from || 'chan'; let thisFrom = msg.from || 'chan';
@@ -994,6 +998,7 @@ class MessagesView extends React.Component {
response={isReply} response={isReply}
seq={msg.seq} seq={msg.seq}
isGroup={groupTopic} isGroup={groupTopic}
isChan={this.state.channel}
userFrom={userFrom} userFrom={userFrom}
userName={userName} userName={userName}
userAvatar={userAvatar} userAvatar={userAvatar}
@@ -1001,7 +1006,7 @@ class MessagesView extends React.Component {
received={deliveryStatus} received={deliveryStatus}
uploader={msg._uploader} uploader={msg._uploader}
viewportWidth={this.props.viewportWidth} // Used by `formatter`. viewportWidth={this.props.viewportWidth} // Used by `formatter`.
showContextMenu={this.state.channel? false : this.handleShowContextMenuMessage} showContextMenu={this.handleShowMessageContextMenu}
onImagePreview={this.handleImagePostview} onImagePreview={this.handleImagePostview}
onFormResponse={this.handleFormResponse} onFormResponse={this.handleFormResponse}
onError={this.props.onError} onError={this.props.onError}
+1 -1
View File
@@ -15,7 +15,7 @@ import InfoView from './info-view.jsx';
import MessagesView from './messages-view.jsx'; import MessagesView from './messages-view.jsx';
import SidepanelView from './sidepanel-view.jsx'; import SidepanelView from './sidepanel-view.jsx';
import { API_KEY, APP_NAME, DEFAULT_P2P_ACCESS_MODE, LOGGING_ENABLED, import { API_KEY, APP_NAME, DEFAULT_P2P_ACCESS_MODE, FORWARDED_PREVIEW_LENGTH, LOGGING_ENABLED,
MEDIA_BREAKPOINT, QUOTED_REPLY_LENGTH, RECEIVED_DELAY } from '../config.js'; MEDIA_BREAKPOINT, QUOTED_REPLY_LENGTH, RECEIVED_DELAY } from '../config.js';
import { PACKAGE_VERSION } from '../version.js'; import { PACKAGE_VERSION } from '../version.js';
import { base64ReEncode, makeImageUrl } from '../lib/blob-helpers.js'; import { base64ReEncode, makeImageUrl } from '../lib/blob-helpers.js';
+5 -2
View File
@@ -71,13 +71,16 @@ class BaseChatMessage extends React.PureComponent {
handleContextClick(e) { handleContextClick(e) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
const menuItems = this.props.received == Tinode.MESSAGE_STATUS_FAILED ? ['menu_item_send_retry'] : []; const menuItems = [];
if (this.props.received == Tinode.MESSAGE_STATUS_FAILED) {
menuItems.push('menu_item_send_retry');
}
if (this.props.userIsWriter && if (this.props.userIsWriter &&
this.props.received > Tinode.MESSAGE_STATUS_FAILED && this.props.received > Tinode.MESSAGE_STATUS_FAILED &&
this.props.received < Tinode.MESSAGE_STATUS_DEL_RANGE) { this.props.received < Tinode.MESSAGE_STATUS_DEL_RANGE) {
menuItems.push('menu_item_reply'); menuItems.push('menu_item_reply');
menuItems.push('menu_item_forward');
} }
menuItems.push('menu_item_forward');
this.props.showContextMenu({ this.props.showContextMenu({
seq: this.props.seq, seq: this.props.seq,
-1
View File
@@ -52,7 +52,6 @@ export default class ForwardDialog extends React.Component {
let contacts = this.state.query != null ? this.props.searchResults : this.props.contacts; let contacts = this.state.query != null ? this.props.searchResults : this.props.contacts;
// Filter out contacts without a 'W' or 'J' permissions as well as the current topic. // Filter out contacts without a 'W' or 'J' permissions as well as the current topic.
contacts = contacts.filter((c) => { contacts = contacts.filter((c) => {
console.log(c.name, this.props.topicSelected);
return (c.name != this.props.topicSelected) && c.acs.isJoiner() && c.acs.isWriter(); return (c.name != this.props.topicSelected) && c.acs.isJoiner() && c.acs.isWriter();
}); });
+19 -8
View File
@@ -41,6 +41,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export */ "MAX_TOPIC_DESCRIPTION_LENGTH": () => (/* binding */ MAX_TOPIC_DESCRIPTION_LENGTH), /* harmony export */ "MAX_TOPIC_DESCRIPTION_LENGTH": () => (/* binding */ MAX_TOPIC_DESCRIPTION_LENGTH),
/* harmony export */ "MESSAGE_PREVIEW_LENGTH": () => (/* binding */ MESSAGE_PREVIEW_LENGTH), /* harmony export */ "MESSAGE_PREVIEW_LENGTH": () => (/* binding */ MESSAGE_PREVIEW_LENGTH),
/* harmony export */ "QUOTED_REPLY_LENGTH": () => (/* binding */ QUOTED_REPLY_LENGTH), /* harmony export */ "QUOTED_REPLY_LENGTH": () => (/* binding */ QUOTED_REPLY_LENGTH),
/* harmony export */ "FORWARDED_PREVIEW_LENGTH": () => (/* binding */ FORWARDED_PREVIEW_LENGTH),
/* harmony export */ "LINK_CONTACT_US": () => (/* binding */ LINK_CONTACT_US), /* harmony export */ "LINK_CONTACT_US": () => (/* binding */ LINK_CONTACT_US),
/* harmony export */ "LINK_PRIVACY_POLICY": () => (/* binding */ LINK_PRIVACY_POLICY), /* harmony export */ "LINK_PRIVACY_POLICY": () => (/* binding */ LINK_PRIVACY_POLICY),
/* harmony export */ "LINK_TERMS_OF_SERVICE": () => (/* binding */ LINK_TERMS_OF_SERVICE) /* harmony export */ "LINK_TERMS_OF_SERVICE": () => (/* binding */ LINK_TERMS_OF_SERVICE)
@@ -81,6 +82,7 @@ const MAX_TITLE_LENGTH = 60;
const MAX_TOPIC_DESCRIPTION_LENGTH = 360; const MAX_TOPIC_DESCRIPTION_LENGTH = 360;
const MESSAGE_PREVIEW_LENGTH = 80; const MESSAGE_PREVIEW_LENGTH = 80;
const QUOTED_REPLY_LENGTH = 30; const QUOTED_REPLY_LENGTH = 30;
const FORWARDED_PREVIEW_LENGTH = 128;
const LINK_CONTACT_US = 'email:support@tinode.co'; const LINK_CONTACT_US = 'email:support@tinode.co';
const LINK_PRIVACY_POLICY = 'https://tinode.co/privacy.html'; const LINK_PRIVACY_POLICY = 'https://tinode.co/privacy.html';
const LINK_TERMS_OF_SERVICE = 'https://tinode.co/terms.html'; const LINK_TERMS_OF_SERVICE = 'https://tinode.co/terms.html';
@@ -3383,7 +3385,7 @@ class MessagesView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
this.handleClosePreview = this.handleClosePreview.bind(this); this.handleClosePreview = this.handleClosePreview.bind(this);
this.handleFormResponse = this.handleFormResponse.bind(this); this.handleFormResponse = this.handleFormResponse.bind(this);
this.handleContextClick = this.handleContextClick.bind(this); this.handleContextClick = this.handleContextClick.bind(this);
this.handleShowContextMenuMessage = this.handleShowContextMenuMessage.bind(this); this.handleShowMessageContextMenu = this.handleShowMessageContextMenu.bind(this);
this.handleNewChatAcceptance = this.handleNewChatAcceptance.bind(this); this.handleNewChatAcceptance = this.handleNewChatAcceptance.bind(this);
this.handleEnablePeer = this.handleEnablePeer.bind(this); this.handleEnablePeer = this.handleEnablePeer.bind(this);
this.handleAttachFile = this.handleAttachFile.bind(this); this.handleAttachFile = this.handleAttachFile.bind(this);
@@ -3950,7 +3952,12 @@ class MessagesView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
}); });
} }
handleShowContextMenuMessage(params, messageSpecificMenuItems) { handleShowMessageContextMenu(params, messageSpecificMenuItems) {
if (params.userFrom == 'chan') {
params.userFrom = this.state.topic;
params.userName = this.state.title;
}
params.topicName = this.state.topic; params.topicName = this.state.topic;
const menuItems = messageSpecificMenuItems || []; const menuItems = messageSpecificMenuItems || [];
const topic = this.props.tinode.getTopic(params.topicName); const topic = this.props.tinode.getTopic(params.topicName);
@@ -4266,7 +4273,7 @@ class MessagesView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
let previousFrom = null; let previousFrom = null;
let chatBoxClass = null; let chatBoxClass = null;
topic.messages((msg, prev, next, i) => { topic.messages((msg, prev, next, i) => {
let nextFrom = next ? next.from || null : 'chan'; let nextFrom = next ? next.from || 'chan' : null;
let sequence = 'single'; let sequence = 'single';
let thisFrom = msg.from || 'chan'; let thisFrom = msg.from || 'chan';
@@ -4311,6 +4318,7 @@ class MessagesView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
response: isReply, response: isReply,
seq: msg.seq, seq: msg.seq,
isGroup: groupTopic, isGroup: groupTopic,
isChan: this.state.channel,
userFrom: userFrom, userFrom: userFrom,
userName: userName, userName: userName,
userAvatar: userAvatar, userAvatar: userAvatar,
@@ -4318,7 +4326,7 @@ class MessagesView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
received: deliveryStatus, received: deliveryStatus,
uploader: msg._uploader, uploader: msg._uploader,
viewportWidth: this.props.viewportWidth, viewportWidth: this.props.viewportWidth,
showContextMenu: this.state.channel ? false : this.handleShowContextMenuMessage, showContextMenu: this.handleShowMessageContextMenu,
onImagePreview: this.handleImagePostview, onImagePreview: this.handleImagePostview,
onFormResponse: this.handleFormResponse, onFormResponse: this.handleFormResponse,
onError: this.props.onError, onError: this.props.onError,
@@ -6760,7 +6768,7 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
const header = '➦ ' + params.userName; const header = '➦ ' + params.userName;
const content = params.forwarded ? tinode_sdk__WEBPACK_IMPORTED_MODULE_4___default().Drafty.forwardedContent(params.content) : typeof params.content == 'string' ? tinode_sdk__WEBPACK_IMPORTED_MODULE_4___default().Drafty.init(params.content) : params.content; const content = params.forwarded ? tinode_sdk__WEBPACK_IMPORTED_MODULE_4___default().Drafty.forwardedContent(params.content) : typeof params.content == 'string' ? tinode_sdk__WEBPACK_IMPORTED_MODULE_4___default().Drafty.init(params.content) : params.content;
const preview = tinode_sdk__WEBPACK_IMPORTED_MODULE_4___default().Drafty.preview(content, _config_js__WEBPACK_IMPORTED_MODULE_11__.QUOTED_REPLY_LENGTH, undefined, params.forwarded != null); const preview = tinode_sdk__WEBPACK_IMPORTED_MODULE_4___default().Drafty.preview(content, _config_js__WEBPACK_IMPORTED_MODULE_11__.FORWARDED_PREVIEW_LENGTH, undefined, params.forwarded != null);
const msg = tinode_sdk__WEBPACK_IMPORTED_MODULE_4___default().Drafty.append(tinode_sdk__WEBPACK_IMPORTED_MODULE_4___default().Drafty.appendLineBreak(tinode_sdk__WEBPACK_IMPORTED_MODULE_4___default().Drafty.mention(header, params.userFrom)), content); const msg = tinode_sdk__WEBPACK_IMPORTED_MODULE_4___default().Drafty.append(tinode_sdk__WEBPACK_IMPORTED_MODULE_4___default().Drafty.appendLineBreak(tinode_sdk__WEBPACK_IMPORTED_MODULE_4___default().Drafty.mention(header, params.userFrom)), content);
const msgPreview = tinode_sdk__WEBPACK_IMPORTED_MODULE_4___default().Drafty.quote(header, params.userFrom, preview); const msgPreview = tinode_sdk__WEBPACK_IMPORTED_MODULE_4___default().Drafty.quote(header, params.userFrom, preview);
const head = { const head = {
@@ -7821,13 +7829,17 @@ class BaseChatMessage extends (react__WEBPACK_IMPORTED_MODULE_0___default().Pure
handleContextClick(e) { handleContextClick(e) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
const menuItems = this.props.received == Tinode.MESSAGE_STATUS_FAILED ? ['menu_item_send_retry'] : []; const menuItems = [];
if (this.props.received == Tinode.MESSAGE_STATUS_FAILED) {
menuItems.push('menu_item_send_retry');
}
if (this.props.userIsWriter && this.props.received > Tinode.MESSAGE_STATUS_FAILED && this.props.received < Tinode.MESSAGE_STATUS_DEL_RANGE) { if (this.props.userIsWriter && this.props.received > Tinode.MESSAGE_STATUS_FAILED && this.props.received < Tinode.MESSAGE_STATUS_DEL_RANGE) {
menuItems.push('menu_item_reply'); menuItems.push('menu_item_reply');
menuItems.push('menu_item_forward');
} }
menuItems.push('menu_item_forward');
this.props.showContextMenu({ this.props.showContextMenu({
seq: this.props.seq, seq: this.props.seq,
content: this.props.content, content: this.props.content,
@@ -9733,7 +9745,6 @@ class ForwardDialog extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compon
render() { render() {
let contacts = this.state.query != null ? this.props.searchResults : this.props.contacts; let contacts = this.state.query != null ? this.props.searchResults : this.props.contacts;
contacts = contacts.filter(c => { contacts = contacts.filter(c => {
console.log(c.name, this.props.topicSelected);
return c.name != this.props.topicSelected && c.acs.isJoiner() && c.acs.isWriter(); return c.name != this.props.topicSelected && c.acs.isJoiner() && c.acs.isWriter();
}); });
return react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", { return react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long