Skip to content

Commit

Permalink
removed updater
Browse files Browse the repository at this point in the history
  • Loading branch information
Waradu committed Sep 4, 2024
1 parent eb2aaea commit c0bcca2
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 124 deletions.
32 changes: 16 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 11 additions & 43 deletions apps/app-frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import { get_opening_command, initialize_state } from '@/helpers/state'
import { saveWindowState, StateFlags } from '@tauri-apps/plugin-window-state'
import { renderString } from '@modrinth/utils'
import { useFetch } from '@/helpers/fetch.js'
import { check } from '@tauri-apps/plugin-updater'
const themeStore = useTheming()
Expand Down Expand Up @@ -244,18 +243,7 @@ async function handleCommand(e) {
}
const updateAvailable = ref(false)
async function checkUpdates() {
const update = await check()
console.log(update)
updateAvailable.value = !!update
setTimeout(
() => {
checkUpdates()
},
5 * 1000 * 60,
)
}
async function checkUpdates() { }
</script>

<template>
Expand All @@ -270,14 +258,9 @@ async function checkUpdates() {
<RouterLink v-tooltip="'Home'" to="/" class="btn icon-only collapsed-button">
<HomeIcon />
</RouterLink>
<RouterLink
v-tooltip="'Browse'"
to="/browse/modpack"
class="btn icon-only collapsed-button"
:class="{
'router-link-active': isOnBrowse,
}"
>
<RouterLink v-tooltip="'Browse'" to="/browse/modpack" class="btn icon-only collapsed-button" :class="{
'router-link-active': isOnBrowse,
}">
<SearchIcon />
</RouterLink>
<RouterLink v-tooltip="'Library'" to="/library" class="btn icon-only collapsed-button">
Expand All @@ -289,21 +272,12 @@ async function checkUpdates() {
</div>
</div>
<div class="settings pages-list">
<button
v-if="updateAvailable"
v-tooltip="'Install update'"
class="btn btn-outline btn-primary icon-only collapsed-button"
@click="restartApp()"
>
<button v-if="updateAvailable" v-tooltip="'Install update'"
class="btn btn-outline btn-primary icon-only collapsed-button" @click="restartApp()">
<DownloadIcon />
</button>
<Button
v-tooltip="'Create profile'"
class="sleek-primary collapsed-button"
icon-only
:disabled="offline"
@click="() => $refs.installationModal.show()"
>
<Button v-tooltip="'Create profile'" class="sleek-primary collapsed-button" icon-only :disabled="offline"
@click="() => $refs.installationModal.show()">
<PlusIcon />
</Button>
<RouterLink v-tooltip="'Settings'" to="/settings" class="btn icon-only collapsed-button">
Expand Down Expand Up @@ -331,11 +305,7 @@ async function checkUpdates() {
<Button class="titlebar-button" icon-only @click="() => getCurrentWindow().minimize()">
<MinimizeIcon />
</Button>
<Button
class="titlebar-button"
icon-only
@click="() => getCurrentWindow().toggleMaximize()"
>
<Button class="titlebar-button" icon-only @click="() => getCurrentWindow().toggleMaximize()">
<MaximizeIcon />
</Button>
<Button class="titlebar-button close" icon-only @click="handleClose">
Expand All @@ -344,10 +314,7 @@ async function checkUpdates() {
</section>
</div>
<div class="router-view">
<ModrinthLoadingIndicator
offset-height="var(--appbar-height)"
offset-width="var(--sidebar-width)"
/>
<ModrinthLoadingIndicator offset-height="var(--appbar-height)" offset-width="var(--sidebar-width)" />
<RouterView v-slot="{ Component }">
<template v-if="Component">
<Suspense @pending="loading.startLoading()" @resolve="loading.stopLoading()">
Expand Down Expand Up @@ -400,6 +367,7 @@ async function checkUpdates() {
height: 3.25rem;
&.close {
&:hover,
&:active {
background-color: var(--color-red);
Expand Down
56 changes: 0 additions & 56 deletions apps/app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,58 +29,7 @@ async fn initialize_state(app: tauri::AppHandle) -> api::Result<()> {

#[cfg(feature = "updater")]
{
use tauri_plugin_updater::UpdaterExt;

let updater = app.updater_builder().build()?;

let update_fut = updater.check();

State::init().await?;

let check_bar = theseus::init_loading(
theseus::LoadingBarType::CheckingForUpdates,
1.0,
"Checking for updates...",
)
.await?;

let update = update_fut.await;

drop(check_bar);

if let Some(update) = update.ok().flatten() {
tracing::info!("Update found: {:?}", update.download_url);
let loader_bar_id = theseus::init_loading(
theseus::LoadingBarType::LauncherUpdate {
version: update.version.clone(),
current_version: update.current_version.clone(),
},
1.0,
"Updating Modrinth App...",
)
.await?;

// 100 MiB
const DEFAULT_CONTENT_LENGTH: u64 = 1024 * 1024 * 100;

update
.download_and_install(
|chunk_length, content_length| {
let _ = theseus::emit_loading(
&loader_bar_id,
(chunk_length as f64)
/ (content_length
.unwrap_or(DEFAULT_CONTENT_LENGTH)
as f64),
None,
);
},
|| {},
)
.await?;

app.restart();
}
}

#[cfg(not(feature = "updater"))]
Expand Down Expand Up @@ -163,11 +112,6 @@ fn main() {

let mut builder = tauri::Builder::default();

#[cfg(feature = "updater")]
{
builder = builder.plugin(tauri_plugin_updater::Builder::new().build());
}

builder = builder
.plugin(tauri_plugin_single_instance::init(|app, args, _cwd| {
if let Some(payload) = args.get(1) {
Expand Down
20 changes: 11 additions & 9 deletions apps/app/tauri-release.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
"createUpdaterArtifacts": "v1Compatible"
},
"build": {
"features": ["updater"]
"features": [
"updater"
]
},
"app": {
"security": {
"capabilities": ["ads", "core", "plugins", "updater"]
"capabilities": [
"ads",
"core",
"plugins",
"updater"
]
}
},
"plugins": {
"updater": {
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDIwMzM5QkE0M0FCOERBMzkKUldRNTJyZzZwSnN6SUdPRGdZREtUUGxMblZqeG9OVHYxRUlRTzJBc2U3MUNJaDMvZDQ1UytZZmYK",
"endpoints": ["https://launcher-files.modrinth.com/updates.json"]
}
}
}
"plugins": {}
}

0 comments on commit c0bcca2

Please sign in to comment.