mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2025-01-07 10:26:45 +03:00
delete extra files
This commit is contained in:
parent
7e500d5671
commit
09ac7f1c24
@ -1,57 +0,0 @@
|
||||
use tauri::{AppHandle, Manager};
|
||||
|
||||
use tracing::instrument;
|
||||
|
||||
#[tauri::command(async)]
|
||||
#[instrument(skip(handle))]
|
||||
pub async fn get_user(handle: tauri::AppHandle) -> Result<Option<users::User>, Error> {
|
||||
let app = handle.state::<app::App>();
|
||||
let proxy = handle.state::<assets::Proxy>();
|
||||
|
||||
match app.get_user().context("failed to get user")? {
|
||||
Some(user) => {
|
||||
let remote_picture = url::Url::parse(&user.picture).context("invalid picture url")?;
|
||||
let local_picture = match proxy.proxy(&remote_picture).await {
|
||||
Ok(picture) => picture,
|
||||
Err(e) => {
|
||||
tracing::error!("{:#}", e);
|
||||
remote_picture
|
||||
}
|
||||
};
|
||||
|
||||
let user = users::User {
|
||||
picture: local_picture.to_string(),
|
||||
..user
|
||||
};
|
||||
|
||||
Ok(Some(user))
|
||||
}
|
||||
None => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command(async)]
|
||||
#[instrument(skip(handle))]
|
||||
pub async fn set_user(handle: tauri::AppHandle, user: users::User) -> Result<(), Error> {
|
||||
let app = handle.state::<app::App>();
|
||||
|
||||
app.set_user(&user).context("failed to set user")?;
|
||||
|
||||
sentry::configure_scope(|scope| scope.set_user(Some(user.clone().into())));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command(async)]
|
||||
#[instrument(skip(handle))]
|
||||
pub async fn delete_user(handle: tauri::AppHandle) -> Result<(), Error> {
|
||||
let app = handle.state::<app::App>();
|
||||
|
||||
app.delete_user().context("failed to delete user")?;
|
||||
|
||||
sentry::configure_scope(|scope| scope.set_user(None));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -1,53 +0,0 @@
|
||||
use tauri::AppHandle;
|
||||
|
||||
use super::{storage::Storage, User};
|
||||
|
||||
pub struct Controller {
|
||||
storage: Storage,
|
||||
}
|
||||
|
||||
impl From<&AppHandle> for Controller {
|
||||
fn from(app: &AppHandle) -> Self {
|
||||
Self {
|
||||
storage: Storage::from(app),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Controller {
|
||||
pub fn set_user(&self, user: &User) -> Result<(), SetError> {
|
||||
self.storage
|
||||
.set(user)
|
||||
.map_err(|error| SetError::Other(error.into()))
|
||||
}
|
||||
|
||||
pub fn get_user(&self) -> Result<Option<User>, GetError> {
|
||||
self.storage.get().map_err(|error| match error {
|
||||
error => GetError::Other(error.into()),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn delete_user(&self) -> Result<(), DeleteError> {
|
||||
self.storage.delete().map_err(|error| match error {
|
||||
error => DeleteError::Other(error.into()),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum DeleteError {
|
||||
#[error(transparent)]
|
||||
Other(anyhow::Error),
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum GetError {
|
||||
#[error(transparent)]
|
||||
Other(anyhow::Error),
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum SetError {
|
||||
#[error(transparent)]
|
||||
Other(#[from] anyhow::Error),
|
||||
}
|
Loading…
Reference in New Issue
Block a user