Fix loading issues

This commit is contained in:
yflory 2025-03-28 17:40:34 +01:00
parent 4b1597a65b
commit dc41e9c1a8
6 changed files with 52 additions and 23 deletions

8
package-lock.json generated
View File

@ -18,7 +18,7 @@
"chainpad": "^5.2.6",
"chainpad-crypto": "^0.2.5",
"chainpad-listmap": "^1.1.1",
"chainpad-netflux": "^1.2.2",
"chainpad-netflux": "^1.2.3",
"chainpad-server": "^5.2.4",
"ckeditor": "npm:ckeditor4@~4.22.1",
"codemirror": "^5.19.0",
@ -1927,9 +1927,9 @@
}
},
"node_modules/chainpad-netflux": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/chainpad-netflux/-/chainpad-netflux-1.2.2.tgz",
"integrity": "sha512-fcKugW29BE4wo4l3WYLc56yeFznu15bGi6tU3uPtsLGSExXGqNwS+3kmpzI0AFAsuoI0OKPeT4uLX4YzKT/D+A==",
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/chainpad-netflux/-/chainpad-netflux-1.2.3.tgz",
"integrity": "sha512-bXLUSxAsCu4kRnGorW+7fVofiCWSNGRkB+uFJ4kUV/zDJ3RJYU4J3+DZsL4rCTkLkAjgKt+YQCoYciCKLlTwqg==",
"license": "LGPL-2.1",
"dependencies": {
"netflux-websocket": "^1.2.0"

View File

@ -21,7 +21,7 @@
"chainpad": "^5.2.6",
"chainpad-crypto": "^0.2.5",
"chainpad-listmap": "^1.1.1",
"chainpad-netflux": "^1.2.2",
"chainpad-netflux": "^1.2.3",
"chainpad-server": "^5.2.4",
"ckeditor": "npm:ckeditor4@~4.22.1",
"codemirror": "^5.19.0",

View File

@ -2866,8 +2866,11 @@ const factory = (ApiConfig = {}, Sortify, UserObject, ProxyManager,
loadSyncModules(waitFor);
loadUniversal(Profile, 'profile', waitFor);
loadUniversal(Calendar, 'calendar', waitFor);
if (store.modules['team']) { store.modules['team'].onReady(waitFor); }
loadUniversal(Support, 'support', waitFor);
nThen(waitFor => {
// Make teams non-blocking
if (store.modules['team']) { store.modules['team'].onReady(waitFor); }
});
}).nThen(function () {
var requestLogin = function () {
broadcast([], "REQUEST_LOGIN");
@ -3280,22 +3283,36 @@ const factory = (ApiConfig = {}, Sortify, UserObject, ProxyManager,
}
if (requires === 'team') {
const initTeams = Util.once(ret => {
// On cache ready (if cache enabled)
// or on ready (if cache disabled)
nThen(w => {
loadUniversal(Team, 'team', w, clientId);
}).nThen(() => {
cb(ret);
loadDrive(clientId, data, ret => {
startCacheModules(clientId, ret, onInit);
}, ret => {
startModules(clientId, ret, onInit);
let called = false;
const initTeams = cache => {
return ret => {
if (called) { return; }
called = true;
// On cache ready (if cache enabled)
// or on ready (if cache disabled)
nThen(w => {
if (cache) { return; }
initAnonRpc(null, null, w());
}).nThen(w => {
loadUniversal(Team, 'team', w, clientId);
}).nThen(w => {
// Sync teams before other modules
// when cache is empty
if (!cache && store.modules['team']) {
store.modules['team'].onReady(w);
}
}).nThen(() => {
cb(ret);
loadDrive(clientId, data, ret => {
startCacheModules(clientId, ret, onInit);
}, ret => {
startModules(clientId, ret, onInit);
});
});
});
});
};
};
return void loadAccount(clientId, data,
initTeams, initTeams);
initTeams(true), initTeams(false));
}
if (requires === 'drive') {

View File

@ -641,11 +641,17 @@ var factory = function (Util, Hash, CPNetflux, Sortify, nThen, Crypto, Feedback)
return Boolean(ready && me);
};
var lastHash;
var onMessage = function (msg, user, vKey, isCp , hash, author) {
// count messages received since the last checkpoint
// even if they fail to parse
ref.internal.sinceLastCheckpoint++;
if (lastHash !== hash) {
// Don't count duplicate lkh message on reconnect
ref.internal.sinceLastCheckpoint++;
}
lastHash = hash;
var parsed = Util.tryParse(msg);
if (!parsed) { return void console.error("could not parse"); }

View File

@ -641,11 +641,17 @@ var factory = function (Util, Hash, CPNetflux, Sortify, nThen, Crypto, Feedback)
return Boolean(ready && me);
};
var lastHash;
var onMessage = function (msg, user, vKey, isCp , hash, author) {
// count messages received since the last checkpoint
// even if they fail to parse
ref.internal.sinceLastCheckpoint++;
if (lastHash !== hash) {
// Don't count duplicate lkh message on reconnect
ref.internal.sinceLastCheckpoint++;
}
lastHash = hash;
var parsed = Util.tryParse(msg);
if (!parsed) { return void console.error("could not parse"); }

File diff suppressed because one or more lines are too long