feat: reload UI (#2999)

* chore: reload folder

* chore: reload folder

* chore: init sync

* chore: update tables

* chore: update database

* chore: load row

* chore: update

* chore: reload row

* test: fit test

* chore: retry

* chore: support batch fetch

* chore: enable sync

* chore: sync switch

* chore: sync switch

* chore: migration user data

* chore: migrate data

* chore: migrate folder

* chore: save user email

* chore: refresh user profile

* chore: fix test

* chore: delete translation files

* test: clippy format
This commit is contained in:
Nathan.fooo
2023-07-14 13:37:13 +08:00
committed by GitHub
parent 5085ea115f
commit f9e7b5ffa4
170 changed files with 3380 additions and 1482 deletions

View File

@ -0,0 +1,3 @@
-- This file should undo anything in `up.sql`
ALTER TABLE user_table
DROP COLUMN auth_type;

View File

@ -0,0 +1,3 @@
-- Your SQL goes here
ALTER TABLE user_table
ADD COLUMN auth_type INTEGER NOT NULL DEFAULT 0;

View File

@ -27,14 +27,13 @@ pub mod prelude {
pub use diesel::{query_dsl::*, BelongingToDsl, ExpressionMethods, RunQueryDsl};
pub use crate::*;
pub use super::UserDatabaseConnection;
}
embed_migrations!("../flowy-sqlite/migrations/");
pub const DB_NAME: &str = "flowy-database.db";
pub fn init(storage_path: &str) -> Result<Database, io::Error> {
pub fn init<P: AsRef<Path>>(storage_path: P) -> Result<Database, io::Error> {
let storage_path = storage_path.as_ref().to_str().unwrap();
if !Path::new(storage_path).exists() {
std::fs::create_dir_all(storage_path)?;
}
@ -52,7 +51,3 @@ where
let msg = format!("{:?}", e);
io::Error::new(io::ErrorKind::NotConnected, msg)
}
pub trait UserDatabaseConnection: Send + Sync {
fn get_connection(&self) -> Result<DBConnection, String>;
}

View File

@ -21,6 +21,7 @@ diesel::table! {
openai_key -> Text,
token -> Text,
email -> Text,
auth_type -> Integer,
}
}

View File

@ -1,14 +1,10 @@
use crate::sqlite::{errors::*, pragma::*};
use std::{sync::Arc, time::Duration};
use diesel::{connection::Connection, SqliteConnection};
use r2d2::{CustomizeConnection, ManageConnection, Pool};
use scheduled_thread_pool::ScheduledThreadPool;
use std::{sync::Arc, time::Duration};
lazy_static::lazy_static! {
static ref DB_POOL: Arc<ScheduledThreadPool> = Arc::new(
ScheduledThreadPool::builder().num_threads(4).thread_name_pattern("db-pool-{}:").build()
);
}
use crate::sqlite::{errors::*, pragma::*};
pub struct ConnectionPool {
pub(crate) inner: Pool<ConnectionManager>,
@ -28,7 +24,12 @@ impl ConnectionPool {
T: Into<String>,
{
let manager = ConnectionManager::new(uri);
let thread_pool = DB_POOL.clone();
let thread_pool = Arc::new(
ScheduledThreadPool::builder()
.num_threads(4)
.thread_name_pattern("db-pool-{}:")
.build(),
);
let config = Arc::new(config);
let customizer_config = DatabaseCustomizerConfig::default();