Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Next
- Use Shift instead of Alt for Videos/Channels page shortcuts
- Add option to disable window decorations
- Fix keyboard input working when modal is open
- Remove old YouTube Email Notifier migration

Expand Down
6 changes: 3 additions & 3 deletions bindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ async addChannel(options: AddChannelOptions) : Promise<Result<null, string>> {
else return { status: "error", error: e as any };
}
},
async setGeneralSettings(apiKey: string, maxConcurrentRequests: number, checkInBackground: boolean) : Promise<Result<null, string>> {
async setGeneralSettings(apiKey: string, maxConcurrentRequests: number, checkInBackground: boolean, noWindowDecorations: boolean) : Promise<Result<null, string>> {
try {
return { status: "ok", data: await TAURI_INVOKE("set_general_settings", { apiKey, maxConcurrentRequests, checkInBackground }) };
return { status: "ok", data: await TAURI_INVOKE("set_general_settings", { apiKey, maxConcurrentRequests, checkInBackground, noWindowDecorations }) };
} catch (e) {
if(e instanceof Error) throw e;
else return { status: "error", error: e as any };
Expand Down Expand Up @@ -105,7 +105,7 @@ export type AddChannelOptions = { url: string; from_time: number; refresh_rate_m
export type After = { publishTimeMs: number; id: string }
export type Channel = { id: string; name: string; icon: string; uploads_playlist_id: string; from_time: number; refresh_rate_ms: number; tags: string[] }
export type Options = { show_all: boolean; show_archived: boolean; channel_filter: string; tag: string | null; limit: number }
export type Settings = { api_key: string; max_concurrent_requests: number; channels: Channel[]; check_in_background: boolean }
export type Settings = { api_key: string; max_concurrent_requests: number; channels: Channel[]; check_in_background: boolean; no_window_decorations?: boolean }
export type UndoHistory = { entries: ([number, Action])[] }
export type Video = { id: string; title: string; description: string; publishTimeMs: number;
/**
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ pub mod videos {
}
#[derive(Deserialize, Debug)]
pub struct Thumbnail {
#[allow(dead_code)]
pub url: String,
}
}
Expand Down
10 changes: 9 additions & 1 deletion src-tauri/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::io::Write;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use std::time::{SystemTime, UNIX_EPOCH};
use tauri::{command, Config, Error, State};
use tauri::{command, Config, Error, Manager, State};
use tokio::sync::Mutex;
use url::Url;

Expand Down Expand Up @@ -283,15 +283,23 @@ pub async fn add_channel(options: AddChannelOptions, data: DataState<'_>) -> Res
#[command]
#[specta::specta]
pub async fn set_general_settings(
app_handle: tauri::AppHandle,
api_key: String,
max_concurrent_requests: u32,
check_in_background: bool,
no_window_decorations: bool,
data: DataState<'_>,
) -> Result<(), String> {
let mut data = data.0.lock().await;
data.settings().set_api_key(api_key);
data.settings().max_concurrent_requests = max_concurrent_requests;
data.settings().check_in_background = check_in_background;
data.settings().no_window_decorations = no_window_decorations;
app_handle
.get_webview_window("main")
.unwrap()
.set_decorations(!no_window_decorations)
.unwrap();
data.save_settings()?;
Ok(())
}
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ pub async fn run() {
.title("Kadium")
.inner_size(900.0, 800.0)
.min_inner_size(400.0, 150.0)
.decorations(!settings.unwrap_ref().no_window_decorations)
.theme(Some(tauri::Theme::Dark));

#[cfg(target_os = "macos")]
Expand Down
4 changes: 4 additions & 0 deletions src-tauri/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ impl Default for VersionedSettings {
max_concurrent_requests: 5,
channels: Vec::new(),
check_in_background: true,
no_window_decorations: false,
})
}
}
Expand Down Expand Up @@ -91,8 +92,11 @@ pub struct Settings {
pub max_concurrent_requests: u32,
pub channels: Vec<Channel>,
pub check_in_background: bool,
#[serde(default)]
pub no_window_decorations: bool,
}
impl Settings {
#[allow(dead_code)]
pub fn wrap(self) -> VersionedSettings {
VersionedSettings::V1(self)
}
Expand Down
1 change: 1 addition & 0 deletions src/lib/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,6 @@ export function enableSampleData() {
return channels
})(),
check_in_background: true,
no_window_decorations: true,
})
}
14 changes: 13 additions & 1 deletion src/lib/modals/Settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@
export let apiKey: string
export let maxConcurrentRequests: number
export let checkInBackground: boolean
export let noWindowDecorations: boolean

export let visible = false
let keyGuideVisible = false

async function setGeneralSettings() {
await commands.setGeneralSettings(apiKey, maxConcurrentRequests, checkInBackground)
await commands.setGeneralSettings(
apiKey,
maxConcurrentRequests,
checkInBackground,
noWindowDecorations,
)
await loadSettings()
visible = false
}
Expand Down Expand Up @@ -43,6 +49,12 @@
</label>
<Switch id="check-in-background" bind:checked={checkInBackground} />
</div>
<div class="toggle-row">
<label for="window-decorations">
<p>Disable window decorations</p>
</label>
<Switch id="no-window-decorations" bind:checked={noWindowDecorations} />
</div>
<div class="buttons">
<Button secondary on:click={() => (visible = false)}>Cancel</Button>
<div class="spacer" />
Expand Down
1 change: 1 addition & 0 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
apiKey={$settings.api_key}
maxConcurrentRequests={$settings.max_concurrent_requests}
checkInBackground={$settings.check_in_background}
noWindowDecorations={$settings.no_window_decorations ?? false}
bind:visible={$settingsOpen}
/>

Expand Down
Loading