handle 'DISCONNECTED' error to avoid a password prompt or a cached file

This commit is contained in:
ansuz 2020-11-06 19:51:56 +05:30
parent 077b3fe635
commit 6c134a678b

View file

@ -408,6 +408,8 @@ define([
// `isNewChannel` doesn't work for files (not a channel)
// `getFileSize` is not adapted to channels because of metadata
Cryptpad.getFileSize(currentPad.href, password, w(function (e, size) {
console.error('GET_FILE_SIZE', e, size);
if (e === 'DISCONNECTED') { return void todo(); } // XXX handle disconnected case
if (size !== 0) { return void todo(); }
// Wrong password or deleted file?
askPassword(true, passwordCfg);
@ -416,6 +418,9 @@ define([
}
// Not a file, so we can use `isNewChannel`
Cryptpad.isNewChannel(currentPad.href, password, w(function(e, isNew) {
console.error('IS_NEW_CHANNEL', e, isNew);
if (e === 'DISCONNECTED') { return void todo(); } // XXX if offline just proceed to use the cache?
if (isNew && expire && expire < (+new Date())) {
sframeChan.event("EV_EXPIRED_ERROR");
waitFor.abort();