mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-14 16:51:18 +10:00
feat: retry connnection on server unavailable
This commit is contained in:
@ -20,7 +20,13 @@
|
||||
We were unable to contact your Drop instance. See if you can open it
|
||||
in your web browser, or contact your server admin for help.
|
||||
</p>
|
||||
<div class="mt-10">
|
||||
<div class="mt-10 space-x-10">
|
||||
<button
|
||||
@click="() => retry()"
|
||||
class="inline-flex gap-x-2 items-center text-sm text-left font-semibold leading-7 text-white"
|
||||
>
|
||||
Retry <ArrowPathIcon class="w-5 h-5" />
|
||||
</button>
|
||||
<NuxtLink
|
||||
to="/setup"
|
||||
class="text-sm text-left font-semibold leading-7 text-blue-600"
|
||||
@ -68,7 +74,15 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ArrowPathIcon } from "@heroicons/vue/24/outline";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
|
||||
definePageMeta({
|
||||
layout: "mini",
|
||||
});
|
||||
|
||||
async function retry() {
|
||||
await invoke("retry_connect");
|
||||
location.reload();
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
use std::{
|
||||
env,
|
||||
sync::Mutex,
|
||||
time::{SystemTime, UNIX_EPOCH},
|
||||
borrow::BorrowMut, env, sync::Mutex, time::{SystemTime, UNIX_EPOCH}
|
||||
};
|
||||
|
||||
use log::{info, warn};
|
||||
@ -11,7 +9,7 @@ use tauri::{AppHandle, Emitter, Manager};
|
||||
use url::Url;
|
||||
|
||||
use crate::{
|
||||
db::{DatabaseAuth, DatabaseImpls},
|
||||
db::{self, DatabaseAuth, DatabaseImpls},
|
||||
remote::RemoteAccessError,
|
||||
AppState, AppStatus, User, DB,
|
||||
};
|
||||
@ -185,6 +183,18 @@ pub async fn auth_initiate<'a>() -> Result<(), String> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn retry_connect(state: tauri::State<'_, Mutex<AppState>>) -> Result<(), ()> {
|
||||
let (app_status, user) = setup()?;
|
||||
|
||||
let mut guard = state.lock().unwrap();
|
||||
guard.status = app_status;
|
||||
guard.user = user;
|
||||
drop(guard);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn setup() -> Result<(AppStatus, Option<User>), ()> {
|
||||
let data = DB.borrow_data().unwrap();
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ mod settings;
|
||||
mod tests;
|
||||
|
||||
use crate::db::DatabaseImpls;
|
||||
use auth::{auth_initiate, generate_authorization_header, recieve_handshake};
|
||||
use auth::{auth_initiate, generate_authorization_header, recieve_handshake, retry_connect};
|
||||
use db::{add_download_dir, delete_download_dir, fetch_download_dir_stats, DatabaseInterface, DATA_ROOT_DIR};
|
||||
use downloads::download_commands::*;
|
||||
use downloads::download_manager::DownloadManagerBuilder;
|
||||
@ -120,6 +120,7 @@ pub fn run() {
|
||||
fetch_state,
|
||||
// Auth
|
||||
auth_initiate,
|
||||
retry_connect,
|
||||
// Remote
|
||||
use_remote,
|
||||
gen_drop_url,
|
||||
|
||||
Reference in New Issue
Block a user