fix: new group topic is immediately unsubscribed
This commit is contained in:
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+4
-2
@@ -22,8 +22,10 @@ export const READ_DELAY = 1000;
|
||||
// The shortest allowed tag length. Matches the value on the server.
|
||||
export const MIN_TAG_LENGTH = 4;
|
||||
|
||||
// Access mode for subscriptions initiated by the current user.
|
||||
export const DEFAULT_ACCESS_MODE = 'JRWPS';
|
||||
// Access mode for P2P subscriptions initiated by the current user.
|
||||
export const DEFAULT_P2P_ACCESS_MODE = 'JRWPS';
|
||||
// Access mode for new group topics created by the current user.
|
||||
export const NEW_GRP_ACCESS_MODE = 'JRWPSAO';
|
||||
|
||||
// Access mode for no access.
|
||||
export const NO_ACCESS_MODE = 'N';
|
||||
|
||||
@@ -14,7 +14,7 @@ import LoadSpinner from '../widgets/load-spinner.jsx';
|
||||
import LogoView from './logo-view.jsx';
|
||||
import SendMessage from '../widgets/send-message.jsx';
|
||||
|
||||
import { DEFAULT_ACCESS_MODE, KEYPRESS_DELAY, MESSAGES_PAGE } from '../config.js';
|
||||
import { DEFAULT_P2P_ACCESS_MODE, KEYPRESS_DELAY, MESSAGES_PAGE } from '../config.js';
|
||||
import { makeImageUrl } from '../lib/blob-helpers.js';
|
||||
import { shortDateFormat } from '../lib/strformat.js';
|
||||
|
||||
@@ -85,7 +85,6 @@ class MessagesView extends React.Component {
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.leave(this.state.topic);
|
||||
if (this.messagesScroller) {
|
||||
this.messagesScroller.removeEventListener('scroll', this.handleScrollEvent);
|
||||
}
|
||||
@@ -104,7 +103,7 @@ class MessagesView extends React.Component {
|
||||
|
||||
const topic = this.props.tinode.getTopic(this.state.topic);
|
||||
if (this.state.topic != prevState.topic) {
|
||||
if (prevState.topic) {
|
||||
if (prevState.topic && !Tinode.isNewGroupTopicName(prevState.topic)) {
|
||||
this.leave(prevState.topic);
|
||||
this.props.readTimerHandler(null);
|
||||
}
|
||||
@@ -490,7 +489,7 @@ class MessagesView extends React.Component {
|
||||
|
||||
handleEnablePeer(e) {
|
||||
e.preventDefault();
|
||||
this.props.onChangePermissions(this.state.topic, DEFAULT_ACCESS_MODE, this.state.topic);
|
||||
this.props.onChangePermissions(this.state.topic, DEFAULT_P2P_ACCESS_MODE, this.state.topic);
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@@ -15,7 +15,7 @@ import InfoView from './info-view.jsx';
|
||||
import MessagesView from './messages-view.jsx';
|
||||
import SidepanelView from './sidepanel-view.jsx';
|
||||
|
||||
import { API_KEY, APP_NAME, DEFAULT_ACCESS_MODE, MEDIA_BREAKPOINT, READ_DELAY, RECEIVED_DELAY } from '../config.js';
|
||||
import { API_KEY, APP_NAME, DEFAULT_P2P_ACCESS_MODE, MEDIA_BREAKPOINT, READ_DELAY, RECEIVED_DELAY } from '../config.js';
|
||||
import { base64ReEncode, makeImageUrl } from '../lib/blob-helpers.js';
|
||||
import { detectServerAddress, isLocalHost, isSecureConnection } from '../lib/host-name.js';
|
||||
import LocalStorageUtil from '../lib/local-storage.js';
|
||||
@@ -990,15 +990,16 @@ class TinodeWeb extends React.Component {
|
||||
|
||||
// Request to start a new topic. New P2P topic requires peer's name.
|
||||
handleNewTopicRequest(peerName, pub, priv, tags) {
|
||||
|
||||
const topicName = peerName || this.tinode.newGroupTopicName();
|
||||
const params = {
|
||||
_topicName: topicName,
|
||||
};
|
||||
if (peerName) {
|
||||
// Because we are initialing the subscription, set 'want' to all permissions.
|
||||
params.sub = {mode: DEFAULT_ACCESS_MODE};
|
||||
params.sub = {mode: DEFAULT_P2P_ACCESS_MODE};
|
||||
// Give the other user all permissions too.
|
||||
params.desc = {defacs: {auth: DEFAULT_ACCESS_MODE}};
|
||||
params.desc = {defacs: {auth: DEFAULT_P2P_ACCESS_MODE}};
|
||||
} else {
|
||||
params.desc = {public: pub, private: {comment: priv}};
|
||||
params.tags = tags;
|
||||
|
||||
+18
-11
@@ -841,7 +841,7 @@
|
||||
function n(e, t) {
|
||||
return "0".repeat((t = t || 2) - ("" + e).length) + e;
|
||||
}
|
||||
}(t);else if (null == t || !1 === t || Array.isArray(t) && 0 == t.length || "object" == s(t) && 0 == Object.keys(t).length) return;
|
||||
}(t);else if (t instanceof D) t = t.jsonHelper();else if (null == t || !1 === t || Array.isArray(t) && 0 == t.length || "object" == s(t) && 0 == Object.keys(t).length) return;
|
||||
return t;
|
||||
}(0, t);
|
||||
}
|
||||
@@ -1609,7 +1609,14 @@
|
||||
return e;
|
||||
}, D.prototype = {
|
||||
toString: function () {
|
||||
return '{mode: "' + D.encode(this.mode) + '", given: "' + D.encode(this.given) + '", want: "' + D.encode(this.want) + '"}';
|
||||
return '{"mode": "' + D.encode(this.mode) + '", "given": "' + D.encode(this.given) + '", "want": "' + D.encode(this.want) + '"}';
|
||||
},
|
||||
jsonHelper: function () {
|
||||
return {
|
||||
mode: D.encode(this.mode),
|
||||
given: D.encode(this.given),
|
||||
want: D.encode(this.want)
|
||||
};
|
||||
},
|
||||
setMode: function (e) {
|
||||
return this.mode = D.decode(e), this;
|
||||
@@ -2610,7 +2617,7 @@ module.exports = g;
|
||||
/*!***********************!*\
|
||||
!*** ./src/config.js ***!
|
||||
\***********************/
|
||||
/*! exports provided: APP_NAME, API_KEY, KNOWN_HOSTS, DEFAULT_HOST, KEYPRESS_DELAY, RECEIVED_DELAY, READ_DELAY, MIN_TAG_LENGTH, DEFAULT_ACCESS_MODE, NO_ACCESS_MODE, MEDIA_BREAKPOINT, REM_SIZE, AVATAR_SIZE, BROKEN_IMAGE_SIZE, MESSAGES_PAGE, MAX_INBAND_ATTACHMENT_SIZE, MAX_EXTERN_ATTACHMENT_SIZE, MAX_IMAGE_DIM, MAX_ONLINE_IN_TOPIC, LINK_CONTACT_US, LINK_PRIVACY_POLICY, LINK_TERMS_OF_SERVICE */
|
||||
/*! exports provided: APP_NAME, API_KEY, KNOWN_HOSTS, DEFAULT_HOST, KEYPRESS_DELAY, RECEIVED_DELAY, READ_DELAY, MIN_TAG_LENGTH, DEFAULT_P2P_ACCESS_MODE, NEW_GRP_ACCESS_MODE, NO_ACCESS_MODE, MEDIA_BREAKPOINT, REM_SIZE, AVATAR_SIZE, BROKEN_IMAGE_SIZE, MESSAGES_PAGE, MAX_INBAND_ATTACHMENT_SIZE, MAX_EXTERN_ATTACHMENT_SIZE, MAX_IMAGE_DIM, MAX_ONLINE_IN_TOPIC, LINK_CONTACT_US, LINK_PRIVACY_POLICY, LINK_TERMS_OF_SERVICE */
|
||||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
@@ -2623,7 +2630,8 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RECEIVED_DELAY", function() { return RECEIVED_DELAY; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "READ_DELAY", function() { return READ_DELAY; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MIN_TAG_LENGTH", function() { return MIN_TAG_LENGTH; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_ACCESS_MODE", function() { return DEFAULT_ACCESS_MODE; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_P2P_ACCESS_MODE", function() { return DEFAULT_P2P_ACCESS_MODE; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NEW_GRP_ACCESS_MODE", function() { return NEW_GRP_ACCESS_MODE; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NO_ACCESS_MODE", function() { return NO_ACCESS_MODE; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MEDIA_BREAKPOINT", function() { return MEDIA_BREAKPOINT; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "REM_SIZE", function() { return REM_SIZE; });
|
||||
@@ -2650,7 +2658,8 @@ var KEYPRESS_DELAY = 3 * 1000;
|
||||
var RECEIVED_DELAY = 500;
|
||||
var READ_DELAY = 1000;
|
||||
var MIN_TAG_LENGTH = 4;
|
||||
var DEFAULT_ACCESS_MODE = 'JRWPS';
|
||||
var DEFAULT_P2P_ACCESS_MODE = 'JRWPS';
|
||||
var NEW_GRP_ACCESS_MODE = 'JRWPSAO';
|
||||
var NO_ACCESS_MODE = 'N';
|
||||
var MEDIA_BREAKPOINT = 640;
|
||||
var REM_SIZE = 13;
|
||||
@@ -5459,8 +5468,6 @@ var MessagesView = function (_React$Component) {
|
||||
}, {
|
||||
key: "componentWillUnmount",
|
||||
value: function componentWillUnmount() {
|
||||
this.leave(this.state.topic);
|
||||
|
||||
if (this.messagesScroller) {
|
||||
this.messagesScroller.removeEventListener('scroll', this.handleScrollEvent);
|
||||
}
|
||||
@@ -5481,7 +5488,7 @@ var MessagesView = function (_React$Component) {
|
||||
var topic = this.props.tinode.getTopic(this.state.topic);
|
||||
|
||||
if (this.state.topic != prevState.topic) {
|
||||
if (prevState.topic) {
|
||||
if (prevState.topic && !tinode_sdk__WEBPACK_IMPORTED_MODULE_2___default.a.isNewGroupTopicName(prevState.topic)) {
|
||||
this.leave(prevState.topic);
|
||||
this.props.readTimerHandler(null);
|
||||
}
|
||||
@@ -5808,7 +5815,7 @@ var MessagesView = function (_React$Component) {
|
||||
key: "handleEnablePeer",
|
||||
value: function handleEnablePeer(e) {
|
||||
e.preventDefault();
|
||||
this.props.onChangePermissions(this.state.topic, _config_js__WEBPACK_IMPORTED_MODULE_12__["DEFAULT_ACCESS_MODE"], this.state.topic);
|
||||
this.props.onChangePermissions(this.state.topic, _config_js__WEBPACK_IMPORTED_MODULE_12__["DEFAULT_P2P_ACCESS_MODE"], this.state.topic);
|
||||
}
|
||||
}, {
|
||||
key: "render",
|
||||
@@ -7954,11 +7961,11 @@ var TinodeWeb = function (_React$Component) {
|
||||
|
||||
if (peerName) {
|
||||
params.sub = {
|
||||
mode: _config_js__WEBPACK_IMPORTED_MODULE_11__["DEFAULT_ACCESS_MODE"]
|
||||
mode: _config_js__WEBPACK_IMPORTED_MODULE_11__["DEFAULT_P2P_ACCESS_MODE"]
|
||||
};
|
||||
params.desc = {
|
||||
defacs: {
|
||||
auth: _config_js__WEBPACK_IMPORTED_MODULE_11__["DEFAULT_ACCESS_MODE"]
|
||||
auth: _config_js__WEBPACK_IMPORTED_MODULE_11__["DEFAULT_P2P_ACCESS_MODE"]
|
||||
}
|
||||
};
|
||||
} else {
|
||||
|
||||
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