|
本帖最后由 Qter 于 2020-9-27 17:38 编辑
在没有任何账号的情况 下会查询下面加红的表
app\src\browser\application.ts
this.windowManager = new WindowManager({
app\src\browser\window-manager.ts
this.windowLauncher = new WindowLauncher({
app\src\browser\window-launcher.ts
this.hotWindow = new MailspringWindow(this._hotWindowOpts());
app\src\browser\mailspring-window.ts
this.browserWindow = new BrowserWindow(browserWindowOptions);
this.browserWindow.loadURL(this.getURL(loadSettings)); ---/static/index.html
/static/index.html
<script src="index.js"></script>
app\static\index.js
function setupWindow(loadSettings) {
require(loadSettings.bootstrapScript);
}
loadSettings {"bootstrapScript":"\app\\src\\secondary-window-bootstrap.ts"}
app\src\secondary-window-bootstrap.ts
window.AppEnv = new AppEnvClass();
AppEnv.startSecondaryWindow();
app\src\app-env.ts
constructor() {
require('mailspring-observables');
require('mailspring-exports');
this.actionBridge = new ActionBridge(ipcRenderer);
this.mailsyncBridge = new MailsyncBridge();
}
app/src/flux/mailsync-bridge.ts
import TaskQueue from './stores/task-queue';
app\src\flux\stores\category-store.ts
constructor() {
Categories.forAllAccounts() ---程序启动默认查询Label Folder表
.sort()
.subscribe(this._onCategoriesChanged);
forAllAccounts() {
const folders = Rx.Observable.fromQuery<Folder[]>(DatabaseStore.findAll<Folder>(Folder));
const labels = Rx.Observable.fromQuery(DatabaseStore.findAll<Label>(Label));
const joined = Rx.Observable.combineLatest<Category[], Category[], Category[]>(
folders,
labels,
(f, l) => [].concat(f, l)
);
======================
app\src\flux\stores\task-queue.ts
constructor() {
super();
Rx.Observable.fromQuery(DatabaseStore.findAll<Task>(Task)).subscribe( ---程序启动默认查询Task表
this._onQueueChangedDebounced
);
}
app\src\global\mailspring-observables.ts
Rx.Observable.fromQuery = <T>(query: ModelQuery<T>) => {
return Rx.Observable.create(observer => {
const unsubscribe = QuerySubscriptionPool.add(query, result => observer.onNext(result));
return Rx.Disposable.create(unsubscribe);
});
};
app\src\flux\models\query-subscription-pool.ts
add(query: ModelQuery<any>, callback) {
subscription = new QuerySubscription(query);
app\src\flux\models\query-subscription.ts
QuerySubscription 构造函数
this.update();
update({ mustRefetchEntireRange }: { mustRefetchEntireRange?: boolean } = {}) {
this._fetchRange(desiredRange, {
version: this._queryVersion,
fetchEntireModels: haveNoModels,
});
_fetchRange(range, { version, fetchEntireModels }) {
DatabaseStore.run
app\src\flux\stores\database-store.ts
_query(query: SQLString, values: SQLValue[] = [], background: boolean = false) {
|
|