mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 17:18:32 +02:00
Show alert after force checking updates
This commit is contained in:
@@ -733,7 +733,7 @@ async fn check_for_updates(
|
|||||||
app_handle: AppHandle<Wry>,
|
app_handle: AppHandle<Wry>,
|
||||||
db_instance: State<'_, Mutex<Pool<Sqlite>>>,
|
db_instance: State<'_, Mutex<Pool<Sqlite>>>,
|
||||||
yaak_updater: State<'_, Mutex<YaakUpdater>>,
|
yaak_updater: State<'_, Mutex<YaakUpdater>>,
|
||||||
) -> Result<(), String> {
|
) -> Result<bool, String> {
|
||||||
let pool = &*db_instance.lock().await;
|
let pool = &*db_instance.lock().await;
|
||||||
let update_mode = get_update_mode(pool).await;
|
let update_mode = get_update_mode(pool).await;
|
||||||
yaak_updater
|
yaak_updater
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ impl YaakUpdater {
|
|||||||
&mut self,
|
&mut self,
|
||||||
app_handle: &AppHandle<Wry>,
|
app_handle: &AppHandle<Wry>,
|
||||||
mode: UpdateMode,
|
mode: UpdateMode,
|
||||||
) -> Result<(), updater::Error> {
|
) -> Result<bool, updater::Error> {
|
||||||
self.last_update_check = SystemTime::now();
|
self.last_update_check = SystemTime::now();
|
||||||
|
|
||||||
let update_mode = get_update_mode_str(mode);
|
let update_mode = get_update_mode_str(mode);
|
||||||
@@ -37,7 +37,7 @@ impl YaakUpdater {
|
|||||||
info!("Checking for updates mode={} enabled={}", update_mode, enabled);
|
info!("Checking for updates mode={} enabled={}", update_mode, enabled);
|
||||||
|
|
||||||
if !enabled {
|
if !enabled {
|
||||||
return Ok(());
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
match app_handle
|
match app_handle
|
||||||
@@ -81,9 +81,9 @@ impl YaakUpdater {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
Ok(())
|
Ok(true)
|
||||||
}
|
}
|
||||||
Err(updater::Error::UpToDate) => Ok(()),
|
Err(updater::Error::UpToDate) => Ok(false),
|
||||||
Err(e) => Err(e),
|
Err(e) => Err(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,9 +91,10 @@ impl YaakUpdater {
|
|||||||
&mut self,
|
&mut self,
|
||||||
app_handle: &AppHandle<Wry>,
|
app_handle: &AppHandle<Wry>,
|
||||||
mode: UpdateMode,
|
mode: UpdateMode,
|
||||||
) -> Result<(), updater::Error> {
|
) -> Result<bool, updater::Error> {
|
||||||
if self.last_update_check.elapsed().unwrap().as_secs() < MAX_UPDATE_CHECK_SECONDS {
|
let ignore_check = self.last_update_check.elapsed().unwrap().as_secs() < MAX_UPDATE_CHECK_SECONDS;
|
||||||
return Ok(());
|
if ignore_check {
|
||||||
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.force_check(app_handle, mode).await
|
self.force_check(app_handle, mode).await
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { invoke, shell } from '@tauri-apps/api';
|
import { invoke, shell } from '@tauri-apps/api';
|
||||||
import { useRef, useState } from 'react';
|
import { useRef, useState } from 'react';
|
||||||
|
import { useAlert } from '../hooks/useAlert';
|
||||||
import { useAppVersion } from '../hooks/useAppVersion';
|
import { useAppVersion } from '../hooks/useAppVersion';
|
||||||
import { useExportData } from '../hooks/useExportData';
|
import { useExportData } from '../hooks/useExportData';
|
||||||
import { useImportData } from '../hooks/useImportData';
|
import { useImportData } from '../hooks/useImportData';
|
||||||
@@ -20,6 +21,7 @@ export function SettingsDropdown() {
|
|||||||
const appVersion = useAppVersion();
|
const appVersion = useAppVersion();
|
||||||
const dropdownRef = useRef<DropdownRef>(null);
|
const dropdownRef = useRef<DropdownRef>(null);
|
||||||
const dialog = useDialog();
|
const dialog = useDialog();
|
||||||
|
const alert = useAlert();
|
||||||
const [showChangelog, setShowChangelog] = useState<boolean>(false);
|
const [showChangelog, setShowChangelog] = useState<boolean>(false);
|
||||||
|
|
||||||
useListenToTauriEvent('show_changelog', () => {
|
useListenToTauriEvent('show_changelog', () => {
|
||||||
@@ -98,7 +100,16 @@ export function SettingsDropdown() {
|
|||||||
key: 'update-check',
|
key: 'update-check',
|
||||||
label: 'Check for Updates',
|
label: 'Check for Updates',
|
||||||
leftSlot: <Icon icon="update" />,
|
leftSlot: <Icon icon="update" />,
|
||||||
onSelect: () => invoke('check_for_updates'),
|
onSelect: async () => {
|
||||||
|
const hasUpdate: boolean = await invoke('check_for_updates');
|
||||||
|
if (!hasUpdate) {
|
||||||
|
alert({
|
||||||
|
title: 'No Updates',
|
||||||
|
body: 'You are currently up to date',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
console.log('HAS UPDATE', hasUpdate);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'feedback',
|
key: 'feedback',
|
||||||
|
|||||||
Reference in New Issue
Block a user