fix check update (#9444)
check_software_update runs in a new thread, won't return directly Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
parent
49989e34e4
commit
e4f7e126e5
@ -570,3 +570,5 @@ enum WindowsTarget {
|
|||||||
extension WindowsTargetExt on int {
|
extension WindowsTargetExt on int {
|
||||||
WindowsTarget get windowsVersion => getWindowsTarget(this);
|
WindowsTarget get windowsVersion => getWindowsTarget(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const kCheckSoftwareUpdateFinish = 'check_software_update_finish';
|
@ -664,9 +664,17 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
if (!bind.isCustomClient()) {
|
if (!bind.isCustomClient()) {
|
||||||
|
platformFFI.registerEventHandler(
|
||||||
|
kCheckSoftwareUpdateFinish, kCheckSoftwareUpdateFinish,
|
||||||
|
(Map<String, dynamic> evt) async {
|
||||||
|
if (evt['url'] is String) {
|
||||||
|
setState(() {
|
||||||
|
updateUrl = evt['url'];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
Timer(const Duration(seconds: 1), () async {
|
Timer(const Duration(seconds: 1), () async {
|
||||||
updateUrl = await bind.mainGetSoftwareUpdateUrl();
|
bind.mainGetSoftwareUpdateUrl();
|
||||||
if (updateUrl.isNotEmpty) setState(() {});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
_updateTimer = periodic_immediate(const Duration(seconds: 1), () async {
|
_updateTimer = periodic_immediate(const Duration(seconds: 1), () async {
|
||||||
@ -824,6 +832,10 @@ class _DesktopHomePageState extends State<DesktopHomePage>
|
|||||||
_uniLinksSubscription?.cancel();
|
_uniLinksSubscription?.cancel();
|
||||||
Get.delete<RxBool>(tag: 'stop-service');
|
Get.delete<RxBool>(tag: 'stop-service');
|
||||||
_updateTimer?.cancel();
|
_updateTimer?.cancel();
|
||||||
|
if (!bind.isCustomClient()) {
|
||||||
|
platformFFI.unregisterEventHandler(
|
||||||
|
kCheckSoftwareUpdateFinish, kCheckSoftwareUpdateFinish);
|
||||||
|
}
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,9 +70,17 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
|||||||
}
|
}
|
||||||
if (isAndroid) {
|
if (isAndroid) {
|
||||||
if (!bind.isCustomClient()) {
|
if (!bind.isCustomClient()) {
|
||||||
|
platformFFI.registerEventHandler(
|
||||||
|
kCheckSoftwareUpdateFinish, kCheckSoftwareUpdateFinish,
|
||||||
|
(Map<String, dynamic> evt) async {
|
||||||
|
if (evt['url'] is String) {
|
||||||
|
setState(() {
|
||||||
|
_updateUrl = evt['url'];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
Timer(const Duration(seconds: 1), () async {
|
Timer(const Duration(seconds: 1), () async {
|
||||||
_updateUrl = await bind.mainGetSoftwareUpdateUrl();
|
bind.mainGetSoftwareUpdateUrl();
|
||||||
if (_updateUrl.isNotEmpty) setState(() {});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -353,6 +361,10 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
|||||||
if (Get.isRegistered<IDTextEditingController>()) {
|
if (Get.isRegistered<IDTextEditingController>()) {
|
||||||
Get.delete<IDTextEditingController>();
|
Get.delete<IDTextEditingController>();
|
||||||
}
|
}
|
||||||
|
if (!bind.isCustomClient()) {
|
||||||
|
platformFFI.unregisterEventHandler(
|
||||||
|
kCheckSoftwareUpdateFinish, kCheckSoftwareUpdateFinish);
|
||||||
|
}
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -830,6 +830,16 @@ async fn check_software_update_() -> hbb_common::ResultType<()> {
|
|||||||
if get_version_number(&latest_release_version) > get_version_number(crate::VERSION) {
|
if get_version_number(&latest_release_version) > get_version_number(crate::VERSION) {
|
||||||
*SOFTWARE_UPDATE_URL.lock().unwrap() = response_url;
|
*SOFTWARE_UPDATE_URL.lock().unwrap() = response_url;
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "flutter")]
|
||||||
|
{
|
||||||
|
let mut m = HashMap::new();
|
||||||
|
m.insert("name", "check_software_update_finish");
|
||||||
|
let url = SOFTWARE_UPDATE_URL.lock().unwrap().clone();
|
||||||
|
m.insert("url", url.as_str());
|
||||||
|
if let Ok(data) = serde_json::to_string(&m) {
|
||||||
|
let _ = crate::flutter::push_global_event(crate::flutter::APP_TYPE_MAIN, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user