mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-05-02 00:25:11 +02:00
refactor: prompt manual update on linux
This commit is contained in:
@@ -107,6 +107,8 @@ pub struct AppUpdateInfo {
|
||||
pub download_url: String,
|
||||
pub is_nightly: bool,
|
||||
pub published_at: String,
|
||||
pub manual_update_required: bool,
|
||||
pub release_page_url: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
@@ -210,25 +212,63 @@ impl AppAutoUpdater {
|
||||
if self.should_update(¤t_version, &latest_release.tag_name, is_nightly) {
|
||||
log::info!("Update available!");
|
||||
|
||||
// Build the release page URL
|
||||
let release_page_url = format!(
|
||||
"https://github.com/zhom/donutbrowser/releases/tag/{}",
|
||||
latest_release.tag_name
|
||||
);
|
||||
|
||||
// Find the appropriate asset for current platform
|
||||
if let Some(download_url) = self.get_download_url_for_platform(&latest_release.assets) {
|
||||
let download_url = self.get_download_url_for_platform(&latest_release.assets);
|
||||
|
||||
// On Linux, we show the update notification even if auto-update is disabled
|
||||
// Users can manually download from the release page
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
let manual_update_required = download_url.is_none();
|
||||
let update_info = AppUpdateInfo {
|
||||
current_version,
|
||||
new_version: latest_release.tag_name.clone(),
|
||||
release_notes: latest_release.body.clone(),
|
||||
download_url,
|
||||
download_url: download_url.unwrap_or_else(|| release_page_url.clone()),
|
||||
is_nightly,
|
||||
published_at: latest_release.published_at.clone(),
|
||||
manual_update_required,
|
||||
release_page_url: Some(release_page_url),
|
||||
};
|
||||
|
||||
log::info!(
|
||||
"Update info prepared: {} -> {}",
|
||||
"Update info prepared: {} -> {} (manual_update_required: {})",
|
||||
update_info.current_version,
|
||||
update_info.new_version
|
||||
update_info.new_version,
|
||||
update_info.manual_update_required
|
||||
);
|
||||
return Ok(Some(update_info));
|
||||
} else {
|
||||
log::info!("No suitable download asset found for current platform");
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
{
|
||||
if let Some(url) = download_url {
|
||||
let update_info = AppUpdateInfo {
|
||||
current_version,
|
||||
new_version: latest_release.tag_name.clone(),
|
||||
release_notes: latest_release.body.clone(),
|
||||
download_url: url,
|
||||
is_nightly,
|
||||
published_at: latest_release.published_at.clone(),
|
||||
manual_update_required: false,
|
||||
release_page_url: Some(release_page_url),
|
||||
};
|
||||
|
||||
log::info!(
|
||||
"Update info prepared: {} -> {}",
|
||||
update_info.current_version,
|
||||
update_info.new_version
|
||||
);
|
||||
return Ok(Some(update_info));
|
||||
} else {
|
||||
log::info!("No suitable download asset found for current platform");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log::info!("No update needed");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { FaDownload, FaTimes } from "react-icons/fa";
|
||||
import { FaDownload, FaExternalLinkAlt, FaTimes } from "react-icons/fa";
|
||||
import { LuCheckCheck, LuCog, LuRefreshCw } from "react-icons/lu";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -60,6 +60,16 @@ export function AppUpdateToast({
|
||||
await onUpdate(updateInfo);
|
||||
};
|
||||
|
||||
const handleViewRelease = () => {
|
||||
if (updateInfo.release_page_url) {
|
||||
// Trigger the same URL handling logic as if the URL came from the system
|
||||
const event = new CustomEvent("url-open-request", {
|
||||
detail: updateInfo.release_page_url,
|
||||
});
|
||||
window.dispatchEvent(event);
|
||||
}
|
||||
};
|
||||
|
||||
const showDownloadProgress =
|
||||
isUpdating &&
|
||||
updateProgress?.stage === "downloading" &&
|
||||
@@ -101,6 +111,11 @@ export function AppUpdateToast({
|
||||
<>
|
||||
Update from {updateInfo.current_version} to{" "}
|
||||
<span className="font-medium">{updateInfo.new_version}</span>
|
||||
{updateInfo.manual_update_required && (
|
||||
<span className="block mt-1 text-muted-foreground/80">
|
||||
Manual download required on Linux
|
||||
</span>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
@@ -155,14 +170,25 @@ export function AppUpdateToast({
|
||||
|
||||
{!isUpdating && (
|
||||
<div className="flex gap-2 items-center mt-3">
|
||||
<RippleButton
|
||||
onClick={() => void handleUpdateClick()}
|
||||
size="sm"
|
||||
className="flex gap-2 items-center text-xs"
|
||||
>
|
||||
<FaDownload className="w-3 h-3" />
|
||||
Update Now
|
||||
</RippleButton>
|
||||
{updateInfo.manual_update_required ? (
|
||||
<RippleButton
|
||||
onClick={handleViewRelease}
|
||||
size="sm"
|
||||
className="flex gap-2 items-center text-xs"
|
||||
>
|
||||
<FaExternalLinkAlt className="w-3 h-3" />
|
||||
View Release
|
||||
</RippleButton>
|
||||
) : (
|
||||
<RippleButton
|
||||
onClick={() => void handleUpdateClick()}
|
||||
size="sm"
|
||||
className="flex gap-2 items-center text-xs"
|
||||
>
|
||||
<FaDownload className="w-3 h-3" />
|
||||
Update Now
|
||||
</RippleButton>
|
||||
)}
|
||||
<RippleButton
|
||||
variant="outline"
|
||||
onClick={onDismiss}
|
||||
|
||||
@@ -70,6 +70,8 @@ export interface AppUpdateInfo {
|
||||
download_url: string;
|
||||
is_nightly: boolean;
|
||||
published_at: string;
|
||||
manual_update_required: boolean;
|
||||
release_page_url?: string;
|
||||
}
|
||||
|
||||
export interface AppUpdateProgress {
|
||||
|
||||
Reference in New Issue
Block a user