FIX feature to scroll down in imap folder to load more mails
This commit is contained in:
@@ -31,6 +31,8 @@ On Android, previously cached folder messages appear while the mailbox refreshes
|
||||
|
||||
In connected IMAP folders, scrolling to the end of the message list loads the next page automatically. The **Load more** button remains available as a manual fallback.
|
||||
|
||||
After upgrading from an older Android build, close and reopen ep-mail once if it still shows the previous interface. This lets the updated offline app shell take control without clearing account data.
|
||||
|
||||
## Run on Windows or Linux
|
||||
|
||||
Install Python 3, open a terminal in this folder, and run:
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "ep-mail",
|
||||
"version": "0.5.17",
|
||||
"version": "0.5.18",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "ep-mail",
|
||||
"version": "0.5.17",
|
||||
"version": "0.5.18",
|
||||
"dependencies": {
|
||||
"@capacitor/android": "^8.5.2",
|
||||
"@capacitor/core": "^8.5.2",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ep-mail",
|
||||
"version": "0.5.17",
|
||||
"version": "0.5.18",
|
||||
"private": true,
|
||||
"description": "Eternity Project mail client",
|
||||
"homepage": "https://git.eternityproject.fi/thuttu/ep-mail-client",
|
||||
|
||||
+25
-2
@@ -1,5 +1,28 @@
|
||||
const CACHE='ep-mail-v19';
|
||||
const CACHE='ep-mail-v20';
|
||||
const FILES=['./','./index.html','./styles.css','./branding.css','./renderer-state.js','./mail-content-security.js','./renderer-mail-api.js','./app.js','./platform-bridge-loader.js','./platform-bridge.js','./mail-ui.js','./productivity.js','./snooze-ui.js','./account-ui.js','./dav-ui.js','./shortcuts.js','./attachments.js','./pgp-ui.js','./pgp-mail-ui.js','./manifest.webmanifest','./icon.svg','./logo-ep-daylight.svg','./logo-ep-wasteland.svg'];
|
||||
self.addEventListener('install',event=>event.waitUntil(caches.open(CACHE).then(cache=>cache.addAll(FILES)).then(()=>self.skipWaiting())));
|
||||
self.addEventListener('activate',event=>event.waitUntil(caches.keys().then(keys=>Promise.all(keys.filter(k=>k!==CACHE).map(k=>caches.delete(k)))).then(()=>self.clients.claim())));
|
||||
self.addEventListener('fetch',event=>{if(event.request.method!=='GET')return;event.respondWith(caches.match(event.request).then(cached=>cached||fetch(event.request).then(response=>{if(new URL(event.request.url).origin===location.origin){const copy=response.clone();caches.open(CACHE).then(cache=>cache.put(event.request,copy))}return response}).catch(()=>caches.match('./index.html'))))});
|
||||
self.addEventListener('fetch', event => {
|
||||
const request = event.request;
|
||||
if (request.method !== 'GET' || new URL(request.url).origin !== location.origin) return;
|
||||
event.respondWith((async () => {
|
||||
let response;
|
||||
try {
|
||||
response = await fetch(request, { cache: 'no-cache' });
|
||||
} catch (error) {
|
||||
const cached = await caches.match(request) ||
|
||||
(request.mode === 'navigate' ? await caches.match('./index.html') : null);
|
||||
if (cached) return cached;
|
||||
throw error;
|
||||
}
|
||||
if (response.ok) {
|
||||
try {
|
||||
const cache = await caches.open(CACHE);
|
||||
await cache.put(request, response.clone());
|
||||
} catch (error) {
|
||||
console.error('Could not update offline app cache:', error);
|
||||
}
|
||||
}
|
||||
return response;
|
||||
})());
|
||||
});
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const vm = require('node:vm');
|
||||
|
||||
const source = fs.readFileSync(path.join(__dirname, '..', 'service-worker.js'), 'utf8');
|
||||
|
||||
function harness({ network, cached }) {
|
||||
const handlers = {};
|
||||
const writes = [];
|
||||
const context = {
|
||||
URL,
|
||||
location: { origin: 'https://localhost' },
|
||||
self: { addEventListener: (type, handler) => { handlers[type] = handler; } },
|
||||
caches: {
|
||||
match: async request => cached.get(typeof request === 'string' ? request : request.url),
|
||||
open: async () => ({ put: async (request, response) => writes.push([request.url, response]) })
|
||||
},
|
||||
fetch: network
|
||||
};
|
||||
vm.runInNewContext(source, context);
|
||||
return {
|
||||
writes,
|
||||
async request(request) {
|
||||
let response;
|
||||
const pending = [];
|
||||
handlers.fetch({
|
||||
request,
|
||||
respondWith(value) { response = value; },
|
||||
waitUntil(value) { pending.push(value); }
|
||||
});
|
||||
if (!response) return { intercepted: false };
|
||||
const result = await response;
|
||||
await Promise.all(pending);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
test('new Android app assets replace old cached scripts', async () => {
|
||||
const request = { method: 'GET', url: 'https://localhost/mail-ui.js', mode: 'same-origin' };
|
||||
const fresh = { ok: true, clone() { return this; } };
|
||||
const old = { old: true };
|
||||
const ui = harness({ network: async () => fresh, cached: new Map([[request.url, old]]) });
|
||||
assert.equal(await ui.request(request), fresh);
|
||||
assert.deepEqual(ui.writes, [[request.url, fresh]]);
|
||||
assert.notEqual(source.match(/const CACHE\s*=\s*['"]([^'"]+)/)[1], 'ep-mail-v19');
|
||||
});
|
||||
|
||||
test('offline requests use cached assets and missing assets fail explicitly', async () => {
|
||||
const request = { method: 'GET', url: 'https://localhost/mail-ui.js', mode: 'same-origin' };
|
||||
const old = { old: true };
|
||||
const offline = async () => { throw new Error('offline'); };
|
||||
const ui = harness({ network: offline, cached: new Map([[request.url, old]]) });
|
||||
assert.equal(await ui.request(request), old);
|
||||
const missing = harness({ network: offline, cached: new Map() });
|
||||
await assert.rejects(missing.request(request), /offline/);
|
||||
});
|
||||
|
||||
test('network failures for navigation use the cached app shell', async () => {
|
||||
const request = { method: 'GET', url: 'https://localhost/', mode: 'navigate' };
|
||||
const shell = { shell: true };
|
||||
const ui = harness({
|
||||
network: async () => { throw new Error('offline'); },
|
||||
cached: new Map([['./index.html', shell]])
|
||||
});
|
||||
assert.equal(await ui.request(request), shell);
|
||||
});
|
||||
|
||||
test('HTTP error responses are not stored or replaced with cached content', async () => {
|
||||
const request = { method: 'GET', url: 'https://localhost/mail-ui.js', mode: 'same-origin' };
|
||||
const failed = { ok: false, status: 404 };
|
||||
const ui = harness({ network: async () => failed, cached: new Map([[request.url, { old: true }]]) });
|
||||
assert.equal(await ui.request(request), failed);
|
||||
assert.deepEqual(ui.writes, []);
|
||||
});
|
||||
|
||||
test('cross-origin and non-GET requests are not intercepted', async () => {
|
||||
const ui = harness({ network: async () => { throw new Error('unexpected fetch'); }, cached: new Map() });
|
||||
assert.deepEqual(await ui.request({ method: 'GET', url: 'https://other.example/image.png' }), { intercepted: false });
|
||||
assert.deepEqual(await ui.request({ method: 'POST', url: 'https://localhost/mail-ui.js' }), { intercepted: false });
|
||||
});
|
||||
+25
-2
@@ -1,5 +1,28 @@
|
||||
const CACHE='ep-mail-v19';
|
||||
const CACHE='ep-mail-v20';
|
||||
const FILES=['./','./index.html','./styles.css','./branding.css','./renderer-state.js','./mail-content-security.js','./renderer-mail-api.js','./app.js','./platform-bridge-loader.js','./platform-bridge.js','./mail-ui.js','./productivity.js','./snooze-ui.js','./account-ui.js','./dav-ui.js','./shortcuts.js','./attachments.js','./pgp-ui.js','./pgp-mail-ui.js','./manifest.webmanifest','./icon.svg','./logo-ep-daylight.svg','./logo-ep-wasteland.svg'];
|
||||
self.addEventListener('install',event=>event.waitUntil(caches.open(CACHE).then(cache=>cache.addAll(FILES)).then(()=>self.skipWaiting())));
|
||||
self.addEventListener('activate',event=>event.waitUntil(caches.keys().then(keys=>Promise.all(keys.filter(k=>k!==CACHE).map(k=>caches.delete(k)))).then(()=>self.clients.claim())));
|
||||
self.addEventListener('fetch',event=>{if(event.request.method!=='GET')return;event.respondWith(caches.match(event.request).then(cached=>cached||fetch(event.request).then(response=>{if(new URL(event.request.url).origin===location.origin){const copy=response.clone();caches.open(CACHE).then(cache=>cache.put(event.request,copy))}return response}).catch(()=>caches.match('./index.html'))))});
|
||||
self.addEventListener('fetch', event => {
|
||||
const request = event.request;
|
||||
if (request.method !== 'GET' || new URL(request.url).origin !== location.origin) return;
|
||||
event.respondWith((async () => {
|
||||
let response;
|
||||
try {
|
||||
response = await fetch(request, { cache: 'no-cache' });
|
||||
} catch (error) {
|
||||
const cached = await caches.match(request) ||
|
||||
(request.mode === 'navigate' ? await caches.match('./index.html') : null);
|
||||
if (cached) return cached;
|
||||
throw error;
|
||||
}
|
||||
if (response.ok) {
|
||||
try {
|
||||
const cache = await caches.open(CACHE);
|
||||
await cache.put(request, response.clone());
|
||||
} catch (error) {
|
||||
console.error('Could not update offline app cache:', error);
|
||||
}
|
||||
}
|
||||
return response;
|
||||
})());
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user