fix leaving a conversation
This commit is contained in:
+22
-20
@@ -313,7 +313,7 @@ class TinodeWeb extends React.Component {
|
|||||||
initFCMessaging() {
|
initFCMessaging() {
|
||||||
const {formatMessage, locale} = this.props.intl;
|
const {formatMessage, locale} = this.props.intl;
|
||||||
const onError = (msg, err) => {
|
const onError = (msg, err) => {
|
||||||
console.log(msg, err);
|
console.error(msg, err);
|
||||||
this.handleError(formatMessage(messages.push_init_failed), 'err');
|
this.handleError(formatMessage(messages.push_init_failed), 'err');
|
||||||
this.setState({desktopAlertsEnabled: false});
|
this.setState({desktopAlertsEnabled: false});
|
||||||
}
|
}
|
||||||
@@ -389,24 +389,28 @@ class TinodeWeb extends React.Component {
|
|||||||
'cred','reset','newtpk','archive','blocked','contacts',''].includes(hash.path[0])) {
|
'cred','reset','newtpk','archive','blocked','contacts',''].includes(hash.path[0])) {
|
||||||
this.setState({sidePanelSelected: hash.path[0]});
|
this.setState({sidePanelSelected: hash.path[0]});
|
||||||
} else {
|
} else {
|
||||||
console.log("Unknown sidepanel view", hash.path[0]);
|
console.warn("Unknown sidepanel view", hash.path[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Topic for MessagesView selector.
|
// Topic for MessagesView selector.
|
||||||
const topicName = hash.path[1];
|
let topicName = hash.path[1] || null;
|
||||||
if (Tinode.topicType(topicName) && topicName != this.state.topicSelected) {
|
if (topicName != this.state.topicSelected) {
|
||||||
const newState = {
|
if (!Tinode.topicType(topicName)) {
|
||||||
topicSelected: topicName
|
// Clear invalid topic name.
|
||||||
};
|
topicName = null;
|
||||||
const acs = this.tinode.getTopicAccessMode(topicName);
|
}
|
||||||
if (acs) {
|
const newState = {
|
||||||
newState.topicSelectedAcs = acs;
|
topicSelected: topicName
|
||||||
}
|
};
|
||||||
this.setState(newState);
|
const acs = this.tinode.getTopicAccessMode(topicName);
|
||||||
|
if (acs) {
|
||||||
|
newState.topicSelectedAcs = acs;
|
||||||
|
}
|
||||||
|
this.setState(newState);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Empty hashpath
|
// Empty hashpath
|
||||||
this.setState({sidePanelSelected: ''});
|
this.setState({sidePanelSelected: '', topicSelected: null});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save validation credentials, if available.
|
// Save validation credentials, if available.
|
||||||
@@ -469,13 +473,11 @@ class TinodeWeb extends React.Component {
|
|||||||
handlePersistenceChange(persist) {
|
handlePersistenceChange(persist) {
|
||||||
if (persist) {
|
if (persist) {
|
||||||
this.tinode.initStorage().then(() => {
|
this.tinode.initStorage().then(() => {
|
||||||
console.log("storage initialized");
|
|
||||||
LocalStorageUtil.setObject('keep-logged-in', true);
|
LocalStorageUtil.setObject('keep-logged-in', true);
|
||||||
this.setState({persist: true});
|
this.setState({persist: true});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.tinode.clearStorage().then(() => {
|
this.tinode.clearStorage().then(() => {
|
||||||
console.log("storage cleared");
|
|
||||||
LocalStorageUtil.setObject('keep-logged-in', false);
|
LocalStorageUtil.setObject('keep-logged-in', false);
|
||||||
this.setState({persist: false});
|
this.setState({persist: false});
|
||||||
});
|
});
|
||||||
@@ -715,7 +717,7 @@ class TinodeWeb extends React.Component {
|
|||||||
} else {
|
} else {
|
||||||
// TODO(gene): handle other types of notifications:
|
// TODO(gene): handle other types of notifications:
|
||||||
// * ua -- user agent changes (maybe display a pictogram for mobile/desktop).
|
// * ua -- user agent changes (maybe display a pictogram for mobile/desktop).
|
||||||
console.log("Unsupported (yet) presence update:" + what + " in: " + cont.topic);
|
console.info("Unsupported (yet) presence update:" + what + " in: " + cont.topic);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -938,7 +940,7 @@ class TinodeWeb extends React.Component {
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log("Unknown invitation action", '"' + action + '""');
|
console.warn("Unknown invitation action", '"' + action + '""');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
@@ -1070,7 +1072,7 @@ class TinodeWeb extends React.Component {
|
|||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.requestPushToken();
|
this.requestPushToken();
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.log("Failed to get notification permission.", err);
|
console.warn("Failed to get notification permission.", err);
|
||||||
this.handleError(err.message, 'err');
|
this.handleError(err.message, 'err');
|
||||||
this.setState({desktopAlerts: false, firebaseToken: null});
|
this.setState({desktopAlerts: false, firebaseToken: null});
|
||||||
LocalStorageUtil.updateObject('settings', {desktopAlerts: false});
|
LocalStorageUtil.updateObject('settings', {desktopAlerts: false});
|
||||||
@@ -1083,7 +1085,7 @@ class TinodeWeb extends React.Component {
|
|||||||
}
|
}
|
||||||
} else if (this.state.firebaseToken && this.fbPush) {
|
} else if (this.state.firebaseToken && this.fbPush) {
|
||||||
this.fbPush.deleteToken(this.state.firebaseToken).catch((err) => {
|
this.fbPush.deleteToken(this.state.firebaseToken).catch((err) => {
|
||||||
console.log("Unable to delete token.", err);
|
console.warn("Unable to delete token.", err);
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
LocalStorageUtil.updateObject('settings', {desktopAlerts: false});
|
LocalStorageUtil.updateObject('settings', {desktopAlerts: false});
|
||||||
localStorage.removeItem('firebase-token');
|
localStorage.removeItem('firebase-token');
|
||||||
@@ -1112,7 +1114,7 @@ class TinodeWeb extends React.Component {
|
|||||||
}
|
}
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
this.handleError(err.message, 'err');
|
this.handleError(err.message, 'err');
|
||||||
console.log("Failed to retrieve firebase token", err);
|
console.warn("Failed to retrieve firebase token", err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user