Only allow using history in writable mode

Otherwise stuff can be reverted, and the write ID can be taken from
padData change events.
pull/54/merge
Candid Dauth 2016-11-01 19:59:55 +03:00
rodzic 88483d142e
commit be37c6b6e1
1 zmienionych plików z 8 dodań i 2 usunięć

Wyświetl plik

@ -429,8 +429,8 @@ utils.extend(SocketConnection.prototype, {
listenToHistory: function() {
return Promise.resolve().then(() => {
if(this.padId == null)
throw "No pad ID set.";
if(!this.writable)
throw "In read-only mode.";
if(this.historyListener)
throw "Already listening to history.";
@ -450,6 +450,9 @@ utils.extend(SocketConnection.prototype, {
if(!this.historyListener)
throw "Not listening to history.";
if(!this.writable)
throw "In read-only mode.";
this.historyListener(); // Unregister db listener
this.historyListener = null;
},
@ -461,6 +464,9 @@ utils.extend(SocketConnection.prototype, {
if(!utils.stripObject(data, { id: "number" }))
throw "Invalid parameters.";
if(!this.writable)
throw "In read-only mode.";
if(listening)
this.socketHandlers.stopListeningToHistory.call(this);