mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-22 00:06:06 +08:00
🎨
This commit is contained in:
parent
e1f1b22ee2
commit
7c99e9c55f
|
@ -50,7 +50,7 @@ class IMAPBox {
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._conn.createConnectionPromise((resolve, reject) => {
|
return this._conn._createConnectionPromise((resolve, reject) => {
|
||||||
const f = this._conn._imap.fetch(range, options);
|
const f = this._conn._imap.fetch(range, options);
|
||||||
f.on('message', (imapMessage) => {
|
f.on('message', (imapMessage) => {
|
||||||
const parts = {};
|
const parts = {};
|
||||||
|
@ -110,7 +110,7 @@ class IMAPBox {
|
||||||
if (!options) {
|
if (!options) {
|
||||||
throw new Error("IMAPConnection.fetchStream requires an options object.")
|
throw new Error("IMAPConnection.fetchStream requires an options object.")
|
||||||
}
|
}
|
||||||
return this._conn.createConnectionPromise((resolve, reject) => {
|
return this._conn._createConnectionPromise((resolve, reject) => {
|
||||||
const f = this._conn._imap.fetch(uid, options);
|
const f = this._conn._imap.fetch(uid, options);
|
||||||
f.on('message', (imapMessage) => {
|
f.on('message', (imapMessage) => {
|
||||||
imapMessage.on('body', (stream) => {
|
imapMessage.on('body', (stream) => {
|
||||||
|
@ -129,7 +129,7 @@ class IMAPBox {
|
||||||
* message in the range
|
* message in the range
|
||||||
*/
|
*/
|
||||||
fetchUIDAttributes(range, fetchOptions = {}) {
|
fetchUIDAttributes(range, fetchOptions = {}) {
|
||||||
return this._conn.createConnectionPromise((resolve, reject) => {
|
return this._conn._createConnectionPromise((resolve, reject) => {
|
||||||
const attributesByUID = {};
|
const attributesByUID = {};
|
||||||
const f = this._conn._imap.fetch(range, fetchOptions);
|
const f = this._conn._imap.fetch(range, fetchOptions);
|
||||||
f.on('message', (msg) => {
|
f.on('message', (msg) => {
|
||||||
|
@ -147,7 +147,7 @@ class IMAPBox {
|
||||||
throw new IMAPConnectionNotReadyError(`IMAPBox::addFlags`)
|
throw new IMAPConnectionNotReadyError(`IMAPBox::addFlags`)
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._conn.createConnectionPromise((resolve, reject) => {
|
return this._conn._createConnectionPromise((resolve, reject) => {
|
||||||
return this._conn._imap.addFlagsAsync(range, flags)
|
return this._conn._imap.addFlagsAsync(range, flags)
|
||||||
.then((...args) => resolve(...args))
|
.then((...args) => resolve(...args))
|
||||||
.catch((...args) => reject(...args))
|
.catch((...args) => reject(...args))
|
||||||
|
@ -158,7 +158,7 @@ class IMAPBox {
|
||||||
if (!this._conn._imap) {
|
if (!this._conn._imap) {
|
||||||
throw new IMAPConnectionNotReadyError(`IMAPBox::delFlags`)
|
throw new IMAPConnectionNotReadyError(`IMAPBox::delFlags`)
|
||||||
}
|
}
|
||||||
return this._conn.createConnectionPromise((resolve, reject) => {
|
return this._conn._createConnectionPromise((resolve, reject) => {
|
||||||
return this._conn._imap.delFlagsAsync(range, flags)
|
return this._conn._imap.delFlagsAsync(range, flags)
|
||||||
.then((...args) => resolve(...args))
|
.then((...args) => resolve(...args))
|
||||||
.catch((...args) => reject(...args))
|
.catch((...args) => reject(...args))
|
||||||
|
@ -169,7 +169,7 @@ class IMAPBox {
|
||||||
if (!this._conn._imap) {
|
if (!this._conn._imap) {
|
||||||
throw new IMAPConnectionNotReadyError(`IMAPBox::moveFromBox`)
|
throw new IMAPConnectionNotReadyError(`IMAPBox::moveFromBox`)
|
||||||
}
|
}
|
||||||
return this._conn.createConnectionPromise((resolve, reject) => {
|
return this._conn._createConnectionPromise((resolve, reject) => {
|
||||||
return this._conn._imap.moveAsync(range, folderName)
|
return this._conn._imap.moveAsync(range, folderName)
|
||||||
.then((...args) => resolve(...args))
|
.then((...args) => resolve(...args))
|
||||||
.catch((...args) => reject(...args))
|
.catch((...args) => reject(...args))
|
||||||
|
@ -180,7 +180,7 @@ class IMAPBox {
|
||||||
if (!this._conn._imap) {
|
if (!this._conn._imap) {
|
||||||
throw new IMAPConnectionNotReadyError(`IMAPBox::moveFromBox`)
|
throw new IMAPConnectionNotReadyError(`IMAPBox::moveFromBox`)
|
||||||
}
|
}
|
||||||
return this._conn.createConnectionPromise((resolve, reject) => {
|
return this._conn._createConnectionPromise((resolve, reject) => {
|
||||||
return this._conn._imap.setLabelsAsync(range, labels)
|
return this._conn._imap.setLabelsAsync(range, labels)
|
||||||
.then((...args) => resolve(...args))
|
.then((...args) => resolve(...args))
|
||||||
.catch((...args) => reject(...args))
|
.catch((...args) => reject(...args))
|
||||||
|
@ -191,7 +191,7 @@ class IMAPBox {
|
||||||
if (!this._conn._imap) {
|
if (!this._conn._imap) {
|
||||||
throw new IMAPConnectionNotReadyError(`IMAPBox::moveFromBox`)
|
throw new IMAPConnectionNotReadyError(`IMAPBox::moveFromBox`)
|
||||||
}
|
}
|
||||||
return this._conn.createConnectionPromise((resolve, reject) => {
|
return this._conn._createConnectionPromise((resolve, reject) => {
|
||||||
return this._conn._imap.delLabelsAsync(range, labels)
|
return this._conn._imap.delLabelsAsync(range, labels)
|
||||||
.then((...args) => resolve(...args))
|
.then((...args) => resolve(...args))
|
||||||
.catch((...args) => reject(...args))
|
.catch((...args) => reject(...args))
|
||||||
|
@ -202,7 +202,7 @@ class IMAPBox {
|
||||||
if (!this._conn._imap) {
|
if (!this._conn._imap) {
|
||||||
throw new IMAPConnectionNotReadyError(`IMAPBox::append`)
|
throw new IMAPConnectionNotReadyError(`IMAPBox::append`)
|
||||||
}
|
}
|
||||||
return this._conn.createConnectionPromise((resolve, reject) => {
|
return this._conn._createConnectionPromise((resolve, reject) => {
|
||||||
return this._conn._imap.appendAsync(rawMime, options)
|
return this._conn._imap.appendAsync(rawMime, options)
|
||||||
.then((...args) => resolve(...args))
|
.then((...args) => resolve(...args))
|
||||||
.catch((...args) => reject(...args))
|
.catch((...args) => reject(...args))
|
||||||
|
@ -213,7 +213,7 @@ class IMAPBox {
|
||||||
if (!this._conn._imap) {
|
if (!this._conn._imap) {
|
||||||
throw new IMAPConnectionNotReadyError(`IMAPBox::search`)
|
throw new IMAPConnectionNotReadyError(`IMAPBox::search`)
|
||||||
}
|
}
|
||||||
return this._conn.createConnectionPromise((resolve, reject) => {
|
return this._conn._createConnectionPromise((resolve, reject) => {
|
||||||
return this._conn._imap.searchAsync(criteria)
|
return this._conn._imap.searchAsync(criteria)
|
||||||
.then((...args) => resolve(...args))
|
.then((...args) => resolve(...args))
|
||||||
.catch((...args) => reject(...args))
|
.catch((...args) => reject(...args))
|
||||||
|
@ -224,7 +224,7 @@ class IMAPBox {
|
||||||
if (!this._conn._imap) {
|
if (!this._conn._imap) {
|
||||||
throw new IMAPConnectionNotReadyError(`IMAPBox::closeBox`)
|
throw new IMAPConnectionNotReadyError(`IMAPBox::closeBox`)
|
||||||
}
|
}
|
||||||
return this._conn.createConnectionPromise((resolve, reject) => {
|
return this._conn._createConnectionPromise((resolve, reject) => {
|
||||||
return this._conn._imap.closeBoxAsync(expunge)
|
return this._conn._imap.closeBoxAsync(expunge)
|
||||||
.then((...args) => resolve(...args))
|
.then((...args) => resolve(...args))
|
||||||
.catch((...args) => reject(...args))
|
.catch((...args) => reject(...args))
|
||||||
|
|
|
@ -203,7 +203,7 @@ class IMAPConnection extends EventEmitter {
|
||||||
return Promise.resolve(new IMAPBox(this, this._imap._box));
|
return Promise.resolve(new IMAPBox(this, this._imap._box));
|
||||||
}
|
}
|
||||||
this._isOpeningBox = true
|
this._isOpeningBox = true
|
||||||
return this.createConnectionPromise((resolve, reject) => {
|
return this._createConnectionPromise((resolve, reject) => {
|
||||||
return this._imap.openBoxAsync(folderName, readOnly)
|
return this._imap.openBoxAsync(folderName, readOnly)
|
||||||
.then((box) => {
|
.then((box) => {
|
||||||
this._isOpeningBox = false
|
this._isOpeningBox = false
|
||||||
|
@ -222,7 +222,7 @@ class IMAPConnection extends EventEmitter {
|
||||||
// get the latest stats from the box (e.g. latest uidnext, etc)
|
// get the latest stats from the box (e.g. latest uidnext, etc)
|
||||||
return this.openBox(folderName, {refetchBoxInfo: true})
|
return this.openBox(folderName, {refetchBoxInfo: true})
|
||||||
}
|
}
|
||||||
return this.createConnectionPromise((resolve, reject) => {
|
return this._createConnectionPromise((resolve, reject) => {
|
||||||
return this._imap.statusAsync(folderName)
|
return this._imap.statusAsync(folderName)
|
||||||
.then((...args) => resolve(...args))
|
.then((...args) => resolve(...args))
|
||||||
.catch((...args) => reject(...args))
|
.catch((...args) => reject(...args))
|
||||||
|
@ -233,7 +233,7 @@ class IMAPConnection extends EventEmitter {
|
||||||
if (!this._imap) {
|
if (!this._imap) {
|
||||||
throw new IMAPConnectionNotReadyError(`IMAPConnection::getBoxes`)
|
throw new IMAPConnectionNotReadyError(`IMAPConnection::getBoxes`)
|
||||||
}
|
}
|
||||||
return this.createConnectionPromise((resolve, reject) => {
|
return this._createConnectionPromise((resolve, reject) => {
|
||||||
return this._imap.getBoxesAsync()
|
return this._imap.getBoxesAsync()
|
||||||
.then((...args) => resolve(...args))
|
.then((...args) => resolve(...args))
|
||||||
.catch((...args) => reject(...args))
|
.catch((...args) => reject(...args))
|
||||||
|
@ -244,7 +244,7 @@ class IMAPConnection extends EventEmitter {
|
||||||
if (!this._imap) {
|
if (!this._imap) {
|
||||||
throw new IMAPConnectionNotReadyError(`IMAPConnection::addBox`)
|
throw new IMAPConnectionNotReadyError(`IMAPConnection::addBox`)
|
||||||
}
|
}
|
||||||
return this.createConnectionPromise((resolve, reject) => {
|
return this._createConnectionPromise((resolve, reject) => {
|
||||||
return this._imap.addBoxAsync(folderName)
|
return this._imap.addBoxAsync(folderName)
|
||||||
.then((...args) => resolve(...args))
|
.then((...args) => resolve(...args))
|
||||||
.catch((...args) => reject(...args))
|
.catch((...args) => reject(...args))
|
||||||
|
@ -255,7 +255,7 @@ class IMAPConnection extends EventEmitter {
|
||||||
if (!this._imap) {
|
if (!this._imap) {
|
||||||
throw new IMAPConnectionNotReadyError(`IMAPConnection::renameBox`)
|
throw new IMAPConnectionNotReadyError(`IMAPConnection::renameBox`)
|
||||||
}
|
}
|
||||||
return this.createConnectionPromise((resolve, reject) => {
|
return this._createConnectionPromise((resolve, reject) => {
|
||||||
return this._imap.renameBoxAsync(oldFolderName, newFolderName)
|
return this._imap.renameBoxAsync(oldFolderName, newFolderName)
|
||||||
.then((...args) => resolve(...args))
|
.then((...args) => resolve(...args))
|
||||||
.catch((...args) => reject(...args))
|
.catch((...args) => reject(...args))
|
||||||
|
@ -266,7 +266,7 @@ class IMAPConnection extends EventEmitter {
|
||||||
if (!this._imap) {
|
if (!this._imap) {
|
||||||
throw new IMAPConnectionNotReadyError(`IMAPConnection::delBox`)
|
throw new IMAPConnectionNotReadyError(`IMAPConnection::delBox`)
|
||||||
}
|
}
|
||||||
return this.createConnectionPromise((resolve, reject) => {
|
return this._createConnectionPromise((resolve, reject) => {
|
||||||
return this._imap.delBoxAsync(folderName)
|
return this._imap.delBoxAsync(folderName)
|
||||||
.then((...args) => resolve(...args))
|
.then((...args) => resolve(...args))
|
||||||
.catch((...args) => reject(...args))
|
.catch((...args) => reject(...args))
|
||||||
|
@ -284,7 +284,7 @@ class IMAPConnection extends EventEmitter {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this._queue.push({operation, resolve, reject});
|
this._queue.push({operation, resolve, reject});
|
||||||
if (this._imap.state === 'authenticated' && !this._currentOperation) {
|
if (this._imap.state === 'authenticated' && !this._currentOperation) {
|
||||||
this.processNextOperation();
|
this._processNextOperation();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -296,9 +296,9 @@ class IMAPConnection extends EventEmitter {
|
||||||
fetch / action forever after emitting an `end` event, or doesn't actually
|
fetch / action forever after emitting an `end` event, or doesn't actually
|
||||||
timeout the socket.
|
timeout the socket.
|
||||||
*/
|
*/
|
||||||
createConnectionPromise(callback) {
|
_createConnectionPromise(callback) {
|
||||||
if (!this._imap) {
|
if (!this._imap) {
|
||||||
throw new IMAPConnectionNotReadyError(`IMAPConnection::createConnectionPromise`)
|
throw new IMAPConnectionNotReadyError(`IMAPConnection::_createConnectionPromise`)
|
||||||
}
|
}
|
||||||
|
|
||||||
let onEnded = null;
|
let onEnded = null;
|
||||||
|
@ -336,7 +336,7 @@ class IMAPConnection extends EventEmitter {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
processNextOperation() {
|
_processNextOperation() {
|
||||||
if (this._currentOperation) {
|
if (this._currentOperation) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -359,7 +359,7 @@ class IMAPConnection extends EventEmitter {
|
||||||
// operation_description: operation.description(),
|
// operation_description: operation.description(),
|
||||||
// }, `Finished sync operation`)
|
// }, `Finished sync operation`)
|
||||||
resolve(maybeResult);
|
resolve(maybeResult);
|
||||||
this.processNextOperation();
|
this._processNextOperation();
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
this._currentOperation = null;
|
this._currentOperation = null;
|
||||||
|
|
Loading…
Reference in a new issue