mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 19:16:08 +00:00
feat(native): the app needs TREK 5.1.3 on the server and checks a remembered one once after the update
The fixes that keep the app's sign-in in the app live in the server's UI, so an updated app on a 5.1.2 server still ended in the browser. The server now reports nativeApi 2 and the app refuses anything below it, naming 5.1.3. A server the app remembers from before is not loaded unchecked: the first launch after the update shows the address screen filled in with it, says why and checks it right away. A server that is new enough loads again with its session; an older one gets the update hint.
This commit is contained in:
@@ -43,10 +43,12 @@ const FEATURES_PATH = '/api/health/features';
|
||||
|
||||
/**
|
||||
* The oldest server API this app can work with (`nativeApi` in the features
|
||||
* response). A server from before the field existed answers without it and is
|
||||
* accepted while the minimum is 1.
|
||||
* response). 2 is TREK 5.1.3, the first server whose sign-in from the app does
|
||||
* not end in the browser. A server without the field is older still. Raising it
|
||||
* goes with SERVER_CHECK in TrekServerStore (iOS and Android), so a server the
|
||||
* app remembers from before is checked against the new minimum once.
|
||||
*/
|
||||
const MIN_NATIVE_API = 1;
|
||||
export const MIN_NATIVE_API = 2;
|
||||
|
||||
function normalize(raw: string): string | null {
|
||||
let parsed: URL;
|
||||
@@ -80,7 +82,7 @@ function judge(response: ProbeResponse): ProbeResult {
|
||||
if (response.status !== 200 || !isRecord(response.data)) return { ok: false, reason: 'notTrek' };
|
||||
if (response.data.nativeApp === true) {
|
||||
const api = response.data.nativeApi;
|
||||
if (typeof api === 'number' && api < MIN_NATIVE_API) return { ok: false, reason: 'tooOld' };
|
||||
if (typeof api !== 'number' || api < MIN_NATIVE_API) return { ok: false, reason: 'tooOld' };
|
||||
// Follow a redirect (http to https, a canonical host) so the app loads the
|
||||
// address the server actually answers on.
|
||||
const base = response.url.endsWith(FEATURES_PATH) ? response.url.slice(0, -FEATURES_PATH.length) : null;
|
||||
|
||||
Reference in New Issue
Block a user