|
app\src\flux\mailsync-bridge.ts
_onIncomingMessages = msgs => {
for (const msg of msgs) {
json = JSON.parse(msg);
const { type, modelJSONs, modelClass } = json; ---modelClass: Folder Message Thread
const models = modelJSONs.map(Utils.convertToModel);
this._onIncomingChangeRecord(
new DatabaseChangeRecord({
type, // TODO BG move to "model" naming style, finding all uses might be tricky
objectClass: modelClass,
objects: models,
objectsRawJSON: modelJSONs,
})
);
}
_onIncomingChangeRecord{
// Allow observers of the database to handle this change
DatabaseStore.trigger(record); //查找对应的监听事件DatabaseStore.listen
}
app\src\flux\stores\database-store.ts
class DatabaseStore extends MailspringStore {
}
监听事件DatabaseStore.listen
app\internal_packages\thread-sharing\lib\main.tsx //分享
this._unlisten = DatabaseStore.listen(_onDatabaseChange);
ipcRenderer.on('openThreadFromWeb', _onOpenThreadFromWeb);
const _onDatabaseChange = change => {
change.objects.forEach(async thread => {
if (isShared(thread)) { //这里是分享的逻辑,不再跟了
syncThreadToWebSoon(thread); //会上传送到官方
}
app\internal_packages\unread-notifications\lib\main.ts //新邮件通知逻辑处理
app\src\components\list-selection.ts //列表选中部分的处理
跟踪不到,直接找下左侧的邮件账号树控件,看数据从哪里加载
app\internal_packages\account-sidebar\lib\components\account-sidebar.tsx
app\internal_packages\account-sidebar\lib\sidebar-store.ts
this.listenTo(AccountStore, this._onAccountsChanged);
this.listenTo(CategoryStore, this._updateSections);
_updateSections = () => {
this._sections[Sections.Standard] = SidebarSection.standardSectionForAccounts(accounts);
}
app\internal_packages\account-sidebar\lib\sidebar-section.ts
if (CategoryStore.categories().length === 0) {
return this.empty(localized('All Accounts'));
}
app\src\flux\stores\category-store.ts //数据来源
_categoryCache = {};
Categories.forAllAccounts() //从数据库查询
.sort()
.subscribe(this._onCategoriesChanged);
_onCategoriesChanged = categories => {
this._categoryResult = categories;
this._categoryCache = {};
for (const cat of categories) {
this._categoryCache[cat.accountId] = this._categoryCache[cat.accountId] || {};
this._categoryCache[cat.accountId][cat.id] = cat;
}
app\src\global\mailspring-observables.ts
const CategoryObservables = {
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)
);
Object.assign(joined, CategoryOperators);
return joined as Observable<Category[]> & ICategoryOperators;
},
app\internal_packages\category-picker\spec\category-picker-spec.jsx
app\spec\mailbox-perspective-spec.ts
app\spec\tasks\task-factory-spec.ts
生成邮件夹的测试用例 造数据
|
|