Offer platform-specific updates at startup and foreground return
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import 'dart:js_interop';
|
||||
|
||||
@JS('fetch')
|
||||
external JSPromise<_ReleaseResponse> _fetch(JSString input, _FetchOptions init);
|
||||
@JS('location.reload')
|
||||
external void _reload();
|
||||
|
||||
extension type _FetchOptions._(JSObject _) implements JSObject {
|
||||
external factory _FetchOptions({JSString credentials, JSString cache});
|
||||
}
|
||||
|
||||
extension type _ReleaseResponse._(JSObject _) implements JSObject {
|
||||
external int get status;
|
||||
external JSPromise<JSString> text();
|
||||
}
|
||||
|
||||
Future<String?> fetchLatestWebBuild(Uri uri) async {
|
||||
final response = await _fetch(
|
||||
uri.toString().toJS,
|
||||
_FetchOptions(credentials: 'same-origin'.toJS, cache: 'no-store'.toJS),
|
||||
).toDart;
|
||||
if (response.status != 200) return null;
|
||||
return (await response.text().toDart).toDart;
|
||||
}
|
||||
|
||||
Future<void> refreshWebPage() async => _reload();
|
||||
Reference in New Issue
Block a user