Skip to content

Commit

Permalink
Improved editing.
Browse files Browse the repository at this point in the history
  • Loading branch information
petersirka committed Aug 20, 2024
1 parent 8bdcc9d commit 957198b
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,29 @@ exports.init = function(url) {
client.options.reconnect = 10000;
client.options.reconnectserver = true;

var initilaized = false;

client.on('message', function(msg) {

if (msg.TYPE === 'redirect') {
if (msg.url) {
client.close(3001);
exports.init(msg.url);
}
return;
}

if (msg.TYPE === 'init') {
console.log(DIVIDER);
console.log(HEADER + ': Welcome to "' + msg.name + ' (' + msg.version + ')"');
console.log('> Project: "' + msg.project + '"');
console.log(DIVIDER);
initilaized = true;
return;
}

if (msg.TYPE === 'redirect') {
if (msg.url) {
client.close(3001);
exports.init(msg.url);
}
if (!initilaized)
return;
}

F.action('editor', msg).callback(function(err, response) {

Expand All @@ -53,6 +59,8 @@ exports.init = function(url) {

client.on('close', function(e) {

initilaized = false;

if (e === 4004) {
console.log(HEADER + ': 404 project not found');
// Tries again in 10 second interval
Expand Down

0 comments on commit 957198b

Please sign in to comment.