IMAP Folder speedup tuning
This commit is contained in:
@@ -17,7 +17,7 @@ function deferred() {
|
||||
function harness({ platform = 'android', cached, sync }) {
|
||||
const messages = [];
|
||||
const state = { messages, activeMessage: null, activeFolder: 'Inbox', selectedIds: new Set(), query: '' };
|
||||
const feature = { connectedAccount: { id: 'account' }, pageOffset: 0, syncPromise: null, syncQueued: false };
|
||||
const feature = { connectedAccount: { id: 'account' }, pageOffset: 0, syncPromise: null, syncQueued: false, displayedMailboxKey: JSON.stringify(['account', 'Inbox']) };
|
||||
const elements = new Map();
|
||||
const opened = [];
|
||||
const renders = [];
|
||||
@@ -130,6 +130,76 @@ test('a sync result for a previous folder does not replace the current mailbox',
|
||||
assert.deepEqual(ui.opened, []);
|
||||
});
|
||||
|
||||
test('switching folders shows that folder’s cached messages before the network response', async () => {
|
||||
const network = deferred();
|
||||
const ui = harness({
|
||||
cached: async folder => folder === 'Sent' ? result([42]) : null,
|
||||
sync: () => network.promise
|
||||
});
|
||||
ui.state.messages.push({ id: 1, uid: 1, tags: [] });
|
||||
ui.state.activeFolder = 'Sent';
|
||||
const pending = ui.context.syncMailbox(false, { offset: 0 });
|
||||
await new Promise(resolve => setImmediate(resolve));
|
||||
assert.deepEqual(ui.state.messages.map(message => message.id), [42]);
|
||||
assert.deepEqual(ui.renders.at(-1), [42]);
|
||||
network.resolve(result([43]));
|
||||
await pending;
|
||||
});
|
||||
|
||||
test('a different folder can load from cache while the previous folder is still syncing', async () => {
|
||||
const inbox = deferred();
|
||||
const sent = deferred();
|
||||
const ui = harness({
|
||||
cached: async folder => folder === 'Sent' ? result([42]) : null,
|
||||
sync: folder => folder === 'Inbox' ? inbox.promise : sent.promise
|
||||
});
|
||||
const first = ui.context.syncMailbox(false);
|
||||
await new Promise(resolve => setImmediate(resolve));
|
||||
ui.state.activeFolder = 'Sent';
|
||||
const second = ui.context.syncMailbox(false, { offset: 0 });
|
||||
await new Promise(resolve => setImmediate(resolve));
|
||||
assert.deepEqual(ui.state.messages.map(message => message.id), [42]);
|
||||
sent.resolve(result([43]));
|
||||
await second;
|
||||
inbox.resolve(result([1]));
|
||||
await first;
|
||||
assert.deepEqual(ui.state.messages.map(message => message.id), [43]);
|
||||
});
|
||||
|
||||
test('returning to a folder ignores an older request for the same folder', async () => {
|
||||
const firstInbox = deferred();
|
||||
const sent = deferred();
|
||||
const secondInbox = deferred();
|
||||
let calls = 0;
|
||||
const ui = harness({
|
||||
sync: () => [firstInbox, sent, secondInbox][calls++].promise
|
||||
});
|
||||
const first = ui.context.syncMailbox(false);
|
||||
ui.state.activeFolder = 'Sent';
|
||||
const middle = ui.context.syncMailbox(false);
|
||||
ui.state.activeFolder = 'Inbox';
|
||||
const last = ui.context.syncMailbox(false);
|
||||
secondInbox.resolve(result([3]));
|
||||
await last;
|
||||
firstInbox.resolve(result([1]));
|
||||
sent.resolve(result([2]));
|
||||
await Promise.all([first, middle]);
|
||||
assert.deepEqual(ui.state.messages.map(message => message.id), [3]);
|
||||
assert.equal(ui.elements.get('#refresh').disabled, false);
|
||||
});
|
||||
|
||||
test('switching accounts never displays the previous account’s messages', async () => {
|
||||
const network = deferred();
|
||||
const ui = harness({ cached: async () => null, sync: () => network.promise });
|
||||
ui.state.messages.push({ id: 1, uid: 1, tags: [] });
|
||||
ui.feature.connectedAccount = { id: 'other' };
|
||||
const pending = ui.context.syncMailbox(false);
|
||||
assert.equal(ui.state.messages.length, 0);
|
||||
network.resolve(result([2]));
|
||||
await pending;
|
||||
assert.deepEqual(ui.state.messages.map(message => message.id), [2]);
|
||||
});
|
||||
|
||||
test('Android startup theme uses the EP vector on supported splash screens', () => {
|
||||
const styles = fs.readFileSync(path.join(root, 'android', 'app', 'src', 'main', 'res', 'values', 'styles.xml'), 'utf8');
|
||||
const icon = fs.readFileSync(path.join(root, 'android', 'app', 'src', 'main', 'res', 'drawable', 'ep_splash_icon.xml'), 'utf8');
|
||||
@@ -137,3 +207,15 @@ test('Android startup theme uses the EP vector on supported splash screens', ()
|
||||
assert.match(styles, /name="postSplashScreenTheme">@style\/AppTheme.NoActionBar/);
|
||||
assert.match(icon, /android:strokeColor="#eee9de"/);
|
||||
});
|
||||
|
||||
test('Android launcher icons use the EP logo on adaptive and legacy launchers', () => {
|
||||
const res = path.join(root, 'android', 'app', 'src', 'main', 'res');
|
||||
const read = (...parts) => fs.readFileSync(path.join(res, ...parts), 'utf8');
|
||||
for (const name of ['ic_launcher.xml', 'ic_launcher_round.xml']) {
|
||||
assert.match(read('mipmap-anydpi-v26', name), /@drawable\/ep_launcher_foreground/);
|
||||
assert.match(read('mipmap-anydpi', name), /@drawable\/ep_splash_icon/);
|
||||
}
|
||||
assert.match(read('drawable', 'ep_launcher_foreground.xml'), /@drawable\/ep_splash_icon/);
|
||||
assert.match(read('drawable', 'ep_launcher_foreground.xml'), /android:inset="22dp"/);
|
||||
assert.match(read('values', 'ic_launcher_background.xml'), /#0a0c0b/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user