mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-12-27 02:23:28 +08:00
Fetch messages on demand
This commit is contained in:
parent
07428a1060
commit
0bec5719fd
6 changed files with 18 additions and 47 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -10,8 +10,6 @@
|
|||
|
||||
##### Client Private Plugins (symlinked)
|
||||
**/client-app/src/error-logger-extensions
|
||||
**/client-app/src/nylas-private-*
|
||||
**/internal_packages/nylas-private-*
|
||||
**/internal_packages/activity-list
|
||||
**/internal_packages/composer-mail-merge
|
||||
**/internal_packages/composer-scheduler
|
||||
|
|
|
@ -3,35 +3,35 @@
|
|||
font-family: 'Nylas-Pro';
|
||||
font-style: normal;
|
||||
font-weight: 200;
|
||||
src: url('nylas://custom-fonts/fonts/Nylas-Pro-Thin.otf');
|
||||
src: url('nylas://custom-fonts/fonts/Custom-Thin.otf');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Nylas-Pro';
|
||||
font-style: normal;
|
||||
font-weight: 300;
|
||||
src: url('nylas://custom-fonts/fonts/Nylas-Pro-Blond.otf');
|
||||
src: url('nylas://custom-fonts/fonts/Custom-Blond.otf');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Nylas-Pro';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: url('nylas://custom-fonts/fonts/Nylas-Pro-Normal.otf');
|
||||
src: url('nylas://custom-fonts/fonts/Custom-Normal.otf');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Nylas-Pro';
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
src: url('nylas://custom-fonts/fonts/Nylas-Pro-Medium.otf');
|
||||
src: url('nylas://custom-fonts/fonts/Custom-Medium.otf');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Nylas-Pro';
|
||||
font-style: normal;
|
||||
font-weight: 600;
|
||||
src: url('nylas://custom-fonts/fonts/Nylas-Pro-SemiBold.otf');
|
||||
src: url('nylas://custom-fonts/fonts/Custom-SemiBold.otf');
|
||||
}
|
||||
|
||||
// Pro-SemiBold doesn't render emoji properly. Override the emjoi unicode
|
||||
|
@ -40,6 +40,6 @@
|
|||
font-family: 'Nylas-Pro';
|
||||
font-style: normal;
|
||||
font-weight: 600;
|
||||
src: url('nylas://custom-fonts/fonts/Nylas-Pro-Normal.otf'), Helvetica, sans-serif;
|
||||
src: url('nylas://custom-fonts/fonts/Custom-Normal.otf'), Helvetica, sans-serif;
|
||||
unicode-range: U+1F300-1F5FF, U+1F600-1F64F, U+1F680-1F6FF, U+2600-26FF;
|
||||
}
|
||||
|
|
|
@ -5,8 +5,6 @@ EmailFrame = require('./email-frame').default
|
|||
{
|
||||
DraftHelpers,
|
||||
CanvasUtils,
|
||||
NylasAPI,
|
||||
NylasAPIRequest,
|
||||
MessageUtils,
|
||||
MessageBodyProcessor,
|
||||
QuotedHTMLTransformer,
|
||||
|
|
|
@ -14,24 +14,6 @@ export default class DatabaseChangeRecord {
|
|||
this._objectsString = options.objectsString;
|
||||
this._objects = this._objects || JSON.parse(this._objectsString, Utils.registeredObjectReviver);
|
||||
|
||||
/**
|
||||
* We notify the entire app in ALL windows when anything in the
|
||||
* database changes. This is normally okay except for Messages because
|
||||
* their bodies might contain millions of charcters that will have to
|
||||
* be serialized, sent over IPC, and deserialized in each and every
|
||||
* window! We make an exception for message bodies here to
|
||||
* dramatically reduce the processing overhead of sending object
|
||||
* changes across the deltas.
|
||||
*/
|
||||
if (options.objectClass === "Message") {
|
||||
this._objects = this._objects.map((o) => {
|
||||
if (!o.draft) {
|
||||
o.body = null;
|
||||
}
|
||||
return o;
|
||||
})
|
||||
}
|
||||
|
||||
Object.defineProperty(this, 'type', {
|
||||
get: () => options.type,
|
||||
})
|
||||
|
|
|
@ -141,7 +141,7 @@ class MessageStore extends NylasStore
|
|||
@_fetchFromCache()
|
||||
|
||||
if change.objectClass is Thread.name
|
||||
updatedThread = _.find change.objects, (obj) => obj.id is @_thread.id
|
||||
updatedThread = change.objects.find((t) => t.id is @_thread.id)
|
||||
if updatedThread
|
||||
@_thread = updatedThread
|
||||
@_fetchFromCache()
|
||||
|
@ -251,19 +251,14 @@ class MessageStore extends NylasStore
|
|||
# loading items for. Necessary because this takes a while.
|
||||
return unless loadedThreadId is @_thread?.id
|
||||
|
||||
loaded = true
|
||||
|
||||
@_items = items.filter((m) => !m.isHidden())
|
||||
@_items = @_sortItemsForDisplay(@_items)
|
||||
|
||||
# If no items were returned, attempt to load messages via the API. If items
|
||||
# are returned, this will trigger a refresh here.
|
||||
if @_items.length is 0
|
||||
@_fetchMessages()
|
||||
loaded = false
|
||||
|
||||
@_expandItemsToDefault()
|
||||
|
||||
if @_itemsLoading
|
||||
@_fetchMissingBodies(@_items)
|
||||
|
||||
# Download the attachments on expanded messages.
|
||||
@_fetchExpandedAttachments(@_items)
|
||||
|
||||
|
@ -272,10 +267,14 @@ class MessageStore extends NylasStore
|
|||
# know we're not ready, don't even bother. Trigger once at start
|
||||
# and once when ready. Many third-party stores will observe
|
||||
# MessageStore and they'll be stupid and re-render constantly.
|
||||
if loaded
|
||||
@_itemsLoading = false
|
||||
@_markAsRead()
|
||||
@trigger(@)
|
||||
@_itemsLoading = false
|
||||
@_markAsRead()
|
||||
@trigger(@)
|
||||
|
||||
_fetchMissingBodies: (items) ->
|
||||
missingIds = items.filter((i) -> i.body == null).map((i) -> i.id)
|
||||
if missingIds.length > 0
|
||||
NylasEnv.actionBridgeCpp.onTellClients({type: 'need-bodies', ids: missingIds})
|
||||
|
||||
_fetchExpandedAttachments: (items) ->
|
||||
policy = NylasEnv.config.get('core.attachments.downloadPolicy')
|
||||
|
@ -293,9 +292,6 @@ class MessageStore extends NylasStore
|
|||
if item.unread or item.draft or idx is visibleItems.length - 1
|
||||
@_itemsExpanded[item.id] = "default"
|
||||
|
||||
_fetchMessages: ->
|
||||
NylasAPIHelpers.getCollection(@_thread.accountId, 'messages', {thread_id: @_thread.id})
|
||||
|
||||
_sortItemsForDisplay: (items) ->
|
||||
# Re-sort items in the list so that drafts appear after the message that
|
||||
# they are in reply to, when possible. First, identify all the drafts
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
import Task from './task';
|
||||
import Event from '../models/event';
|
||||
import {APIError} from '../errors';
|
||||
import Utils from '../models/utils';
|
||||
import DatabaseStore from '../stores/database-store';
|
||||
import NylasAPI from '../nylas-api';
|
||||
import NylasAPIRequest from '../nylas-api-request';
|
||||
|
||||
|
||||
export default class EventRSVPTask extends Task {
|
||||
|
|
Loading…
Reference in a new issue