Skip to content

Commit

Permalink
Merge pull request #40 from ryoha000/feat/home.scroll.keep
Browse files Browse the repository at this point in the history
home画面との画面の行き来でスクロール位置を保持
  • Loading branch information
ryoha000 authored Jan 6, 2024
2 parents 23b88a6 + c6ea765 commit 819dbf3
Show file tree
Hide file tree
Showing 26 changed files with 712 additions and 259 deletions.
102 changes: 99 additions & 3 deletions src-tauri/Cargo.lock

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

27 changes: 25 additions & 2 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ serde_json = "1.0"
anyhow = "1.0"
thiserror = "1.0"
async-trait = "0.1.57"
sqlx = { version = "0.6", features = [ "runtime-tokio-rustls", "sqlite", "chrono" ] }
sqlx = { version = "0.6", features = [
"runtime-tokio-rustls",
"sqlite",
"chrono",
] }
chrono = { version = "0.4.26", features = ["serde"] }
derive-new = "0.5.0"
walkdir = "2"
Expand All @@ -34,11 +38,30 @@ url = "2.4.1"
tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
ico = "0.3.0"
sysinfo = "0.29.10"
refinery = { version = "0.8", features = ["rusqlite"] }

[dependencies.windows]
version = "0.51"
features = [
"Win32_System_Com", "Win32_Foundation", "Win32_System_Ole", "Win32_UI_Shell", "Win32_Storage_FileSystem", "Win32_UI_WindowsAndMessaging", "Win32_Graphics_Direct3D", "Graphics_Capture", "Win32_Graphics_Dxgi", "Win32_Graphics_Direct3D11", "Win32_System_WinRT_Direct3D11", "Graphics_DirectX_Direct3D11", "Win32_System_WinRT_Graphics_Capture", "Win32_Graphics_Dwm", "Win32_Graphics_Dxgi_Common", "Foundation", "Graphics_Imaging", "Storage", "Storage_Streams"
"Win32_System_Com",
"Win32_Foundation",
"Win32_System_Ole",
"Win32_UI_Shell",
"Win32_Storage_FileSystem",
"Win32_UI_WindowsAndMessaging",
"Win32_Graphics_Direct3D",
"Graphics_Capture",
"Win32_Graphics_Dxgi",
"Win32_Graphics_Direct3D11",
"Win32_System_WinRT_Direct3D11",
"Graphics_DirectX_Direct3D11",
"Win32_System_WinRT_Graphics_Capture",
"Win32_Graphics_Dwm",
"Win32_Graphics_Dxgi_Common",
"Foundation",
"Graphics_Imaging",
"Storage",
"Storage_Streams",
]

[dependencies.uuid]
Expand Down
2 changes: 2 additions & 0 deletions src-tauri/src/domain/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pub struct CollectionElement {
pub install_at: Option<DateTime<Local>>,
pub last_play_at: Option<DateTime<Local>>,
pub like_at: Option<DateTime<Local>>,
pub thumbnail_width: Option<i32>,
pub thumbnail_height: Option<i32>,
pub created_at: DateTime<Local>,
pub updated_at: DateTime<Local>,
}
Expand Down
7 changes: 7 additions & 0 deletions src-tauri/src/domain/repository/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ pub trait CollectionRepository {
id: &Id<CollectionElement>,
) -> Result<Option<CollectionElement>>;
async fn upsert_collection_element(&self, new_elements: &NewCollectionElement) -> Result<()>;
async fn upsert_collection_element_thumbnail_size(
&self,
id: &Id<CollectionElement>,
width: i32,
height: i32,
) -> Result<()>;
async fn get_null_thumbnail_size_element_ids(&self) -> Result<Vec<Id<CollectionElement>>>;
async fn remove_conflict_maps(&self) -> Result<()>;
async fn delete_collection_element(&self, element_id: &Id<CollectionElement>) -> Result<()>;

Expand Down
28 changes: 28 additions & 0 deletions src-tauri/src/infrastructure/repositoryimpl/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,34 @@ impl CollectionRepository for RepositoryImpl<CollectionElement> {
.await?;
Ok(())
}
async fn upsert_collection_element_thumbnail_size(
&self,
id: &Id<CollectionElement>,
width: i32,
height: i32,
) -> anyhow::Result<()> {
let pool = self.pool.0.clone();
query(
"update collection_elements set thumbnail_width = ?, thumbnail_height = ? where id = ?",
)
.bind(width)
.bind(height)
.bind(id.value)
.execute(&*pool)
.await?;
Ok(())
}
async fn get_null_thumbnail_size_element_ids(
&self,
) -> anyhow::Result<Vec<Id<CollectionElement>>> {
let pool = self.pool.0.clone();
let ids: Vec<(i32,)> = sqlx::query_as(
"SELECT id FROM collection_elements WHERE thumbnail_width IS NULL OR thumbnail_height IS NULL",
)
.fetch_all(&*pool)
.await?;
Ok(ids.into_iter().map(|v| Id::new(v.0)).collect())
}
async fn remove_conflict_maps(&self) -> anyhow::Result<()> {
let pool = self.pool.0.clone();
let not_delete_ids: Vec<(i32,)> = sqlx::query_as(
Expand Down
10 changes: 10 additions & 0 deletions src-tauri/src/infrastructure/repositoryimpl/driver.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{path::Path, str::FromStr, sync::Arc};

use refinery::config::{Config, ConfigDbType};
use sqlx::{
sqlite::{SqliteConnectOptions, SqlitePoolOptions},
Pool, Sqlite,
Expand All @@ -12,6 +13,11 @@ pub struct Db(pub(crate) Arc<Pool<Sqlite>>);

const DB_FILE: &str = "launcherg_sqlite.db3";

mod embedded {
use refinery::embed_migrations;
embed_migrations!("./src/migrations");
}

impl Db {
pub async fn new() -> Db {
let root = get_save_root_abs_dir();
Expand All @@ -32,6 +38,10 @@ impl Db {
.map_err(|err| format!("{}\nfile: {}", err.to_string(), db_filename))
.unwrap();

// migrate
let mut conf = Config::new(ConfigDbType::Sqlite).set_db_path(&db_filename);
embedded::migrations::runner().run(&mut conf).unwrap();

println!("finish setup database. file: {:?}", db_filename);

Db(Arc::new(pool))
Expand Down
Loading

0 comments on commit 819dbf3

Please sign in to comment.