
@@ -3772,7 +3790,7 @@
}
},
handleHashRoute: function(e) {
- console.log("hashchange", location.hash);
+ console.log("hashchange", parseUrlHash(window.location.hash));
},
handleOnline: function(online) {
var newState = {liveConnection: online};
@@ -3846,6 +3864,7 @@
},
handleCredentialsRequest: function(params) {
+ window.location.hash = "validation/" + this.state.topicSelected + "/" + params.cred;
this.setState({
sidePanelSelected: 'validation',
validation: params.cred
@@ -3861,6 +3880,7 @@
// Logged in fine, subscribe to 'me' attaching callbacks from the contacts view.
var me = Tinode.getMeTopic();
me.onMetaDesc = instance.tnMeMetaDesc;
+ window.location.hash = "";
instance.setState({
connected: true,
sidePanelSelected: "contacts",
@@ -3954,7 +3974,9 @@
handleTopicSelected: function(topicName, unused_index, online, acs) {
if (topicName) {
// Contact selected
- location.hash = topicName;
+ if (this.state.topicSelected != topicName) {
+ window.location.hash = this.state.sidePanelSelected + "/" + topicName;
+ }
this.setState({
topicSelected: topicName,
mobilePanel: 'topic-view',
@@ -3965,7 +3987,10 @@
infoPanelShowMembers: Tinode.getTopicType(topicName) === "grp"
});
} else {
- location.hash = null;
+ if (this.state.topicSelected) {
+ console.log("topic deleted");
+ window.history.replaceState({}, "", this.state.sidePanelSelected);
+ }
// Currently selected contact deleted
this.setState({
topicSelected: null,
@@ -4014,6 +4039,7 @@
},
// User chose a Sign Up menu item.
handleNewAccount: function() {
+ window.location.hash = "register";
this.setState({sidePanelSelected: 'register'});
},
// Actual registration of a new account.
@@ -4057,6 +4083,7 @@
// User chose Settings menu item.
handleSettings: function() {
+ window.location.hash = this.state.myUserId ? 'edit' : 'settings';
this.setState({sidePanelSelected: this.state.myUserId ? 'edit-account' : 'settings'});
},
// User updated connection parameters - transport and server address
@@ -4069,13 +4096,16 @@
// User clicked Cancel button in Setting or Sign Up panel.
handleSidepanelCancel: function() {
if (this.state.myUserId) {
+ window.location.hash = "/" + this.state.topicSelected;
this.setState({sidePanelSelected: 'contacts', errorText: '', errorLevel: null});
} else {
+ window.location.hash = '';
this.setState({sidePanelSelected: 'login', errorText: '', errorLevel: null});
}
},
// User clicked a (+) menu item.
handleNewTopic: function() {
+ window.location.hash = 'new';
this.setState({sidePanelSelected: 'new-topic'});
},
// Create of a new topic. New P2P topic requires peer's name.
@@ -4214,9 +4244,11 @@
},
handleShowInfoView: function() {
+ window.location.hash = addParamToHash(window.location.hash, 'info', true);
this.setState({showInfoPanel: true, infoPanelShowMembers: false});
},
handleHideInfoView: function() {
+ window.location.hash = removeParamFromHash(window.location.hash, 'info');
this.setState({showInfoPanel: false, infoPanelShowMembers: false});
},
handleMemberUpdateRequest: function(topicName, added, removed) {