adding pinned messages (wip)
This commit is contained in:
+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
Reference in New Issue
Block a user