mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-14 08:41:21 +10:00
feat: retry connnection on server unavailable
This commit is contained in:
@ -20,9 +20,15 @@
|
|||||||
We were unable to contact your Drop instance. See if you can open it
|
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.
|
in your web browser, or contact your server admin for help.
|
||||||
</p>
|
</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
|
<NuxtLink
|
||||||
to="/setup"
|
to="/setup"
|
||||||
class="text-sm text-left font-semibold leading-7 text-blue-600"
|
class="text-sm text-left font-semibold leading-7 text-blue-600"
|
||||||
>
|
>
|
||||||
Connect to different instance <span aria-hidden="true">→</span>
|
Connect to different instance <span aria-hidden="true">→</span>
|
||||||
@ -68,7 +74,15 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { ArrowPathIcon } from "@heroicons/vue/24/outline";
|
||||||
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
layout: "mini",
|
layout: "mini",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function retry() {
|
||||||
|
await invoke("retry_connect");
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
use std::{
|
use std::{
|
||||||
env,
|
borrow::BorrowMut, env, sync::Mutex, time::{SystemTime, UNIX_EPOCH}
|
||||||
sync::Mutex,
|
|
||||||
time::{SystemTime, UNIX_EPOCH},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use log::{info, warn};
|
use log::{info, warn};
|
||||||
@ -11,7 +9,7 @@ use tauri::{AppHandle, Emitter, Manager};
|
|||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::{DatabaseAuth, DatabaseImpls},
|
db::{self, DatabaseAuth, DatabaseImpls},
|
||||||
remote::RemoteAccessError,
|
remote::RemoteAccessError,
|
||||||
AppState, AppStatus, User, DB,
|
AppState, AppStatus, User, DB,
|
||||||
};
|
};
|
||||||
@ -185,6 +183,18 @@ pub async fn auth_initiate<'a>() -> Result<(), String> {
|
|||||||
Ok(())
|
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>), ()> {
|
pub fn setup() -> Result<(AppStatus, Option<User>), ()> {
|
||||||
let data = DB.borrow_data().unwrap();
|
let data = DB.borrow_data().unwrap();
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ mod settings;
|
|||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
use crate::db::DatabaseImpls;
|
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 db::{add_download_dir, delete_download_dir, fetch_download_dir_stats, DatabaseInterface, DATA_ROOT_DIR};
|
||||||
use downloads::download_commands::*;
|
use downloads::download_commands::*;
|
||||||
use downloads::download_manager::DownloadManagerBuilder;
|
use downloads::download_manager::DownloadManagerBuilder;
|
||||||
@ -120,6 +120,7 @@ pub fn run() {
|
|||||||
fetch_state,
|
fetch_state,
|
||||||
// Auth
|
// Auth
|
||||||
auth_initiate,
|
auth_initiate,
|
||||||
|
retry_connect,
|
||||||
// Remote
|
// Remote
|
||||||
use_remote,
|
use_remote,
|
||||||
gen_drop_url,
|
gen_drop_url,
|
||||||
|
|||||||
Reference in New Issue
Block a user