mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
Fix setTimeout
This commit is contained in:
@@ -4,6 +4,13 @@ Venera JavaScript Library
|
|||||||
This library provides a set of APIs for interacting with the Venera app.
|
This library provides a set of APIs for interacting with the Venera app.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
function setTimeout(callback, delay) {
|
||||||
|
sendMessage({
|
||||||
|
method: 'delay',
|
||||||
|
time: delay,
|
||||||
|
}).then(callback);
|
||||||
|
}
|
||||||
|
|
||||||
/// encode, decode, hash, decrypt
|
/// encode, decode, hash, decrypt
|
||||||
let Convert = {
|
let Convert = {
|
||||||
/**
|
/**
|
||||||
|
@@ -172,6 +172,12 @@ class JsEngine with _JSEngineApi {
|
|||||||
{
|
{
|
||||||
return ComicSource.find(message["key"])!.isLogged;
|
return ComicSource.find(message["key"])!.isLogged;
|
||||||
}
|
}
|
||||||
|
// temporary solution for [setTimeout] function
|
||||||
|
// TODO: implement [setTimeout] in quickjs project
|
||||||
|
case "delay":
|
||||||
|
{
|
||||||
|
return Future.delayed(Duration(milliseconds: message["time"]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@@ -8,6 +8,7 @@ import 'package:venera/foundation/comic_source/comic_source.dart';
|
|||||||
import 'package:venera/foundation/log.dart';
|
import 'package:venera/foundation/log.dart';
|
||||||
import 'package:venera/network/app_dio.dart';
|
import 'package:venera/network/app_dio.dart';
|
||||||
import 'package:venera/utils/ext.dart';
|
import 'package:venera/utils/ext.dart';
|
||||||
|
import 'package:venera/utils/image.dart';
|
||||||
import 'package:venera/utils/io.dart';
|
import 'package:venera/utils/io.dart';
|
||||||
import 'package:venera/utils/translations.dart';
|
import 'package:venera/utils/translations.dart';
|
||||||
|
|
||||||
@@ -705,10 +706,14 @@ class _CallbackSettingState extends State<_CallbackSetting> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
});
|
});
|
||||||
await result;
|
try {
|
||||||
setState(() {
|
await result;
|
||||||
isLoading = false;
|
}
|
||||||
});
|
finally {
|
||||||
|
setState(() {
|
||||||
|
isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user