Don't disable map if disconnected and not in pad

pull/54/merge
Candid Dauth 2016-10-19 16:00:21 +03:00
rodzic bad767a955
commit f91b23a39e
3 zmienionych plików z 38 dodań i 26 usunięć

Wyświetl plik

@ -4,7 +4,7 @@
<img src="spinner.gif" alt="Loading…">
</div>
</div>
<div class="fm-map-disabled-cover" ng-show="disconnected || serverError"></div>
<div class="fm-map-disabled-cover" ng-show="padId && (disconnected || serverError)"></div>
<div class="fm-map-loading" ng-hide="loaded || serverError">
Loading...
</div>

Wyświetl plik

@ -40,21 +40,8 @@
return socket.emit.apply(socket, arguments);
};
scope.on("serverError", function(data) {
scope.serverError = data;
});
scope.on("padData", function(data) {
scope.padData = data;
if(data.writable != null)
scope.readonly = !data.writable;
var id = scope.readonly ? data.id : data.writeId;
if(id != null)
scope.padId = id;
scope.disconnected = false;
setPadData(data);
});
scope.on("marker", function(data) {
@ -133,7 +120,7 @@
scope.on("reconnect", function() {
if(scope.padId)
scope.emit("setPadId", scope.padId);
setPadId(scope.padId);
else
scope.disconnected = false; // Otherwise it gets set when padData arrives
@ -141,14 +128,38 @@
scope.emit("updateBbox", scope.bbox);
});
function setPadData(data) {
scope.padData = data;
if(data.writable != null)
scope.readonly = !data.writable;
var id = scope.readonly ? data.id : data.writeId;
if(id != null)
scope.padId = id;
}
scope.setPadId = function(padId) {
if(scope.padId != null)
return;
scope.padId = padId;
scope.emit("setPadId", padId);
setPadId(padId);
};
function setPadId(padId) {
scope.padId = padId;
scope.emit("setPadId", padId, function(err, padData) {
if(err) {
scope.serverError = err;
socket.disconnect();
return;
}
setPadData(padData);
scope.disconnected = false;
});
}
scope.updateBbox = function(bbox) {
scope.emit("updateBbox", bbox);

Wyświetl plik

@ -59,16 +59,18 @@ var serverP = Promise.denodeify(server.listen.bind(server))(config.port, config.
},
setPadId : function(padId) {
if(typeof padId != "string" || socket.padId != null)
return;
return Promise.resolve().then(function() {
if(typeof padId != "string")
throw "Invalid pad id";
if(socket.padId != null)
throw "Pad id already set";
socket.padId = true;
socket.padId = true;
database.getPadData(padId).then(function(data) {
return database.getPadData(padId);
}).then(function(data) {
_setPadId(socket, data);
}, function(err) {
socket.emit("serverError", err);
socket.disconnect();
return data;
});
},
@ -344,7 +346,6 @@ function _setPadId(socket, data) {
socket.writable = data.writable;
listeners.addPadListener(socket);
socket.emit("padData", data);
_sendStreamData(socket, "view", database.getViews(socket.padId));
_sendStreamData(socket, "type", database.getTypes(socket.padId));
_sendStreamData(socket, "line", database.getPadLines(socket.padId));