Some fixes

This commit is contained in:
mindfreq 2026-05-04 12:17:47 +02:00
parent 28fe1e42e5
commit 233c5aafed
11 changed files with 32 additions and 54 deletions

View file

@ -1,3 +0,0 @@
{
"recommendations": ["tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"]
}

2
src-tauri/Cargo.lock generated
View file

@ -3348,7 +3348,7 @@ dependencies = [
[[package]]
name = "rufeed"
version = "0.3.0"
version = "0.4.0"
dependencies = [
"cached",
"feed-rs",

View file

@ -1,7 +1,7 @@
[package]
name = "rufeed"
version = "0.3.0"
description = "A Tauri App"
version = "0.4.0"
description = "A feed reader"
authors = ["Ahmed Nagi"]
edition = "2021"

View file

@ -1,23 +0,0 @@
[
{
"id": "17a52b7a-cb76-4d84-bc37-110537c2f7ca",
"title": "Rust Blog",
"url": "https://blog.rust-lang.org/",
"feed_url": "https://blog.rust-lang.org/feed.xml",
"icon": "https://blog.rust-lang.org/images/apple-touch-icon.png"
},
{
"id": "c414b24b-c429-4d56-9be5-aa2e0c042fc0",
"title": "RSS feed for os.phil-opp.com",
"url": "https://os.phil-opp.com/",
"feed_url": "https://os.phil-opp.com/rss.xml",
"icon": "https://os.phil-opp.com/favicon.ico"
},
{
"id": "e4a39047-3c64-4beb-9622-9fd02062cff5",
"title": "عالم الكمبيوتر- RSS",
"url": "https://www.computer-wd.com/",
"feed_url": "https://www.computer-wd.com/rss.xml",
"icon": "https://www.computer-wd.com/favicon.ico"
}
]

View file

@ -1,6 +1,6 @@
use once_cell::sync::Lazy;
use std::sync::LazyLock;
pub static CLIENT: Lazy<reqwest::Client> = Lazy::new(|| {
pub static CLIENT: LazyLock<reqwest::Client> = LazyLock::new(|| {
reqwest::Client::builder()
.timeout(std::time::Duration::from_secs(20))
.connect_timeout(std::time::Duration::from_secs(10))

View file

@ -1,21 +1,32 @@
use std::fs;
use std::path::PathBuf;
use std::sync::OnceLock;
use serde::{Deserialize, Serialize};
use tauri::Manager;
use crate::Error;
static CONFIG_PATH: OnceLock<PathBuf> = OnceLock::new();
fn get_config_path(app: &tauri::AppHandle) -> Result<PathBuf, String> {
let config_dir = app.path().app_config_dir()
.map_err(|e| e.to_string())?;
pub fn init_config_path(app: &tauri::AppHandle) -> Result<(), String> {
let config_dir = app.path().app_config_dir().map_err(|e| e.to_string())?;
// Create dir if not exist
fs::create_dir_all(&config_dir).map_err(|e| e.to_string())?;
Ok(config_dir.join("config.json"))
let path = config_dir.join("feeds.json");
CONFIG_PATH
.set(path)
.map_err(|_| "Config path already initialized".to_string())?;
Ok(())
}
fn get_feeds_path() -> Result<&'static PathBuf, Error> {
CONFIG_PATH
.get()
.ok_or_else(|| Error::MissingField("Config path not initialized".to_string()))
}
pub mod feed_config {
use super::*;
@ -56,7 +67,7 @@ pub mod feed_config {
};
feeds.push(new_feed);
let json = serde_json::to_string_pretty(&feeds)?;
fs::write("feeds.json", json)?;
fs::write(get_feeds_path()?, json)?;
Ok(feeds.pop().unwrap())
}
@ -70,13 +81,13 @@ pub mod feed_config {
let removed = feeds.remove(index);
let json = serde_json::to_string_pretty(&feeds)?;
fs::write("feeds.json", json)?;
fs::write(get_feeds_path()?, json)?;
Ok(removed)
}
fn get_content() -> Result<Vec<Feed>, Error> {
let path = std::path::Path::new("feeds.json");
let path = std::path::Path::new(get_feeds_path()?);
if !path.exists() {
fs::write(path, "[]")?;
}

View file

@ -5,18 +5,13 @@ pub mod parser;
use commands::feed::{add_feed, get_entry, get_feed_item, get_feeds, remove_feed};
pub async fn test_thing() -> Result<(), Error> {
// match get_entry("https://blog.rust-lang.org/", "https://blog.rust-lang.org/2026/03/20/rust-challenges/").await {
// Ok(feed) => println!("{:?}", feed),
// Err(e) => eprintln!("add_feed failed: {}", e),
// }
Ok(())
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.setup(|app| {
config::init_config_path(&app.handle())?;
Ok(())
})
.plugin(tauri_plugin_opener::init())
.invoke_handler(tauri::generate_handler![
add_feed,

View file

@ -3,6 +3,5 @@
#[tokio::main]
async fn main() {
// rufeed_lib::test_thing().await;
rufeed_lib::run()
}

View file

@ -1,8 +1,8 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "rufeed",
"version": "0.1.0",
"identifier": "com.army.rufeed",
"version": "0.4.0",
"identifier": "com.mindfeq.rufeed",
"build": {
"beforeDevCommand": "pnpm dev",
"devUrl": "http://localhost:1420",

View file

@ -1 +0,0 @@
error: manifest path `/home/army/Desktop/proj/rufeed/Cargo.toml` does not exist