mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-27 15:04:31 +08:00
Fix QuerySubscription: null
is a valid query result, should be emitted
This commit is contained in:
parent
e4a2568829
commit
7171513053
2 changed files with 4 additions and 4 deletions
|
@ -10,7 +10,7 @@ export default class QuerySubscription {
|
|||
|
||||
this._set = null;
|
||||
this._callbacks = [];
|
||||
this._lastResult = null;
|
||||
this._lastResult = undefined; // null is a valid result!
|
||||
this._updateInFlight = false;
|
||||
this._queuedChangeRecords = [];
|
||||
this._queryVersion = 1;
|
||||
|
@ -44,8 +44,7 @@ export default class QuerySubscription {
|
|||
throw new Error(`QuerySubscription:addCallback - expects a function, received ${callback}`);
|
||||
}
|
||||
this._callbacks.push(callback);
|
||||
|
||||
if (this._lastResult) {
|
||||
if (this._lastResult !== undefined) {
|
||||
callback(this._lastResult);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -320,7 +320,8 @@ export default class ModelQuery {
|
|||
|
||||
formatResult(inflated) {
|
||||
if (this._returnOne) {
|
||||
return inflated[0];
|
||||
// be careful not to return "undefined" if no items returned
|
||||
return inflated.length > 0 ? inflated[0] : null;
|
||||
}
|
||||
if (this._count) {
|
||||
return inflated;
|
||||
|
|
Loading…
Add table
Reference in a new issue