adding pinned messages (wip)
This commit is contained in:
+2
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "tinode-webapp",
|
||||
"description": "Tinode messenger for the web",
|
||||
"version": "0.22.2",
|
||||
"version": "0.23.0-rc1",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/tinode/webapp.git"
|
||||
@@ -71,7 +71,7 @@
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-intl": "^6.3.0",
|
||||
"tinode-sdk": "^0.22.2",
|
||||
"tinode-sdk": "^0.23.0-rc1",
|
||||
"webm-duration-fix": "^1.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1647,5 +1647,19 @@
|
||||
"description": "Label for busy call line",
|
||||
"missing": false,
|
||||
"obsolete": false
|
||||
},
|
||||
"pin_message": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Pin",
|
||||
"description": "Menu item [Pin] for pinning message to the top.",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
},
|
||||
"unpin_message": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Unpin",
|
||||
"description": "Menu item [Unpin] for un-pinning the message.",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1647,5 +1647,19 @@
|
||||
"description": "Label for busy call line",
|
||||
"missing": false,
|
||||
"obsolete": false
|
||||
},
|
||||
"pin_message": {
|
||||
"translation": "Pin",
|
||||
"defaultMessage": "Pin",
|
||||
"description": "Menu item [Pin] for pinning message to the top.",
|
||||
"missing": false,
|
||||
"obsolete": false
|
||||
},
|
||||
"unpin_message": {
|
||||
"translation": "Unpin",
|
||||
"defaultMessage": "Unpin",
|
||||
"description": "Menu item [Unpin] for un-pinning the message.",
|
||||
"missing": false,
|
||||
"obsolete": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1647,5 +1647,19 @@
|
||||
"description": "Label for busy call line",
|
||||
"missing": false,
|
||||
"obsolete": false
|
||||
},
|
||||
"pin_message": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Pin",
|
||||
"description": "Menu item [Pin] for pinning message to the top.",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
},
|
||||
"unpin_message": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Unpin",
|
||||
"description": "Menu item [Unpin] for un-pinning the message.",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -756,6 +756,10 @@
|
||||
"defaultMessage": "phone",
|
||||
"description": "Dative case of 'phone', i.e. 'phone' in 'by phone'"
|
||||
},
|
||||
"pin_message": {
|
||||
"defaultMessage": "Pin",
|
||||
"description": "Menu item [Pin] for pinning message to the top."
|
||||
},
|
||||
"private_editing_placeholder": {
|
||||
"defaultMessage": "Visible to you only",
|
||||
"description": "Placeholder for editing 'private'"
|
||||
@@ -912,6 +916,10 @@
|
||||
"defaultMessage": "Unnamed",
|
||||
"description": "Title shown when the topic has no name"
|
||||
},
|
||||
"unpin_message": {
|
||||
"defaultMessage": "Unpin",
|
||||
"description": "Menu item [Unpin] for un-pinning the message."
|
||||
},
|
||||
"unrecognized_video_format": {
|
||||
"defaultMessage": "Format of this video is not recognized",
|
||||
"description": "Error message when uploaded video is invalid"
|
||||
|
||||
@@ -1647,5 +1647,19 @@
|
||||
"description": "Label for busy call line",
|
||||
"missing": false,
|
||||
"obsolete": false
|
||||
},
|
||||
"pin_message": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Pin",
|
||||
"description": "Menu item [Pin] for pinning message to the top.",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
},
|
||||
"unpin_message": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Unpin",
|
||||
"description": "Menu item [Unpin] for un-pinning the message.",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1647,5 +1647,19 @@
|
||||
"description": "Label for busy call line",
|
||||
"missing": false,
|
||||
"obsolete": false
|
||||
},
|
||||
"pin_message": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Pin",
|
||||
"description": "Menu item [Pin] for pinning message to the top.",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
},
|
||||
"unpin_message": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Unpin",
|
||||
"description": "Menu item [Unpin] for un-pinning the message.",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1647,5 +1647,19 @@
|
||||
"description": "Label for busy call line",
|
||||
"missing": false,
|
||||
"obsolete": false
|
||||
},
|
||||
"pin_message": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Pin",
|
||||
"description": "Menu item [Pin] for pinning message to the top.",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
},
|
||||
"unpin_message": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Unpin",
|
||||
"description": "Menu item [Unpin] for un-pinning the message.",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1647,5 +1647,19 @@
|
||||
"description": "Label for busy call line",
|
||||
"missing": false,
|
||||
"obsolete": false
|
||||
},
|
||||
"pin_message": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Pin",
|
||||
"description": "Menu item [Pin] for pinning message to the top.",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
},
|
||||
"unpin_message": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Unpin",
|
||||
"description": "Menu item [Unpin] for un-pinning the message.",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1647,5 +1647,19 @@
|
||||
"description": "Label for busy call line",
|
||||
"missing": false,
|
||||
"obsolete": false
|
||||
},
|
||||
"pin_message": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Pin",
|
||||
"description": "Menu item [Pin] for pinning message to the top.",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
},
|
||||
"unpin_message": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Unpin",
|
||||
"description": "Menu item [Unpin] for un-pinning the message.",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1647,5 +1647,19 @@
|
||||
"description": "Label for busy call line",
|
||||
"missing": false,
|
||||
"obsolete": false
|
||||
},
|
||||
"pin_message": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Pin",
|
||||
"description": "Menu item [Pin] for pinning message to the top.",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
},
|
||||
"unpin_message": {
|
||||
"translation": "",
|
||||
"defaultMessage": "Unpin",
|
||||
"description": "Menu item [Unpin] for un-pinning the message.",
|
||||
"missing": true,
|
||||
"obsolete": false
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
// This is a generated file. Don't edit.
|
||||
|
||||
export const PACKAGE_VERSION = "0.22.2";
|
||||
export const PACKAGE_VERSION = "0.23.0-rc1";
|
||||
|
||||
@@ -123,6 +123,7 @@ class MessagesView extends React.Component {
|
||||
this.handleDescChange = this.handleDescChange.bind(this);
|
||||
this.handleSubsUpdated = this.handleSubsUpdated.bind(this);
|
||||
this.handleMessageUpdate = this.handleMessageUpdate.bind(this);
|
||||
this.handleAuxUpdate = this.handleAuxUpdate.bind(this);
|
||||
this.handleAllMessagesReceived = this.handleAllMessagesReceived.bind(this);
|
||||
this.handleInfoReceipt = this.handleInfoReceipt.bind(this);
|
||||
this.handleExpandMedia = this.handleExpandMedia.bind(this);
|
||||
@@ -234,6 +235,7 @@ class MessagesView extends React.Component {
|
||||
topic.onMetaDesc = this.handleDescChange;
|
||||
topic.onSubsUpdated = this.handleSubsUpdated;
|
||||
topic.onPres = this.handleSubsUpdated;
|
||||
topic.onAux = this.handleAuxUpdate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,7 +361,8 @@ class MessagesView extends React.Component {
|
||||
minSeqId: topic.minMsgSeq(),
|
||||
maxSeqId: topic.maxMsgSeq(),
|
||||
latestClearId: topic.maxClearId(),
|
||||
channel: topic.isChannelType()
|
||||
channel: topic.isChannelType(),
|
||||
pins: topic.aux('pins')
|
||||
});
|
||||
|
||||
if (nextProps.callTopic == topic.name && shouldPresentCallPanel(nextProps.callState)) {
|
||||
@@ -393,6 +396,9 @@ class MessagesView extends React.Component {
|
||||
if (nextProps.acs.isReader() != prevState.isReader) {
|
||||
nextState.isReader = !prevState.isReader;
|
||||
}
|
||||
if (nextProps.acs.isAdmin() != prevState.isAdmin) {
|
||||
nextState.isAdmin = !prevState.isAdmin;
|
||||
}
|
||||
if (!nextProps.acs.isReader('given') != prevState.readingBlocked) {
|
||||
nextState.readingBlocked = !prevState.readingBlocked;
|
||||
}
|
||||
@@ -406,6 +412,9 @@ class MessagesView extends React.Component {
|
||||
if (prevState.isReader) {
|
||||
nextState.isReader = false;
|
||||
}
|
||||
if (prevState.isAdmin) {
|
||||
nextState.isAdmin = false;
|
||||
}
|
||||
if (!prevState.readingBlocked) {
|
||||
prevState.readingBlocked = true;
|
||||
}
|
||||
@@ -582,6 +591,7 @@ class MessagesView extends React.Component {
|
||||
this.setState({
|
||||
isWriter: desc.acs.isWriter(),
|
||||
isReader: desc.acs.isReader(),
|
||||
isAdmin: desc.acs.isAdmin(),
|
||||
readingBlocked: !desc.acs.isReader('given'),
|
||||
unconfirmed: isUnconfirmed(desc.acs),
|
||||
});
|
||||
@@ -722,6 +732,10 @@ class MessagesView extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
handleAuxUpdate(aux) {
|
||||
this.setState({pins: aux['pins']});
|
||||
}
|
||||
|
||||
handleInfoReceipt(info) {
|
||||
switch (info.what) {
|
||||
case 'kp': {
|
||||
@@ -748,9 +762,9 @@ class MessagesView extends React.Component {
|
||||
}
|
||||
|
||||
if (content.video) {
|
||||
this.setState({ videoPostview: content });
|
||||
this.setState({videoPostview: content});
|
||||
} else {
|
||||
this.setState({ imagePostview: content });
|
||||
this.setState({imagePostview: content});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1479,6 +1493,7 @@ class MessagesView extends React.Component {
|
||||
received={deliveryStatus}
|
||||
uploader={msg._uploader}
|
||||
userIsWriter={this.state.isWriter}
|
||||
userIsAdmin={this.state.isAdmin}
|
||||
viewportWidth={this.props.viewportWidth} // Used by `formatter`.
|
||||
showContextMenu={this.handleShowMessageContextMenu}
|
||||
onExpandMedia={this.handleExpandMedia}
|
||||
@@ -1594,6 +1609,7 @@ class MessagesView extends React.Component {
|
||||
}<ContactBadges badges={icon_badges} /></div>
|
||||
<div id="topic-last-seen">{lastSeen}</div>
|
||||
</div>
|
||||
<div>{this.state.pins}</div>
|
||||
{groupTopic ?
|
||||
<GroupSubs
|
||||
tinode={this.props.tinode}
|
||||
|
||||
@@ -93,23 +93,28 @@ class BaseChatMessage extends React.PureComponent {
|
||||
if (this.props.received == Tinode.MESSAGE_STATUS_FAILED) {
|
||||
menuItems.push('menu_item_send_retry');
|
||||
}
|
||||
if (this.props.userIsWriter && this.props.received > Tinode.MESSAGE_STATUS_FATAL) {
|
||||
menuItems.push('menu_item_reply');
|
||||
if (!this.props.response) {
|
||||
let immutable = false;
|
||||
Drafty.entities(this.props.content, (_0, _1, tp) => {
|
||||
immutable = ['AU', 'EX', 'FM', 'IM', 'VC', 'VD'].includes(tp);
|
||||
return immutable;
|
||||
});
|
||||
if (!immutable) {
|
||||
Drafty.styles(this.props.content, tp => {
|
||||
immutable = ['QQ'].includes(tp);
|
||||
if (this.props.received > Tinode.MESSAGE_STATUS_FATAL) {
|
||||
if (this.props.userIsWriter) {
|
||||
menuItems.push('menu_item_reply');
|
||||
if (!this.props.response) {
|
||||
let immutable = false;
|
||||
Drafty.entities(this.props.content, (_0, _1, tp) => {
|
||||
immutable = ['AU', 'EX', 'FM', 'IM', 'VC', 'VD'].includes(tp);
|
||||
return immutable;
|
||||
});
|
||||
if (!immutable) {
|
||||
Drafty.styles(this.props.content, tp => {
|
||||
immutable = ['QQ'].includes(tp);
|
||||
return immutable;
|
||||
});
|
||||
}
|
||||
if (!immutable) {
|
||||
menuItems.push('menu_item_edit');
|
||||
}
|
||||
}
|
||||
if (!immutable) {
|
||||
menuItems.push('menu_item_edit');
|
||||
}
|
||||
}
|
||||
if (this.props.userIsAdmin) {
|
||||
menuItems.push('menu_item_pin');
|
||||
}
|
||||
}
|
||||
menuItems.push('menu_item_forward');
|
||||
|
||||
@@ -116,6 +116,16 @@ const messages = defineMessages({
|
||||
defaultMessage: 'Are you sure you want to clear all messages? It cannot be undone.',
|
||||
description: 'Alert dialog warning when deleting all messages.'
|
||||
},
|
||||
pin_message: {
|
||||
id: 'pin_message',
|
||||
defaultMessage: 'Pin',
|
||||
description: 'Menu item [Pin] for pinning message to the top.'
|
||||
},
|
||||
unpin_message: {
|
||||
id: 'unpin_message',
|
||||
defaultMessage: 'Unpin',
|
||||
description: 'Menu item [Unpin] for un-pinning the message.'
|
||||
},
|
||||
});
|
||||
|
||||
class ContextMenu extends React.Component {
|
||||
@@ -205,6 +215,20 @@ class ContextMenu extends React.Component {
|
||||
return this.editMessage(params, errorHandler);
|
||||
}
|
||||
},
|
||||
'menu_item_pin': {
|
||||
id: 'menu_item_pin',
|
||||
title: formatMessage(messages.pin_message),
|
||||
handler: (params, errorHandler) => {
|
||||
return this.pinMessage(true, params, errorHandler);
|
||||
}
|
||||
},
|
||||
'menu_item_unpin': {
|
||||
id: 'menu_item_unpin',
|
||||
title: formatMessage(messages.unpin_message),
|
||||
handler: (params, errorHandler) => {
|
||||
return this.pinMessage(false, params, errorHandler);
|
||||
}
|
||||
},
|
||||
'topic_unmute': {
|
||||
id: 'topic_unmute',
|
||||
title: formatMessage(messages.unmute),
|
||||
@@ -428,6 +452,37 @@ class ContextMenu extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
// Pin or unpin the message.
|
||||
pinMessage(pin, params, errorHandler) {
|
||||
const topic = this.props.tinode.getTopic(params.topicName);
|
||||
if (!topic) {
|
||||
return;
|
||||
}
|
||||
|
||||
let pinned = topic.aux('pins');
|
||||
console.log("topic.aux[pins]=", pinned);
|
||||
if (!Array.isArray(pinned)) {
|
||||
pinned = [];
|
||||
}
|
||||
let changed = false;
|
||||
if (pin) {
|
||||
if (!pinned.includes(params.seq)) {
|
||||
changed = true;
|
||||
pinned.push(params.seq);
|
||||
}
|
||||
} else {
|
||||
if (pinned.includes(params.seq)) {
|
||||
changed = true;
|
||||
pinned = pinned.filter(seq => seq != params.seq)
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
console.log("sending pins=", pinned);
|
||||
topic.setMeta({aux: {pins: pinned}})
|
||||
.catch(err => errorHandler ? errorHandler(err.message, 'err') : null);
|
||||
}
|
||||
}
|
||||
|
||||
// Function is used by context menu to set permissions.
|
||||
topicPermissionSetter(mode, params, errorHandler) {
|
||||
const topic = this.props.tinode.getTopic(params.topicName);
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+97
-17
@@ -3589,7 +3589,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "PACKAGE_VERSION": () => (/* binding */ PACKAGE_VERSION)
|
||||
/* harmony export */ });
|
||||
const PACKAGE_VERSION = "0.22.2";
|
||||
const PACKAGE_VERSION = "0.23.0-rc1";
|
||||
|
||||
/***/ }),
|
||||
|
||||
@@ -5194,6 +5194,7 @@ class MessagesView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
|
||||
this.handleDescChange = this.handleDescChange.bind(this);
|
||||
this.handleSubsUpdated = this.handleSubsUpdated.bind(this);
|
||||
this.handleMessageUpdate = this.handleMessageUpdate.bind(this);
|
||||
this.handleAuxUpdate = this.handleAuxUpdate.bind(this);
|
||||
this.handleAllMessagesReceived = this.handleAllMessagesReceived.bind(this);
|
||||
this.handleInfoReceipt = this.handleInfoReceipt.bind(this);
|
||||
this.handleExpandMedia = this.handleExpandMedia.bind(this);
|
||||
@@ -5277,6 +5278,7 @@ class MessagesView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
|
||||
topic.onMetaDesc = this.handleDescChange;
|
||||
topic.onSubsUpdated = this.handleSubsUpdated;
|
||||
topic.onPres = this.handleSubsUpdated;
|
||||
topic.onAux = this.handleAuxUpdate;
|
||||
}
|
||||
}
|
||||
if (!this.props.applicationVisible) {
|
||||
@@ -5386,7 +5388,8 @@ class MessagesView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
|
||||
minSeqId: topic.minMsgSeq(),
|
||||
maxSeqId: topic.maxMsgSeq(),
|
||||
latestClearId: topic.maxClearId(),
|
||||
channel: topic.isChannelType()
|
||||
channel: topic.isChannelType(),
|
||||
pins: topic.aux('pins')
|
||||
});
|
||||
if (nextProps.callTopic == topic.name && shouldPresentCallPanel(nextProps.callState)) {
|
||||
nextState.rtcPanel = nextProps.callTopic;
|
||||
@@ -5415,6 +5418,9 @@ class MessagesView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
|
||||
if (nextProps.acs.isReader() != prevState.isReader) {
|
||||
nextState.isReader = !prevState.isReader;
|
||||
}
|
||||
if (nextProps.acs.isAdmin() != prevState.isAdmin) {
|
||||
nextState.isAdmin = !prevState.isAdmin;
|
||||
}
|
||||
if (!nextProps.acs.isReader('given') != prevState.readingBlocked) {
|
||||
nextState.readingBlocked = !prevState.readingBlocked;
|
||||
}
|
||||
@@ -5428,6 +5434,9 @@ class MessagesView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
|
||||
if (prevState.isReader) {
|
||||
nextState.isReader = false;
|
||||
}
|
||||
if (prevState.isAdmin) {
|
||||
nextState.isAdmin = false;
|
||||
}
|
||||
if (!prevState.readingBlocked) {
|
||||
prevState.readingBlocked = true;
|
||||
}
|
||||
@@ -5576,6 +5585,7 @@ class MessagesView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
|
||||
this.setState({
|
||||
isWriter: desc.acs.isWriter(),
|
||||
isReader: desc.acs.isReader(),
|
||||
isAdmin: desc.acs.isAdmin(),
|
||||
readingBlocked: !desc.acs.isReader('given'),
|
||||
unconfirmed: isUnconfirmed(desc.acs)
|
||||
});
|
||||
@@ -5698,6 +5708,11 @@ class MessagesView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
|
||||
this.postReadNotification(0);
|
||||
}
|
||||
}
|
||||
handleAuxUpdate(aux) {
|
||||
this.setState({
|
||||
pins: aux['pins']
|
||||
});
|
||||
}
|
||||
handleInfoReceipt(info) {
|
||||
switch (info.what) {
|
||||
case 'kp':
|
||||
@@ -6368,6 +6383,7 @@ class MessagesView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
|
||||
received: deliveryStatus,
|
||||
uploader: msg._uploader,
|
||||
userIsWriter: this.state.isWriter,
|
||||
userIsAdmin: this.state.isAdmin,
|
||||
viewportWidth: this.props.viewportWidth,
|
||||
showContextMenu: this.handleShowMessageContextMenu,
|
||||
onExpandMedia: this.handleExpandMedia,
|
||||
@@ -6496,7 +6512,7 @@ class MessagesView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
|
||||
badges: icon_badges
|
||||
})), react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
||||
id: "topic-last-seen"
|
||||
}, lastSeen)), groupTopic ? react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_widgets_group_subs_jsx__WEBPACK_IMPORTED_MODULE_8__["default"], {
|
||||
}, lastSeen)), react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", null, this.state.pins), groupTopic ? react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_widgets_group_subs_jsx__WEBPACK_IMPORTED_MODULE_8__["default"], {
|
||||
tinode: this.props.tinode,
|
||||
subscribers: this.state.onlineSubs
|
||||
}) : react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
||||
@@ -11078,23 +11094,28 @@ class BaseChatMessage extends (react__WEBPACK_IMPORTED_MODULE_0___default().Pure
|
||||
if (this.props.received == tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Tinode.MESSAGE_STATUS_FAILED) {
|
||||
menuItems.push('menu_item_send_retry');
|
||||
}
|
||||
if (this.props.userIsWriter && this.props.received > tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Tinode.MESSAGE_STATUS_FATAL) {
|
||||
menuItems.push('menu_item_reply');
|
||||
if (!this.props.response) {
|
||||
let immutable = false;
|
||||
tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Drafty.entities(this.props.content, (_0, _1, tp) => {
|
||||
immutable = ['AU', 'EX', 'FM', 'IM', 'VC', 'VD'].includes(tp);
|
||||
return immutable;
|
||||
});
|
||||
if (!immutable) {
|
||||
tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Drafty.styles(this.props.content, tp => {
|
||||
immutable = ['QQ'].includes(tp);
|
||||
if (this.props.received > tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Tinode.MESSAGE_STATUS_FATAL) {
|
||||
if (this.props.userIsWriter) {
|
||||
menuItems.push('menu_item_reply');
|
||||
if (!this.props.response) {
|
||||
let immutable = false;
|
||||
tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Drafty.entities(this.props.content, (_0, _1, tp) => {
|
||||
immutable = ['AU', 'EX', 'FM', 'IM', 'VC', 'VD'].includes(tp);
|
||||
return immutable;
|
||||
});
|
||||
if (!immutable) {
|
||||
tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Drafty.styles(this.props.content, tp => {
|
||||
immutable = ['QQ'].includes(tp);
|
||||
return immutable;
|
||||
});
|
||||
}
|
||||
if (!immutable) {
|
||||
menuItems.push('menu_item_edit');
|
||||
}
|
||||
}
|
||||
if (!immutable) {
|
||||
menuItems.push('menu_item_edit');
|
||||
}
|
||||
}
|
||||
if (this.props.userIsAdmin) {
|
||||
menuItems.push('menu_item_pin');
|
||||
}
|
||||
}
|
||||
menuItems.push('menu_item_forward');
|
||||
@@ -12077,6 +12098,20 @@ const messages = (0,react_intl__WEBPACK_IMPORTED_MODULE_1__.defineMessages)({
|
||||
"type": 0,
|
||||
"value": "Are you sure you want to clear all messages? It cannot be undone."
|
||||
}]
|
||||
},
|
||||
pin_message: {
|
||||
id: "pin_message",
|
||||
defaultMessage: [{
|
||||
"type": 0,
|
||||
"value": "Pin"
|
||||
}]
|
||||
},
|
||||
unpin_message: {
|
||||
id: "unpin_message",
|
||||
defaultMessage: [{
|
||||
"type": 0,
|
||||
"value": "Unpin"
|
||||
}]
|
||||
}
|
||||
});
|
||||
class ContextMenu extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component) {
|
||||
@@ -12153,6 +12188,20 @@ class ContextMenu extends (react__WEBPACK_IMPORTED_MODULE_0___default().Componen
|
||||
return this.editMessage(params, errorHandler);
|
||||
}
|
||||
},
|
||||
'menu_item_pin': {
|
||||
id: 'menu_item_pin',
|
||||
title: formatMessage(messages.pin_message),
|
||||
handler: (params, errorHandler) => {
|
||||
return this.pinMessage(true, params, errorHandler);
|
||||
}
|
||||
},
|
||||
'menu_item_unpin': {
|
||||
id: 'menu_item_unpin',
|
||||
title: formatMessage(messages.unpin_message),
|
||||
handler: (params, errorHandler) => {
|
||||
return this.pinMessage(false, params, errorHandler);
|
||||
}
|
||||
},
|
||||
'topic_unmute': {
|
||||
id: 'topic_unmute',
|
||||
title: formatMessage(messages.unmute),
|
||||
@@ -12334,6 +12383,37 @@ class ContextMenu extends (react__WEBPACK_IMPORTED_MODULE_0___default().Componen
|
||||
}
|
||||
});
|
||||
}
|
||||
pinMessage(pin, params, errorHandler) {
|
||||
const topic = this.props.tinode.getTopic(params.topicName);
|
||||
if (!topic) {
|
||||
return;
|
||||
}
|
||||
let pinned = topic.aux('pins');
|
||||
console.log("topic.aux[pins]=", pinned);
|
||||
if (!Array.isArray(pinned)) {
|
||||
pinned = [];
|
||||
}
|
||||
let changed = false;
|
||||
if (pin) {
|
||||
if (!pinned.includes(params.seq)) {
|
||||
changed = true;
|
||||
pinned.push(params.seq);
|
||||
}
|
||||
} else {
|
||||
if (pinned.includes(params.seq)) {
|
||||
changed = true;
|
||||
pinned = pinned.filter(seq => seq != params.seq);
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
console.log("sending pins=", pinned);
|
||||
topic.setMeta({
|
||||
aux: {
|
||||
pins: pinned
|
||||
}
|
||||
}).catch(err => errorHandler ? errorHandler(err.message, 'err') : null);
|
||||
}
|
||||
}
|
||||
topicPermissionSetter(mode, params, errorHandler) {
|
||||
const topic = this.props.tinode.getTopic(params.topicName);
|
||||
if (!topic) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+28
-6
@@ -1306,7 +1306,7 @@ function _serializeMessage(dst, msg) {
|
||||
}
|
||||
var _topic_fields = {
|
||||
writable: true,
|
||||
value: ['created', 'updated', 'deleted', 'read', 'recv', 'seq', 'clear', 'defacs', 'creds', 'public', 'trusted', 'private', 'touched', '_deleted']
|
||||
value: ['created', 'updated', 'deleted', 'touched', 'read', 'recv', 'seq', 'clear', 'defacs', 'creds', 'public', 'trusted', 'private', 'tags', 'aux', '_deleted']
|
||||
};
|
||||
|
||||
/***/ }),
|
||||
@@ -3419,6 +3419,7 @@ class Topic {
|
||||
this._recvNotificationTimer = null;
|
||||
this._tags = [];
|
||||
this._credentials = [];
|
||||
this._aux = {};
|
||||
this._messageVersions = {};
|
||||
this._messages = new _cbuffer_js__WEBPACK_IMPORTED_MODULE_1__["default"]((a, b) => {
|
||||
return a.seq - b.seq;
|
||||
@@ -3438,6 +3439,7 @@ class Topic {
|
||||
this.onSubsUpdated = callbacks.onSubsUpdated;
|
||||
this.onTagsUpdated = callbacks.onTagsUpdated;
|
||||
this.onCredsUpdated = callbacks.onCredsUpdated;
|
||||
this.onAuxUpdated = callbacks.onAuxUpdated;
|
||||
this.onDeleteTopic = callbacks.onDeleteTopic;
|
||||
this.onAllMessagesReceived = callbacks.onAllMessagesReceived;
|
||||
}
|
||||
@@ -3682,6 +3684,9 @@ class Topic {
|
||||
if (params.cred) {
|
||||
this._processMetaCreds([params.cred], true);
|
||||
}
|
||||
if (params.aux) {
|
||||
this._processMetaAux(params.aux, true);
|
||||
}
|
||||
return ctrl;
|
||||
});
|
||||
}
|
||||
@@ -3944,6 +3949,9 @@ class Topic {
|
||||
tags() {
|
||||
return this._tags.slice(0);
|
||||
}
|
||||
aux(key) {
|
||||
return this._aux[key];
|
||||
}
|
||||
subscriber(uid) {
|
||||
return this._users[uid];
|
||||
}
|
||||
@@ -4244,6 +4252,9 @@ class Topic {
|
||||
if (meta.cred) {
|
||||
this._processMetaCreds(meta.cred);
|
||||
}
|
||||
if (meta.aux) {
|
||||
this._processMetaAux(meta.aux);
|
||||
}
|
||||
if (this.onMeta) {
|
||||
this.onMeta(meta);
|
||||
}
|
||||
@@ -4385,7 +4396,7 @@ class Topic {
|
||||
}
|
||||
}
|
||||
_processMetaTags(tags) {
|
||||
if (tags.length == 1 && tags[0] == _config_js__WEBPACK_IMPORTED_MODULE_3__.DEL_CHAR) {
|
||||
if (tags == _config_js__WEBPACK_IMPORTED_MODULE_3__.DEL_CHAR || tags.length == 1 && tags[0] == _config_js__WEBPACK_IMPORTED_MODULE_3__.DEL_CHAR) {
|
||||
tags = [];
|
||||
}
|
||||
this._tags = tags;
|
||||
@@ -4394,13 +4405,20 @@ class Topic {
|
||||
}
|
||||
}
|
||||
_processMetaCreds(creds) {}
|
||||
_processMetaAux(aux) {
|
||||
aux = !aux || aux == _config_js__WEBPACK_IMPORTED_MODULE_3__.DEL_CHAR ? {} : aux;
|
||||
this._aux = (0,_utils_js__WEBPACK_IMPORTED_MODULE_6__.mergeObj)(this._aux, aux);
|
||||
if (this.onAuxUpdated) {
|
||||
this.onAuxUpdated(this._aux);
|
||||
}
|
||||
}
|
||||
_processDelMessages(clear, delseq) {
|
||||
this._maxDel = Math.max(clear, this._maxDel);
|
||||
this.clear = Math.max(clear, this.clear);
|
||||
const topic = this;
|
||||
let count = 0;
|
||||
if (Array.isArray(delseq)) {
|
||||
delseq.forEach(function (range) {
|
||||
delseq.forEach(range => {
|
||||
if (!range.hi) {
|
||||
count++;
|
||||
topic.flushMessage(range.low);
|
||||
@@ -4944,7 +4962,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "PACKAGE_VERSION": () => (/* binding */ PACKAGE_VERSION)
|
||||
/* harmony export */ });
|
||||
const PACKAGE_VERSION = "0.22.2";
|
||||
const PACKAGE_VERSION = "0.23.0-rc1";
|
||||
|
||||
/***/ })
|
||||
|
||||
@@ -5664,6 +5682,9 @@ class Tinode {
|
||||
if (setParams.tags) {
|
||||
pkt.sub.set.tags = setParams.tags;
|
||||
}
|
||||
if (setParams.aux) {
|
||||
pkt.sub.set.aux = setParams.aux;
|
||||
}
|
||||
}
|
||||
return _classPrivateMethodGet(this, _send, _send2).call(this, pkt, pkt.sub.id);
|
||||
}
|
||||
@@ -5778,7 +5799,8 @@ class Tinode {
|
||||
const pkt = _classPrivateMethodGet(this, _initPacket, _initPacket2).call(this, 'set', topic);
|
||||
const what = [];
|
||||
if (params) {
|
||||
['desc', 'sub', 'tags', 'cred', 'ephemeral'].forEach(function (key) {
|
||||
console.log("setMeta, params=", params);
|
||||
['desc', 'sub', 'tags', 'cred', 'aux'].forEach(key => {
|
||||
if (params.hasOwnProperty(key)) {
|
||||
what.push(key);
|
||||
pkt.set[key] = params[key];
|
||||
@@ -6204,7 +6226,7 @@ function _initPacket2(type, topic) {
|
||||
'desc': {},
|
||||
'sub': {},
|
||||
'tags': [],
|
||||
'ephemeral': {}
|
||||
'aux': {}
|
||||
}
|
||||
};
|
||||
case 'del':
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,3 +1,3 @@
|
||||
// This is a generated file. Don't edit.
|
||||
|
||||
const PACKAGE_VERSION = "0.22.2";
|
||||
const PACKAGE_VERSION = "0.23.0-rc1";
|
||||
|
||||
Reference in New Issue
Block a user