Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat(league): avisar sobre jogadores anotados e grupos de cinco com perfil oculto (#255)

antonio44031812ab86
diff --git a/src-tauri/omniget-core/src/models/settings.rs b/src-tauri/omniget-core/src/models/settings.rs
index 3c1fe48c..8b64b986 100644
--- a/src-tauri/omniget-core/src/models/settings.rs
+++ b/src-tauri/omniget-core/src/models/settings.rs
@@ -53,6 +53,8 @@ pub struct LeagueSettings {
pub auto_accept: bool,
#[serde(default)]
pub auto_accept_delay: u8,
+ #[serde(default = "default_notify_ready_check")]
+ pub notify_ready_check: bool,
#[serde(default)]
pub auto_pick: bool,
#[serde(default)]
@@ -81,12 +83,17 @@ fn default_league_enabled() -> bool {
true
}
+fn default_notify_ready_check() -> bool {
+ true
+}
+
impl Default for LeagueSettings {
fn default() -> Self {
Self {
enabled: default_league_enabled(),
auto_accept: false,
auto_accept_delay: 0,
+ notify_ready_check: default_notify_ready_check(),
auto_pick: false,
auto_ban: false,
auto_lock: false,
diff --git a/src-tauri/src/commands/league/ws.rs b/src-tauri/src/commands/league/ws.rs
index 74762d9a..e6f4cd1c 100644
--- a/src-tauri/src/commands/league/ws.rs
+++ b/src-tauri/src/commands/league/ws.rs
@@ -4,7 +4,8 @@ use futures::{SinkExt, StreamExt};
use once_cell::sync::OnceCell;
use serde_json::{json, Value};
use std::sync::atomic::{AtomicBool, Ordering};
-use tauri::Emitter;
+use tauri::{Emitter, Manager};
+use tauri_plugin_notification::NotificationExt;
use tokio_tungstenite::tungstenite::client::IntoClientRequest;
use tokio_tungstenite::tungstenite::Message;
use tokio_tungstenite::Connector;
@@ -14,6 +15,7 @@ static STARTED: AtomicBool = AtomicBool::new(false);
static WS_CONNECTED: AtomicBool = AtomicBool::new(false);
static MESSAGE_SENT: AtomicBool = AtomicBool::new(false);
static ACCEPT_PENDING: AtomicBool = AtomicBool::new(false);
+static NOTIFIED_READY_CHECK: AtomicBool = AtomicBool::new(false);
static TRADES_HANDLED: once_cell::sync::Lazy<tokio::sync::Mutex<std::collections::HashSet<i64>>> =
once_cell::sync::Lazy::new(|| tokio::sync::Mutex::new(std::collections::HashSet::new()));
@@ -39,6 +41,31 @@ fn should_accept_ready_check(state: &str, player_response: &str) -> bool {
pending_ready_check(state) && player_response == "None"
}
+/// A queue popping while the user looks at another window is exactly the moment
+/// a notification earns its keep; firing one over a focused app would be noise.
+fn notify_ready_check() {
+ if !league_settings().notify_ready_check {
+ return;
+ }
+ let Some(app) = APP.get() else { return };
+ let focused = app
+ .get_webview_window("main")
+ .and_then(|w| w.is_focused().ok())
+ .unwrap_or(false);
+ if focused {
+ return;
+ }
+ if let Err(e) = app
+ .notification()
+ .builder()
+ .title("OmniGet")
+ .body("League of Legends: match found")
+ .show()
+ {
+ tracing::debug!("[league] ready check notification failed: {}", e);
+ }
+}
+
async fn accept_ready_check(client: &LcuClient) {
match lcu_post_raw(client, "/lol-matchmaking/v1/ready-check/accept").await {
Ok(_) => tracing::info!("[league] ready check accepted"),
@@ -193,6 +220,11 @@ async fn handle_event(client: &LcuClient, value: &Value) {
emit("league-ready-check", data.clone());
if !pending_ready_check(state) {
ACCEPT_PENDING.store(false, Ordering::SeqCst);
+ NOTIFIED_READY_CHECK.store(false, Ordering::SeqCst);
+ } else if should_accept_ready_check(state, response)
+ && !NOTIFIED_READY_CHECK.swap(true, Ordering::SeqCst)
+ {
+ notify_ready_check();
}
if should_accept_ready_check(state, response)
&& super::AUTO_ACCEPT.load(Ordering::Relaxed)
diff --git a/src/components/league/AnalysisTab.svelte b/src/components/league/AnalysisTab.svelte
index 7c310fea..720dae86 100644
--- a/src/components/league/AnalysisTab.svelte
+++ b/src/components/league/AnalysisTab.svelte
@@ -2,6 +2,7 @@
import { invoke } from "@tauri-apps/api/core";
import { t } from "$lib/i18n";
import { CDRAGON, TAG_KEYS, type Champion, type RankedEntry, type ScoutPlayer } from "./shared";
+ import { markedPlayers, winrateSquad } from "$lib/league-scouting";
let {
analysis,
@@ -31,6 +32,9 @@
timesSeenBefore: (puuid: string) => number;
} = $props();
+ let marked = $derived(markedPlayers(scoutPlayers, notes));
+ let squadSide = $derived(winrateSquad(scoutPlayers, analysis?.premades ?? [], scoutReports));
+
let openNotes = $state<Record<string, boolean>>({});
let chatPreview = $state("");
let chatSending = $state(false);
@@ -137,6 +141,25 @@
<button class="button" onclick={onRefreshScouting} disabled={scoutLoading}>{$t("league.refresh")}</button>
</div>
<div class="scout-teams">
+ {#if marked.ally.length > 0 || marked.enemy.length > 0 || squadSide}
+ <div class="scout-notices">
+ {#if marked.ally.length > 0}
+ <p class="scout-notice">
+ {$t("league.marked_in_allies")} <strong>{marked.ally.join(", ")}</strong>
+ </p>
+ {/if}
+ {#if marked.enemy.length > 0}
+ <p class="scout-notice">
+ {$t("league.marked_in_enemies")} <strong>{marked.enemy.join(", ")}</strong>
+ </p>
+ {/if}
+ {#if squadSide}
+ <p class="scout-notice">
+ {squadSide === "enemy" ? $t("league.squad_enemy") : $t("league.squad_ally")}
+ </p>
+ {/if}
+ </div>
+ {/if}
{#each scoutGroups() as group (group.label)}
<div class="scout-team">
<h4 class="scout-team-title" class:enemy={!group.ally}>{group.label}</h4>
diff --git a/src/components/league/AutomationTab.svelte b/src/components/league/AutomationTab.svelte
index ea372d3c..d5838d27 100644
--- a/src/components/league/AutomationTab.svelte
+++ b/src/components/league/AutomationTab.svelte
@@ -36,7 +36,7 @@
}
}
- function toggleLeagueFlag(field: "auto_pick" | "auto_ban" | "auto_lock" | "auto_honor" | "auto_play_again" | "auto_reconnect") {
+ function toggleLeagueFlag(field: "auto_pick" | "auto_ban" | "auto_lock" | "auto_honor" | "auto_play_again" | "auto_reconnect" | "notify_ready_check") {
const current = (settings?.league as any)?.[field] ?? false;
updateSettings({ league: { [field]: !current } });
}
@@ -117,6 +117,16 @@
</div>
{/if}
<div class="divider"></div>
+ <div class="action-row">
+ <div class="action-col">
+ <span class="action-label">{$t("league.notify_ready")}</span>
+ <span class="action-hint">{$t("league.notify_ready_desc")}</span>
+ </div>
+ <button class="toggle" class:on={settings?.league?.notify_ready_check ?? true} onclick={() => toggleLeagueFlag("notify_ready_check")} role="switch" aria-checked={settings?.league?.notify_ready_check ?? true} aria-label={$t("league.notify_ready") as string}>
+ <span class="toggle-knob"></span>
+ </button>
+ </div>
+ <div class="divider"></div>
<div class="action-row">
<div class="action-col">
<span class="action-label">{$t("league.auto_pick")}</span>
diff --git a/src/lib/i18n/el.json b/src/lib/i18n/el.json
index 54eb357b..09dc745f 100644
--- a/src/lib/i18n/el.json
+++ b/src/lib/i18n/el.json
@@ -156,6 +156,10 @@
"scout_enemies": "Αντίπαλοι",
"scout_enemies_hidden": "Οι αντίπαλοι αποκαλύπτονται όταν ξεκινήσει ο αγώνας.",
"scout_note_placeholder": "Προσωπική σημείωση για αυτόν τον παίκτη…",
+ "marked_in_allies": "Έχεις σημειώσεις στην ομάδα σου:",
+ "marked_in_enemies": "Έχεις σημειώσεις στην αντίπαλη ομάδα:",
+ "squad_enemy": "Οι πέντε αντίπαλοι μπήκαν μαζί στην ουρά και όλα τα προφίλ είναι κρυφά.",
+ "squad_ally": "Μπήκατε και οι πέντε μαζί στην ουρά και όλα τα προφίλ είναι κρυφά.",
"scout_private": "Ιδιωτικό προφίλ",
"tag_hot_streak": "σερί νικών",
"tag_cold_streak": "σερί ηττών",
@@ -179,6 +183,8 @@
"live_title": "Ζωντανός αγώνας",
"respawn_in": "επανεμφάνιση σε",
"automation_title": "Αυτοματισμός",
+ "notify_ready": "Ειδοποίηση όταν βρεθεί παιχνίδι",
+ "notify_ready_desc": "Στέλνει ειδοποίηση συστήματος μόνο όταν το παράθυρο του OmniGet δεν είναι σε εστίαση.",
"auto_pick": "Αυτόματο pick",
"auto_pick_desc": "Επιλέγει τον πρώτο διαθέσιμο ήρωα από τη λίστα σας όταν είναι η σειρά σας.",
"auto_ban": "Αυτόματο ban",
diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json
index 4ebeb8f4..e11126b1 100644
--- a/src/lib/i18n/en.json
+++ b/src/lib/i18n/en.json
@@ -174,6 +174,10 @@
"scout_enemies": "Enemies",
"scout_enemies_hidden": "Enemies are revealed once the game starts.",
"scout_note_placeholder": "Personal note about this player…",
+ "marked_in_allies": "You have notes on your side:",
+ "marked_in_enemies": "You have notes on the enemy side:",
+ "squad_enemy": "All five enemies queued together and every profile is hidden.",
+ "squad_ally": "All five of you queued together and every profile is hidden.",
"scout_private": "Private profile",
"tag_hot_streak": "win streak",
"tag_cold_streak": "loss streak",
@@ -197,6 +201,8 @@
"live_title": "Live game",
"respawn_in": "respawns in",
"automation_title": "Automation",
+ "notify_ready": "Notify when a match is found",
+ "notify_ready_desc": "Sends a desktop notification only while the OmniGet window is not in focus.",
"auto_pick": "Auto pick",
"auto_pick_desc": "Picks the first available champion from your list when it's your turn.",
"auto_ban": "Auto ban",
diff --git a/src/lib/i18n/es.json b/src/lib/i18n/es.json
index 4db8f9db..0be8704b 100644
--- a/src/lib/i18n/es.json
+++ b/src/lib/i18n/es.json
@@ -156,6 +156,10 @@
"scout_enemies": "Enemigos",
"scout_enemies_hidden": "Los enemigos se revelan cuando empieza la partida.",
"scout_note_placeholder": "Nota personal sobre este jugador…",
+ "marked_in_allies": "Tienes notas en tu equipo:",
+ "marked_in_enemies": "Tienes notas en el equipo enemigo:",
+ "squad_enemy": "Los cinco enemigos entraron en cola juntos y todos los perfiles están ocultos.",
+ "squad_ally": "Los cinco entraron en cola juntos y todos los perfiles están ocultos.",
"scout_private": "Perfil privado",
"tag_hot_streak": "racha de victorias",
"tag_cold_streak": "racha de derrotas",
@@ -179,6 +183,8 @@
"live_title": "Partida en vivo",
"respawn_in": "reaparece en",
"automation_title": "Automatización",
+ "notify_ready": "Avisar cuando se encuentre partida",
+ "notify_ready_desc": "Envía una notificación del sistema solo cuando la ventana de OmniGet no está enfocada.",
"auto_pick": "Pick automático",
"auto_pick_desc": "Elige el primer campeón disponible de tu lista cuando sea tu turno.",
"auto_ban": "Baneo automático",
diff --git a/src/lib/i18n/fr.json b/src/lib/i18n/fr.json
index 3bee073a..65ef4726 100644
--- a/src/lib/i18n/fr.json
+++ b/src/lib/i18n/fr.json
@@ -156,6 +156,10 @@
"scout_enemies": "Ennemis",
"scout_enemies_hidden": "Les ennemis sont révélés au début de la partie.",
"scout_note_placeholder": "Note personnelle sur ce joueur…",
+ "marked_in_allies": "Vous avez des notes dans votre équipe :",
+ "marked_in_enemies": "Vous avez des notes dans l'équipe adverse :",
+ "squad_enemy": "Les cinq adversaires ont fait la queue ensemble et tous les profils sont masqués.",
+ "squad_ally": "Vous avez tous les cinq fait la queue ensemble et tous les profils sont masqués.",
"scout_private": "Profil privé",
"tag_hot_streak": "série de victoires",
"tag_cold_streak": "série de défaites",
@@ -179,6 +183,8 @@
"live_title": "Partie en direct",
"respawn_in": "réapparaît dans",
"automation_title": "Automatisation",
+ "notify_ready": "Prévenir quand une partie est trouvée",
+ "notify_ready_desc": "Envoie une notification système uniquement lorsque la fenêtre d'OmniGet n'est pas au premier plan.",
"auto_pick": "Pick automatique",
"auto_pick_desc": "Choisit le premier champion disponible de votre liste quand c'est votre tour.",
"auto_ban": "Ban automatique",
diff --git a/src/lib/i18n/it.json b/src/lib/i18n/it.json
index f979d121..ba406965 100644
--- a/src/lib/i18n/it.json
+++ b/src/lib/i18n/it.json
@@ -156,6 +156,10 @@
"scout_enemies": "Nemici",
"scout_enemies_hidden": "I nemici vengono rivelati quando inizia la partita.",
"scout_note_placeholder": "Nota personale su questo giocatore…",
+ "marked_in_allies": "Hai note nella tua squadra:",
+ "marked_in_enemies": "Hai note nella squadra nemica:",
+ "squad_enemy": "I cinque nemici sono entrati in coda insieme e tutti i profili sono nascosti.",
+ "squad_ally": "Voi cinque siete entrati in coda insieme e tutti i profili sono nascosti.",
"scout_private": "Profilo privato",
"tag_hot_streak": "serie di vittorie",
"tag_cold_streak": "serie di sconfitte",
@@ -179,6 +183,8 @@
"live_title": "Partita in corso",
"respawn_in": "rinasce tra",
"automation_title": "Automazione",
+ "notify_ready": "Avvisa quando la partita è trovata",
+ "notify_ready_desc": "Invia una notifica di sistema solo quando la finestra di OmniGet non è in primo piano.",
"auto_pick": "Pick automatico",
"auto_pick_desc": "Sceglie il primo campione disponibile della tua lista quando è il tuo turno.",
"auto_ban": "Ban automatico",
diff --git a/src/lib/i18n/ja.json b/src/lib/i18n/ja.json
index bcb90452..b9580f7f 100644
--- a/src/lib/i18n/ja.json
+++ b/src/lib/i18n/ja.json
@@ -156,6 +156,10 @@
"scout_enemies": "敵",
"scout_enemies_hidden": "敵はゲーム開始後に表示されます。",
"scout_note_placeholder": "このプレイヤーへの個人メモ…",
+ "marked_in_allies": "味方にメモがあります:",
+ "marked_in_enemies": "敵にメモがあります:",
+ "squad_enemy": "敵5人が一緒にキューへ入り、全員のプロフィールが非公開です。",
+ "squad_ally": "5人全員が一緒にキューへ入り、全員のプロフィールが非公開です。",
"scout_private": "非公開プロフィール",
"tag_hot_streak": "連勝中",
"tag_cold_streak": "連敗中",
@@ -179,6 +183,8 @@
"live_title": "進行中のゲーム",
"respawn_in": "リスポーンまで",
"automation_title": "自動化",
+ "notify_ready": "マッチが見つかったら通知",
+ "notify_ready_desc": "OmniGet のウィンドウが前面にないときだけデスクトップ通知を送ります。",
"auto_pick": "自動ピック",
"auto_pick_desc": "自分の番になるとリストから利用可能な最初のチャンピオンをピックします。",
"auto_ban": "自動バン",
diff --git a/src/lib/i18n/keys.ts b/src/lib/i18n/keys.ts
index 4a8b1a11..db002602 100644
--- a/src/lib/i18n/keys.ts
+++ b/src/lib/i18n/keys.ts
@@ -491,9 +491,13 @@ export type TranslationKeys =
| 'league.live_title'
| 'league.lobby_hint'
| 'league.lobby_title'
+ | 'league.marked_in_allies'
+ | 'league.marked_in_enemies'
| 'league.match_damage'
| 'league.match_detail_unavailable'
| 'league.nav'
+ | 'league.notify_ready'
+ | 'league.notify_ready_desc'
| 'league.objective_baron'
| 'league.objective_dragon'
| 'league.objective_inhibitor'
@@ -570,6 +574,8 @@ export type TranslationKeys =
| 'league.spectate_loading'
| 'league.spectate_not_in_game'
| 'league.spell_timer_hint'
+ | 'league.squad_ally'
+ | 'league.squad_enemy'
| 'league.start_queue'
| 'league.stat_winrate'
| 'league.stop_queue'
diff --git a/src/lib/i18n/pt.json b/src/lib/i18n/pt.json
index e425450a..86e263aa 100644
--- a/src/lib/i18n/pt.json
+++ b/src/lib/i18n/pt.json
@@ -156,6 +156,10 @@
"scout_enemies": "Inimigos",
"scout_enemies_hidden": "Os inimigos são revelados quando a partida começa.",
"scout_note_placeholder": "Anotação pessoal sobre este jogador…",
+ "marked_in_allies": "Você tem anotações no seu time:",
+ "marked_in_enemies": "Você tem anotações no time inimigo:",
+ "squad_enemy": "Os cinco inimigos entraram na fila juntos e todos os perfis estão ocultos.",
+ "squad_ally": "Vocês cinco entraram na fila juntos e todos os perfis estão ocultos.",
"scout_private": "Perfil privado",
"tag_hot_streak": "sequência de vitórias",
"tag_cold_streak": "sequência de derrotas",
@@ -179,6 +183,8 @@
"live_title": "Partida ao vivo",
"respawn_in": "renasce em",
"automation_title": "Automação",
+ "notify_ready": "Avisar quando a partida for encontrada",
+ "notify_ready_desc": "Envia uma notificação do sistema apenas quando a janela do OmniGet não está em foco.",
"auto_pick": "Pick automático",
"auto_pick_desc": "Escolhe o primeiro campeão disponível da sua lista quando for a sua vez.",
"auto_ban": "Ban automático",
diff --git a/src/lib/i18n/ru.json b/src/lib/i18n/ru.json
index 2b6cb7c8..30ad6fcf 100644
--- a/src/lib/i18n/ru.json
+++ b/src/lib/i18n/ru.json
@@ -156,6 +156,10 @@
"scout_enemies": "Противники",
"scout_enemies_hidden": "Противники раскрываются после начала игры.",
"scout_note_placeholder": "Личная заметка об этом игроке…",
+ "marked_in_allies": "У вас есть заметки о союзниках:",
+ "marked_in_enemies": "У вас есть заметки о противниках:",
+ "squad_enemy": "Все пять противников встали в очередь вместе, и все профили скрыты.",
+ "squad_ally": "Вы все пятеро встали в очередь вместе, и все профили скрыты.",
"scout_private": "Скрытый профиль",
"tag_hot_streak": "серия побед",
"tag_cold_streak": "серия поражений",
@@ -179,6 +183,8 @@
"live_title": "Текущая игра",
"respawn_in": "возродится через",
"automation_title": "Автоматизация",
+ "notify_ready": "Уведомлять о найденном матче",
+ "notify_ready_desc": "Отправляет системное уведомление, только когда окно OmniGet не в фокусе.",
"auto_pick": "Автопик",
"auto_pick_desc": "Выбирает первого доступного чемпиона из вашего списка, когда наступает ваш ход.",
"auto_ban": "Автобан",
diff --git a/src/lib/i18n/zh-TW.json b/src/lib/i18n/zh-TW.json
index e022505d..fd77a3f3 100644
--- a/src/lib/i18n/zh-TW.json
+++ b/src/lib/i18n/zh-TW.json
@@ -156,6 +156,10 @@
"scout_enemies": "敵方",
"scout_enemies_hidden": "對戰開始後才會顯示敵方玩家。",
"scout_note_placeholder": "關於該玩家的個人備註…",
+ "marked_in_allies": "你對己方有備註:",
+ "marked_in_enemies": "你對敵方有備註:",
+ "squad_enemy": "五名敵人一起排隊,且所有生涯都已隱藏。",
+ "squad_ally": "你們五人一起排隊,且所有生涯都已隱藏。",
"scout_private": "隱私資料",
"tag_hot_streak": "連勝中",
"tag_cold_streak": "連敗中",
@@ -179,6 +183,8 @@
"live_title": "進行中的對戰",
"respawn_in": "復活倒數",
"automation_title": "自動化",
+ "notify_ready": "找到對局時通知",
+ "notify_ready_desc": "僅在 OmniGet 視窗未取得焦點時發送系統通知。",
"auto_pick": "自動選角",
"auto_pick_desc": "輪到你時自動選擇清單中第一個可用的英雄。",
"auto_ban": "自動禁用",
diff --git a/src/lib/i18n/zh.json b/src/lib/i18n/zh.json
index 1d4750c7..8ca89542 100644
--- a/src/lib/i18n/zh.json
+++ b/src/lib/i18n/zh.json
@@ -156,6 +156,10 @@
"scout_enemies": "敌方",
"scout_enemies_hidden": "对局开始后才会显示敌方玩家。",
"scout_note_placeholder": "关于该玩家的个人备注…",
+ "marked_in_allies": "你对己方有备注:",
+ "marked_in_enemies": "你对敌方有备注:",
+ "squad_enemy": "五名敌人一起排队,且所有生涯都已隐藏。",
+ "squad_ally": "你们五人一起排队,且所有生涯都已隐藏。",
"scout_private": "隐私资料",
"tag_hot_streak": "连胜中",
"tag_cold_streak": "连败中",
@@ -179,6 +183,8 @@
"live_title": "进行中的对局",
"respawn_in": "复活倒计时",
"automation_title": "自动化",
+ "notify_ready": "找到对局时通知",
+ "notify_ready_desc": "仅在 OmniGet 窗口未获得焦点时发送系统通知。",
"auto_pick": "自动选英雄",
"auto_pick_desc": "轮到你时自动选择列表中第一个可用的英雄。",
"auto_ban": "自动禁用",
diff --git a/src/lib/league-scouting.test.ts b/src/lib/league-scouting.test.ts
new file mode 100644
index 00000000..570c23cd
--- /dev/null
+++ b/src/lib/league-scouting.test.ts
@@ -0,0 +1,80 @@
+import { describe, it, expect } from "vitest";
+import { markedPlayers, winrateSquad, type ScoutedPlayer } from "./league-scouting";
+
+const team = (ally: boolean, count: number, offset = 0): ScoutedPlayer[] =>
+ Array.from({ length: count }, (_, i) => ({
+ puuid: `p${offset + i}`,
+ isAlly: ally,
+ gameName: `Player${offset + i}`,
+ }));
+
+describe("markedPlayers", () => {
+ it("splits marked players by side and prefers the display name", () => {
+ const players = [...team(true, 2), ...team(false, 2, 10)];
+ const marked = markedPlayers(players, { p0: "smurf", p10: "trolled last game" });
+ expect(marked).toEqual({ ally: ["Player0"], enemy: ["Player10"] });
+ });
+
+ it("treats a blank note as no note", () => {
+ const marked = markedPlayers(team(true, 2), { p0: " ", p1: "" });
+ expect(marked).toEqual({ ally: [], enemy: [] });
+ });
+
+ it("falls back to a short puuid when the name is missing", () => {
+ const marked = markedPlayers([{ puuid: "abcdefghijkl", isAlly: false }], {
+ abcdefghijkl: "note",
+ });
+ expect(marked.enemy).toEqual(["abcdefgh"]);
+ });
+
+ it("ignores players without a puuid", () => {
+ expect(markedPlayers([{ isAlly: true, gameName: "Ghost" }], {})).toEqual({
+ ally: [],
+ enemy: [],
+ });
+ });
+});
+
+describe("winrateSquad", () => {
+ const five = team(false, 5);
+ const allPrivate = Object.fromEntries(five.map((p) => [p.puuid!, { privateProfile: true }]));
+
+ it("flags a five-stack whose profiles are all hidden", () => {
+ const premades = [{ label: "A", puuids: five.map((p) => p.puuid!) }];
+ expect(winrateSquad(five, premades, allPrivate)).toBe("enemy");
+ });
+
+ it("says nothing when one profile is visible", () => {
+ const reports = { ...allPrivate, p2: { privateProfile: false } };
+ const premades = [{ label: "A", puuids: five.map((p) => p.puuid!) }];
+ expect(winrateSquad(five, premades, reports)).toBeNull();
+ });
+
+ it("says nothing for a group smaller than five", () => {
+ const premades = [{ label: "A", puuids: ["p0", "p1"] }];
+ expect(winrateSquad(five, premades, allPrivate)).toBeNull();
+ });
+
+ it("reports the ally side when it is the user's own stack", () => {
+ const allies = team(true, 5);
+ const reports = Object.fromEntries(allies.map((p) => [p.puuid!, { privateProfile: true }]));
+ const premades = [{ label: "A", puuids: allies.map((p) => p.puuid!) }];
+ expect(winrateSquad(allies, premades, reports)).toBe("ally");
+ });
+
+ it("ignores a group that spans both teams or has unknown members", () => {
+ const mixed = [...team(true, 3), ...team(false, 2, 3)];
+ const reports = Object.fromEntries(mixed.map((p) => [p.puuid!, { privateProfile: true }]));
+ const premades = [{ puuids: mixed.map((p) => p.puuid!) }];
+ expect(winrateSquad(mixed, premades, reports)).toBeNull();
+ expect(winrateSquad([], [{ puuids: ["x", "y", "z", "w", "v"] }], {})).toBeNull();
+ });
+
+ it("handles missing or malformed premade payloads", () => {
+ expect(winrateSquad(five, [], allPrivate)).toBeNull();
+ expect(winrateSquad(five, [{}], allPrivate)).toBeNull();
+ expect(winrateSquad(five, [{ puuids: [null, "", "p0", "p1", "p2", "p3", "p4"] }], allPrivate)).toBe(
+ "enemy",
+ );
+ });
+});
diff --git a/src/lib/league-scouting.ts b/src/lib/league-scouting.ts
new file mode 100644
index 00000000..2410fac5
--- /dev/null
+++ b/src/lib/league-scouting.ts
@@ -0,0 +1,50 @@
+export type ScoutedPlayer = { puuid?: string; isAlly?: boolean; gameName?: string };
+export type PremadeGroup = { label?: string; puuids?: (string | null)[] };
+export type ScoutReport = { privateProfile?: boolean } | null | undefined;
+
+export type MarkedPlayers = { ally: string[]; enemy: string[] };
+
+/// Players the user already wrote a note about. An empty or whitespace-only note
+/// is not a mark: it is a note the user started and abandoned.
+export function markedPlayers(
+ players: readonly ScoutedPlayer[],
+ notes: Record<string, string>,
+): MarkedPlayers {
+ const marked: MarkedPlayers = { ally: [], enemy: [] };
+ for (const player of players) {
+ const puuid = player.puuid;
+ if (!puuid) continue;
+ if ((notes[puuid] ?? "").trim() === "") continue;
+ const label = player.gameName?.trim() || puuid.slice(0, 8);
+ (player.isAlly ? marked.ally : marked.enemy).push(label);
+ }
+ return marked;
+}
+
+function sideOf(players: readonly ScoutedPlayer[], puuids: readonly string[]): boolean | null {
+ const sides = new Set(
+ puuids
+ .map((puuid) => players.find((p) => p.puuid === puuid)?.isAlly)
+ .filter((side): side is boolean => typeof side === "boolean"),
+ );
+ return sides.size === 1 ? [...sides][0] : null;
+}
+
+/// A five-player group whose profiles are all hidden is the shape of a squad
+/// queueing together to farm wins. It is reported as an observation, never as an
+/// accusation: both halves have to hold, and neither is proof on its own.
+export function winrateSquad(
+ players: readonly ScoutedPlayer[],
+ premades: readonly PremadeGroup[],
+ reports: Record<string, ScoutReport>,
+): "ally" | "enemy" | null {
+ for (const group of premades) {
+ const puuids = (group.puuids ?? []).filter((p): p is string => typeof p === "string" && p !== "");
+ if (puuids.length < 5) continue;
+ const side = sideOf(players, puuids);
+ if (side === null) continue;
+ const allHidden = puuids.every((puuid) => reports[puuid]?.privateProfile === true);
+ if (allHidden) return side ? "ally" : "enemy";
+ }
+ return null;
+}
diff --git a/src/lib/stores/settings-store.svelte.ts b/src/lib/stores/settings-store.svelte.ts
index 3682fad7..6697f3fc 100644
--- a/src/lib/stores/settings-store.svelte.ts
+++ b/src/lib/stores/settings-store.svelte.ts
@@ -1,3 +1,274 @@
+import { invoke } from "@tauri-apps/api/core";
+
+export type AppSettings = {
+ schema_version: number;
+ appearance: {
+ theme: string;
+ language: string;
+ };
+ download: {
+ default_output_dir: string;
+ always_ask_path: boolean;
+ video_quality: string;
+ skip_existing: boolean;
+ download_attachments: boolean;
+ download_descriptions: boolean;
+ embed_metadata: boolean;
+ embed_thumbnail: boolean;
+ clipboard_detection: boolean;
+ auto_download_on_paste: boolean;
+ filename_template: string;
+ organize_by_platform: boolean;
+ download_subtitles: boolean;
+ include_auto_subtitles: boolean;
+ caption_locale: string;
+ keep_vtt: boolean;
+ continuous_lecture_numbers: boolean;
+ translate_metadata: boolean;
+ youtube_sponsorblock: boolean;
+ sponsorblock_mode: string;
+ sponsorblock_categories: string[];
+ split_by_chapters: boolean;
+ live_from_start: boolean;
+ speed_limit: string;
+ hotkey_enabled: boolean;
+ hotkey_binding: string;
+ clip_hotkey_enabled?: boolean;
+ clip_hotkey_binding?: string;
+ music_hotkey_enabled: boolean;
+ music_hotkey_binding: string;
+ music_audio_format: string;
+ copy_to_clipboard_on_hotkey: boolean;
+ extra_ytdlp_flags?: string[];
+ cookie_file: string;
+ always_use_managed_cookies: boolean;
+ bilibili_danmaku_enabled: boolean;
+ bilibili_danmaku_format: string;
+ bilibili_container: string;
+ bilibili_nfo_enabled: boolean;
+ bilibili_cover_sidecar: boolean;
+ bilibili_cover_format: string;
+ bilibili_naming_video: string;
+ bilibili_naming_multi_part: string;
+ bilibili_naming_bangumi: string;
+ bilibili_naming_cheese: string;
+ bilibili_naming_collection: string;
+ bilibili_cdn_hosts: string;
+ bilibili_cdn_prefer_alternatives: boolean;
+ bilibili_preferred_qn: number;
+ bilibili_preferred_codec: number;
+ bilibili_preferred_audio_qn: number;
+ };
+ proxy?: {
+ enabled?: boolean;
+ proxy_type?: string;
+ host?: string;
+ port?: number;
+ username?: string;
+ password?: string;
+ };
+ advanced: {
+ max_concurrent_segments: number;
+ max_retries: number;
+ max_concurrent_downloads: number;
+ concurrent_fragments: number;
+ stagger_delay_ms: number;
+ torrent_listen_port: number;
+ torrent_auto_trackers: boolean;
+ torrent_upnp: boolean;
+ prevent_sleep: boolean;
+ cookies_from_browser: string;
+ twitter_manual_cookie: string;
+ user_agent: string;
+ };
+ telegram: {
+ concurrent_downloads: number;
+ fix_file_extensions: boolean;
+ };
+ rpc: {
+ enabled: boolean;
+ app_id: string;
+ large_image_key: string;
+ };
+ league?: {
+ enabled?: boolean;
+ auto_accept?: boolean;
+ auto_accept_delay?: number;
+ notify_ready_check?: boolean;
+ auto_pick?: boolean;
+ auto_ban?: boolean;
+ auto_lock?: boolean;
+ auto_runes?: boolean;
+ auto_honor?: boolean;
+ auto_play_again?: boolean;
+ auto_reconnect?: boolean;
+ auto_trade?: string;
+ auto_message?: string;
+ pick_champions?: number[];
+ ban_champions?: number[];
+ };
+ onboarding_completed: boolean;
+ start_with_system: boolean;
+ start_minimized: boolean;
+ legal_acknowledged?: boolean;
+ last_download_options?: {
+ mode?: "auto" | "audio" | "mute" | null;
+ quality?: string | null;
+ };
+ accessibility?: {
+ reduce_motion?: boolean;
+ reduce_transparency?: boolean;
+ disable_haptics?: boolean;
+ };
+ typography?: TypographySettings;
+};
+
+export type TypographySettings = {
+ font_display: string;
+ font_body: string;
+ font_mono: string;
+ line_height_base: number;
+ spacing_scale: number;
+ preset_name: string | null;
+};
+
+const TYPOGRAPHY_DEFAULTS: TypographySettings = {
+ font_display: "System",
+ font_body: "System",
+ font_mono: "IBM Plex Mono",
+ line_height_base: 1.55,
+ spacing_scale: 1.0,
+ preset_name: "system",
+};
+
+const SPACING_BASE_PX: Record<string, number> = {
+ "--space-1": 4,
+ "--space-2": 8,
+ "--space-3": 12,
+ "--space-4": 16,
+ "--space-5": 24,
+ "--space-6": 32,
+ "--space-7": 48,
+ "--space-8": 64,
+ "--space-9": 96,
+};
+
+function fontStack(fontDisplay: string): string {
+ const display = fontDisplay.trim();
+ if (display === "System") {
+ return `-apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif`;
+ }
+ if (display === "Bricolage Grotesque Variable") {
+ return `'Bricolage Grotesque Variable', 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif`;
+ }
+ if (display === "Inter") {
+ return `'Inter', 'DM Sans', ui-sans-serif, system-ui, sans-serif`;
+ }
+ if (display === "DM Sans") {
+ return `'DM Sans', 'Inter', ui-sans-serif, system-ui, sans-serif`;
+ }
+ if (display === "IBM Plex Mono") {
+ return `'IBM Plex Mono', ui-monospace, monospace`;
+ }
+ if (display === "system-ui") {
+ return `system-ui, -apple-system, BlinkMacSystemFont, sans-serif`;
+ }
+ return `'${display}', ui-sans-serif, system-ui, sans-serif`;
+}
+
+function bodyFontStack(fontBody: string): string {
+ const body = fontBody.trim();
+ if (body === "System") {
+ return `-apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif`;
+ }
+ if (body === "Inter") {
+ return `'Inter', 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif`;
+ }
+ if (body === "DM Sans") {
+ return `'DM Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif`;
+ }
+ if (body === "Bricolage Grotesque Variable") {
+ return `'Bricolage Grotesque Variable', 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif`;
+ }
+ if (body === "IBM Plex Mono") {
+ return `'IBM Plex Mono', ui-monospace, monospace`;
+ }
+ if (body === "system-ui") {
+ return `system-ui, -apple-system, BlinkMacSystemFont, sans-serif`;
+ }
+ return `'${body}', ui-sans-serif, system-ui, sans-serif`;
+}
+
+function monoFontStack(fontMono: string): string {
+ const mono = fontMono.trim();
+ if (mono === "IBM Plex Mono") {
+ return `'IBM Plex Mono', 'DejaVu Sans Mono', 'Liberation Mono', 'Courier New', monospace`;
+ }
+ return `'${mono}', ui-monospace, 'Courier New', monospace`;
+}
+
+function applyTypography(typo: TypographySettings | undefined) {
+ if (typeof document === "undefined") return;
+ const t = typo ?? TYPOGRAPHY_DEFAULTS;
+ const root = document.documentElement.style;
+ root.setProperty("--font-display", fontStack(t.font_display));
+ root.setProperty("--font-body", bodyFontStack(t.font_body));
+ root.setProperty("--font-mono", monoFontStack(t.font_mono));
+ root.setProperty("--leading-base", String(t.line_height_base));
+ const scale = typeof t.spacing_scale === "number" ? t.spacing_scale : 1.0;
+ if (Math.abs(scale - 1.0) > 0.001) {
+ for (const [key, base] of Object.entries(SPACING_BASE_PX)) {
+ root.setProperty(key, `${(base * scale).toFixed(2)}px`);
+ }
+ } else {
+ for (const key of Object.keys(SPACING_BASE_PX)) {
+ root.removeProperty(key);
+ }
+ }
+}
+
+let settings = $state<AppSettings | null>(null);
+
+function applyTheme(theme: string) {
+ if (typeof document === "undefined") return;
+
+ if (theme === "system") {
+ const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
+ document.documentElement.setAttribute("data-theme", prefersDark ? "dark" : "light");
+ } else {
+ document.documentElement.setAttribute("data-theme", theme);
+ }
+}
+
+export function getSettings(): AppSettings | null {
+ return settings;
+}
+
+export async function loadSettings(): Promise<AppSettings> {
+ const result = await invoke<AppSettings>("get_settings");
+ settings = result;
+ applyTheme(result.appearance.theme);
+ applyTypography(result.typography);
+ return result;
+}
+
+export async function updateSettings(partial: Record<string, unknown>): Promise<AppSettings> {
+ const result = await invoke<AppSettings>("update_settings", {
+ partial: JSON.stringify(partial),
+ });
+ settings = result;
+ applyTheme(result.appearance.theme);
+ applyTypography(result.typography);
+ return result;
+}
+
+export async function resetSettings(): Promise<AppSettings> {
+ const result = await invoke<AppSettings>("reset_settings");
+ settings = result;
+ applyTheme(result.appearance.theme);
+ applyTypography(result.typography);
+ return result;
+}
import { invoke } from "@tauri-apps/api/core";
export type AppSettings = {
diff --git a/src/routes/league/+page.svelte b/src/routes/league/+page.svelte
index a8570c2b..2365ab84 100644
--- a/src/routes/league/+page.svelte
+++ b/src/routes/league/+page.svelte
@@ -831,6 +831,23 @@
color: var(--gray);
}
+ .league-page :global(.scout-notices) {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ margin-bottom: 10px;
+ padding: 8px 10px;
+ border: 1px solid var(--border);
+ border-radius: var(--border-radius);
+ background: var(--surface-hover);
+ }
+
+ .league-page :global(.scout-notice) {
+ margin: 0;
+ font-size: 12.5px;
+ color: var(--text-secondary);
+ }
+
.league-page :global(.queue-filter) {
display: flex;
gap: 6px;