rebuilt
This commit is contained in:
+72
-8
@@ -410,6 +410,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ "EXPIRE_PROMISES_TIMEOUT": () => (/* binding */ EXPIRE_PROMISES_TIMEOUT),
|
||||
/* harmony export */ "LIBRARY": () => (/* binding */ LIBRARY),
|
||||
/* harmony export */ "LOCAL_SEQID": () => (/* binding */ LOCAL_SEQID),
|
||||
/* harmony export */ "MAX_PINNED_COUNT": () => (/* binding */ MAX_PINNED_COUNT),
|
||||
/* harmony export */ "MESSAGE_STATUS_FAILED": () => (/* binding */ MESSAGE_STATUS_FAILED),
|
||||
/* harmony export */ "MESSAGE_STATUS_FATAL": () => (/* binding */ MESSAGE_STATUS_FATAL),
|
||||
/* harmony export */ "MESSAGE_STATUS_NONE": () => (/* binding */ MESSAGE_STATUS_NONE),
|
||||
@@ -463,6 +464,7 @@ const EXPIRE_PROMISES_PERIOD = 1000;
|
||||
const RECV_TIMEOUT = 100;
|
||||
const DEFAULT_MESSAGES_PAGE = 24;
|
||||
const DEL_CHAR = '\u2421';
|
||||
const MAX_PINNED_COUNT = 5;
|
||||
|
||||
/***/ }),
|
||||
|
||||
@@ -1306,7 +1308,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', '_aux', '_deleted']
|
||||
};
|
||||
|
||||
/***/ }),
|
||||
@@ -3327,6 +3329,10 @@ class MetaGetBuilder {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
withAux() {
|
||||
this.what['aux'] = true;
|
||||
return this;
|
||||
}
|
||||
withDel(since, limit) {
|
||||
if (since || limit) {
|
||||
this.what['del'] = {
|
||||
@@ -3345,7 +3351,7 @@ class MetaGetBuilder {
|
||||
build() {
|
||||
const what = [];
|
||||
let params = {};
|
||||
['data', 'sub', 'desc', 'tags', 'cred', 'del'].forEach(key => {
|
||||
['data', 'sub', 'desc', 'tags', 'cred', 'aux', 'del'].forEach(key => {
|
||||
if (this.what.hasOwnProperty(key)) {
|
||||
what.push(key);
|
||||
if (Object.getOwnPropertyNames(this.what[key]).length > 0) {
|
||||
@@ -3425,6 +3431,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;
|
||||
@@ -3444,6 +3451,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;
|
||||
}
|
||||
@@ -3688,6 +3696,9 @@ class Topic {
|
||||
if (params.cred) {
|
||||
this._processMetaCreds([params.cred], true);
|
||||
}
|
||||
if (params.aux) {
|
||||
this._processMetaAux(params.aux);
|
||||
}
|
||||
return ctrl;
|
||||
});
|
||||
}
|
||||
@@ -3721,6 +3732,38 @@ class Topic {
|
||||
}
|
||||
});
|
||||
}
|
||||
pinMessage(seq, pin) {
|
||||
let pinned = this.aux('pins');
|
||||
if (!Array.isArray(pinned)) {
|
||||
pinned = [];
|
||||
}
|
||||
let changed = false;
|
||||
if (pin) {
|
||||
if (!pinned.includes(seq)) {
|
||||
changed = true;
|
||||
if (pinned.length == _config_js__WEBPACK_IMPORTED_MODULE_3__.MAX_PINNED_COUNT) {
|
||||
pinned.shift();
|
||||
}
|
||||
pinned.push(seq);
|
||||
}
|
||||
} else {
|
||||
if (pinned.includes(seq)) {
|
||||
changed = true;
|
||||
pinned = pinned.filter(id => id != seq);
|
||||
if (pinned.length == 0) {
|
||||
pinned = _config_js__WEBPACK_IMPORTED_MODULE_3__.DEL_CHAR;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
return this.setMeta({
|
||||
aux: {
|
||||
pins: pinned
|
||||
}
|
||||
});
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
delMessages(ranges, hard) {
|
||||
if (!this._attached) {
|
||||
return Promise.reject(new Error("Cannot delete messages in inactive topic"));
|
||||
@@ -3950,6 +3993,9 @@ class Topic {
|
||||
tags() {
|
||||
return this._tags.slice(0);
|
||||
}
|
||||
aux(key) {
|
||||
return this._aux[key];
|
||||
}
|
||||
subscriber(uid) {
|
||||
return this._users[uid];
|
||||
}
|
||||
@@ -4250,6 +4296,9 @@ class Topic {
|
||||
if (meta.cred) {
|
||||
this._processMetaCreds(meta.cred);
|
||||
}
|
||||
if (meta.aux) {
|
||||
this._processMetaAux(meta.aux);
|
||||
}
|
||||
if (this.onMeta) {
|
||||
this.onMeta(meta);
|
||||
}
|
||||
@@ -4277,6 +4326,9 @@ class Topic {
|
||||
this.getMeta(this.startMetaQuery().withLaterOneSub(pres.src).build());
|
||||
}
|
||||
break;
|
||||
case 'aux':
|
||||
this.getMeta(this.startMetaQuery().withAux().build());
|
||||
break;
|
||||
case 'acs':
|
||||
uid = pres.src || this._tinode.getCurrentUserID();
|
||||
user = this._users[uid];
|
||||
@@ -4391,22 +4443,31 @@ 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;
|
||||
this._tinode._db.updTopic(this);
|
||||
if (this.onTagsUpdated) {
|
||||
this.onTagsUpdated(tags);
|
||||
}
|
||||
}
|
||||
_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);
|
||||
this._tinode._db.updTopic(this);
|
||||
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);
|
||||
@@ -4928,7 +4989,7 @@ function normalizeArray(arr) {
|
||||
}
|
||||
}
|
||||
}
|
||||
out.sort().filter(function (item, pos, ary) {
|
||||
out.sort().filter((item, pos, ary) => {
|
||||
return !pos || item != ary[pos - 1];
|
||||
});
|
||||
}
|
||||
@@ -4950,7 +5011,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.3";
|
||||
const PACKAGE_VERSION = "0.23.0-rc1";
|
||||
|
||||
/***/ })
|
||||
|
||||
@@ -5670,6 +5731,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);
|
||||
}
|
||||
@@ -5784,7 +5848,7 @@ class Tinode {
|
||||
const pkt = _classPrivateMethodGet(this, _initPacket, _initPacket2).call(this, 'set', topic);
|
||||
const what = [];
|
||||
if (params) {
|
||||
['desc', 'sub', 'tags', 'cred', 'ephemeral'].forEach(function (key) {
|
||||
['desc', 'sub', 'tags', 'cred', 'aux'].forEach(key => {
|
||||
if (params.hasOwnProperty(key)) {
|
||||
what.push(key);
|
||||
pkt.set[key] = params[key];
|
||||
@@ -6210,7 +6274,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