Compare commits
4 Commits
72000b362d
...
8e0f90f449
| Author | SHA1 | Date | |
|---|---|---|---|
| 8e0f90f449 | |||
| 91fcaa9b9e | |||
| 0bbb327b29 | |||
| 276732d2a9 |
229
src/App.tsx
229
src/App.tsx
@@ -12,13 +12,17 @@ import { useToast } from "@/ui/toast";
|
|||||||
import { useRenderer } from "@opentui/solid";
|
import { useRenderer } from "@opentui/solid";
|
||||||
import type { AuthScreen } from "@/types/auth";
|
import type { AuthScreen } from "@/types/auth";
|
||||||
import type { Episode } from "@/types/episode";
|
import type { Episode } from "@/types/episode";
|
||||||
import { DIRECTION, LayerGraph, TABS } from "./utils/navigation";
|
import { DIRECTION, LayerGraph, TABS, LayerDepths } from "./utils/navigation";
|
||||||
import { useTheme } from "./context/ThemeContext";
|
import { useTheme, ThemeProvider } from "./context/ThemeContext";
|
||||||
|
import { KeybindProvider, useKeybinds } from "./context/KeybindContext";
|
||||||
|
import { useAudioNavStore, AudioSource } from "./stores/audio-nav";
|
||||||
|
|
||||||
const DEBUG = import.meta.env.DEBUG;
|
const DEBUG = import.meta.env.DEBUG;
|
||||||
|
|
||||||
export interface PageProps {
|
export interface PageProps {
|
||||||
depth: Accessor<number>;
|
depth: Accessor<number>;
|
||||||
|
focusedIndex?: Accessor<number> | number;
|
||||||
|
focusedIndexValue?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function App() {
|
export function App() {
|
||||||
@@ -28,12 +32,16 @@ export function App() {
|
|||||||
const [showAuthPanel, setShowAuthPanel] = createSignal(false);
|
const [showAuthPanel, setShowAuthPanel] = createSignal(false);
|
||||||
const [inputFocused, setInputFocused] = createSignal(false);
|
const [inputFocused, setInputFocused] = createSignal(false);
|
||||||
const [layerDepth, setLayerDepth] = createSignal(0);
|
const [layerDepth, setLayerDepth] = createSignal(0);
|
||||||
|
const [focusedIndex, setFocusedIndex] = createSignal(0);
|
||||||
|
|
||||||
const auth = useAuthStore();
|
const auth = useAuthStore();
|
||||||
const feedStore = useFeedStore();
|
const feedStore = useFeedStore();
|
||||||
const audio = useAudio();
|
const audio = useAudio();
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const renderer = useRenderer();
|
const renderer = useRenderer();
|
||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
|
const keybind = useKeybinds();
|
||||||
|
const audioNav = useAudioNavStore();
|
||||||
|
|
||||||
useMultimediaKeys({
|
useMultimediaKeys({
|
||||||
playerFocused: () => activeTab() === TABS.PLAYER && layerDepth() > 0,
|
playerFocused: () => activeTab() === TABS.PLAYER && layerDepth() > 0,
|
||||||
@@ -45,6 +53,7 @@ export function App() {
|
|||||||
audio.play(episode);
|
audio.play(episode);
|
||||||
setActiveTab(TABS.PLAYER);
|
setActiveTab(TABS.PLAYER);
|
||||||
setLayerDepth(1);
|
setLayerDepth(1);
|
||||||
|
audioNav.setSource(AudioSource.FEED);
|
||||||
};
|
};
|
||||||
|
|
||||||
useSelectionHandler((selection: any) => {
|
useSelectionHandler((selection: any) => {
|
||||||
@@ -64,64 +73,172 @@ export function App() {
|
|||||||
|
|
||||||
useKeyboard(
|
useKeyboard(
|
||||||
(keyEvent) => {
|
(keyEvent) => {
|
||||||
//handle intra layer navigation
|
const isUp = keybind.match("up", keyEvent);
|
||||||
if (keyEvent.name == "up" || keyEvent.name) {
|
const isDown = keybind.match("down", keyEvent);
|
||||||
|
const isLeft = keybind.match("left", keyEvent);
|
||||||
|
const isRight = keybind.match("right", keyEvent);
|
||||||
|
const isCycle = keybind.match("cycle", keyEvent);
|
||||||
|
const isDive = keybind.match("dive", keyEvent);
|
||||||
|
const isOut = keybind.match("out", keyEvent);
|
||||||
|
const isToggle = keybind.match("audio-toggle", keyEvent);
|
||||||
|
const isNext = keybind.match("audio-next", keyEvent);
|
||||||
|
const isPrev = keybind.match("audio-prev", keyEvent);
|
||||||
|
const isSeekForward = keybind.match("audio-seek-forward", keyEvent);
|
||||||
|
const isSeekBackward = keybind.match("audio-seek-backward", keyEvent);
|
||||||
|
const isQuit = keybind.match("quit", keyEvent);
|
||||||
|
|
||||||
|
if (DEBUG) {
|
||||||
|
console.log("KeyEvent:", keyEvent);
|
||||||
|
console.log("Keybinds loaded:", {
|
||||||
|
up: keybind.keybinds.up,
|
||||||
|
down: keybind.keybinds.down,
|
||||||
|
left: keybind.keybinds.left,
|
||||||
|
right: keybind.keybinds.right,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isUp || isDown) {
|
||||||
|
const currentDepth = activeDepth();
|
||||||
|
const maxDepth = LayerDepths[activeTab()];
|
||||||
|
|
||||||
|
console.log("Navigation:", { isUp, isDown, currentDepth, maxDepth });
|
||||||
|
|
||||||
|
// Navigate within current depth layer
|
||||||
|
if (currentDepth < maxDepth) {
|
||||||
|
const newIndex = isUp ? focusedIndex() - 1 : focusedIndex() + 1;
|
||||||
|
setFocusedIndex(Math.max(0, Math.min(newIndex, maxDepth)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Horizontal movement - move within current layer
|
||||||
|
if (isLeft || isRight) {
|
||||||
|
const currentDepth = activeDepth();
|
||||||
|
const maxDepth = LayerDepths[activeTab()];
|
||||||
|
|
||||||
|
if (currentDepth < maxDepth) {
|
||||||
|
const newIndex = isLeft ? focusedIndex() - 1 : focusedIndex() + 1;
|
||||||
|
setFocusedIndex(Math.max(0, Math.min(newIndex, maxDepth)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cycle through current depth
|
||||||
|
if (isCycle) {
|
||||||
|
const currentDepth = activeDepth();
|
||||||
|
const maxDepth = LayerDepths[activeTab()];
|
||||||
|
|
||||||
|
if (currentDepth < maxDepth) {
|
||||||
|
const newIndex = (focusedIndex() + 1) % (maxDepth + 1);
|
||||||
|
setFocusedIndex(newIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Increase depth
|
||||||
|
if (isDive) {
|
||||||
|
const currentDepth = activeDepth();
|
||||||
|
const maxDepth = LayerDepths[activeTab()];
|
||||||
|
|
||||||
|
if (currentDepth < maxDepth) {
|
||||||
|
setActiveDepth(currentDepth + 1);
|
||||||
|
setFocusedIndex(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decrease depth
|
||||||
|
if (isOut) {
|
||||||
|
const currentDepth = activeDepth();
|
||||||
|
|
||||||
|
if (currentDepth > 0) {
|
||||||
|
setActiveDepth(currentDepth - 1);
|
||||||
|
setFocusedIndex(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isToggle) {
|
||||||
|
audio.togglePlayback();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isNext) {
|
||||||
|
audio.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isPrev) {
|
||||||
|
audio.prev();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSeekForward) {
|
||||||
|
audio.seekRelative(15);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSeekBackward) {
|
||||||
|
audio.seekRelative(-15);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Quit application
|
||||||
|
if (isQuit) {
|
||||||
|
process.exit(0);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ release: false }, // Not strictly necessary
|
{ release: false },
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ErrorBoundary
|
<KeybindProvider>
|
||||||
fallback={(err) => (
|
<ThemeProvider mode="dark">
|
||||||
<box border padding={2} borderColor={theme.error}>
|
<ErrorBoundary
|
||||||
<text fg={theme.error}>
|
fallback={(err) => (
|
||||||
Error: {err?.message ?? String(err)}
|
<box border padding={2} borderColor={theme.error}>
|
||||||
{"\n"}
|
<text fg={theme.error}>
|
||||||
Press a number key (1-6) to switch tabs.
|
Error: {err?.message ?? String(err)}
|
||||||
</text>
|
{"\n"}
|
||||||
</box>
|
Press a number key (1-6) to switch tabs.
|
||||||
)}
|
</text>
|
||||||
>
|
</box>
|
||||||
{DEBUG && (
|
)}
|
||||||
<box flexDirection="row" width="100%" height={1}>
|
>
|
||||||
<text fg={theme.primary}>█</text>
|
{DEBUG && (
|
||||||
<text fg={theme.secondary}>█</text>
|
<box flexDirection="row" width="100%" height={1}>
|
||||||
<text fg={theme.accent}>█</text>
|
<text fg={theme.primary}>█</text>
|
||||||
<text fg={theme.error}>█</text>
|
<text fg={theme.secondary}>█</text>
|
||||||
<text fg={theme.warning}>█</text>
|
<text fg={theme.accent}>█</text>
|
||||||
<text fg={theme.success}>█</text>
|
<text fg={theme.error}>█</text>
|
||||||
<text fg={theme.info}>█</text>
|
<text fg={theme.warning}>█</text>
|
||||||
<text fg={theme.text}>█</text>
|
<text fg={theme.success}>█</text>
|
||||||
<text fg={theme.textMuted}>█</text>
|
<text fg={theme.info}>█</text>
|
||||||
<text fg={theme.surface}>█</text>
|
<text fg={theme.text}>█</text>
|
||||||
<text fg={theme.background}>█</text>
|
<text fg={theme.textMuted}>█</text>
|
||||||
<text fg={theme.border}>█</text>
|
<text fg={theme.surface}>█</text>
|
||||||
<text fg={theme.borderActive}>█</text>
|
<text fg={theme.background}>█</text>
|
||||||
<text fg={theme.diffAdded}>█</text>
|
<text fg={theme.border}>█</text>
|
||||||
<text fg={theme.diffRemoved}>█</text>
|
<text fg={theme.borderActive}>█</text>
|
||||||
<text fg={theme.diffContext}>█</text>
|
<text fg={theme.diffAdded}>█</text>
|
||||||
<text fg={theme.markdownText}>█</text>
|
<text fg={theme.diffRemoved}>█</text>
|
||||||
<text fg={theme.markdownHeading}>█</text>
|
<text fg={theme.diffContext}>█</text>
|
||||||
<text fg={theme.markdownLink}>█</text>
|
<text fg={theme.markdownText}>█</text>
|
||||||
<text fg={theme.markdownCode}>█</text>
|
<text fg={theme.markdownHeading}>█</text>
|
||||||
<text fg={theme.syntaxKeyword}>█</text>
|
<text fg={theme.markdownLink}>█</text>
|
||||||
<text fg={theme.syntaxString}>█</text>
|
<text fg={theme.markdownCode}>█</text>
|
||||||
<text fg={theme.syntaxNumber}>█</text>
|
<text fg={theme.syntaxKeyword}>█</text>
|
||||||
<text fg={theme.syntaxFunction}>█</text>
|
<text fg={theme.syntaxString}>█</text>
|
||||||
</box>
|
<text fg={theme.syntaxNumber}>█</text>
|
||||||
)}
|
<text fg={theme.syntaxFunction}>█</text>
|
||||||
<box flexDirection="row" width="100%" height={1} />
|
</box>
|
||||||
<box
|
)}
|
||||||
flexDirection="row"
|
<box flexDirection="row" width="100%" height={1} />
|
||||||
width="100%"
|
<box
|
||||||
height="100%"
|
flexDirection="row"
|
||||||
backgroundColor={theme.surface}
|
width="100%"
|
||||||
>
|
height="100%"
|
||||||
<TabNavigation activeTab={activeTab()} onTabSelect={setActiveTab} />
|
backgroundColor={theme.surface}
|
||||||
{LayerGraph[activeTab()]({ depth: activeDepth })}
|
>
|
||||||
{/**TODO: Contextual controls based on tab/depth**/}
|
<TabNavigation activeTab={activeTab()} onTabSelect={setActiveTab} />
|
||||||
</box>
|
{LayerGraph[activeTab()]({
|
||||||
</ErrorBoundary>
|
depth: activeDepth,
|
||||||
|
focusedIndex: focusedIndex(),
|
||||||
|
})}
|
||||||
|
{/** TODO: Contextual controls based on tab/depth**/}
|
||||||
|
</box>
|
||||||
|
</ErrorBoundary>
|
||||||
|
</ThemeProvider>
|
||||||
|
</KeybindProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +1,74 @@
|
|||||||
import { useTheme } from "@/context/ThemeContext";
|
import { useTheme } from "@/context/ThemeContext";
|
||||||
import type { JSXElement } from "solid-js";
|
import { children as solidChildren } from "solid-js";
|
||||||
|
import type { ParentComponent } from "solid-js";
|
||||||
import type { BoxOptions, TextOptions } from "@opentui/core";
|
import type { BoxOptions, TextOptions } from "@opentui/core";
|
||||||
|
|
||||||
export function SelectableBox({
|
export const SelectableBox: ParentComponent<
|
||||||
selected,
|
{
|
||||||
children,
|
selected: () => boolean;
|
||||||
...props
|
} & BoxOptions
|
||||||
}: { selected: () => boolean; children: JSXElement } & BoxOptions) {
|
> = (props) => {
|
||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
|
|
||||||
|
const child = solidChildren(() => props.children);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<box
|
<box
|
||||||
border={!!props.border}
|
border={!!props.border}
|
||||||
borderColor={selected() ? theme.surface : theme.border}
|
borderColor={props.selected() ? theme.surface : theme.border}
|
||||||
backgroundColor={selected() ? theme.primary : theme.surface}
|
backgroundColor={props.selected() ? theme.primary : theme.surface}
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
{children}
|
{child()}
|
||||||
</box>
|
</box>
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ColorSet {
|
||||||
|
PRIMARY,
|
||||||
|
SECONDARY,
|
||||||
|
TERTIARY,
|
||||||
|
DEFAULT,
|
||||||
|
}
|
||||||
|
function getTextColor(set: ColorSet, selected: () => boolean) {
|
||||||
|
const { theme } = useTheme();
|
||||||
|
switch (set) {
|
||||||
|
case ColorSet.PRIMARY:
|
||||||
|
return selected() ? theme.textSelectedPrimary : theme.textPrimary;
|
||||||
|
case ColorSet.SECONDARY:
|
||||||
|
return selected() ? theme.textSelectedSecondary : theme.textSecondary;
|
||||||
|
case ColorSet.TERTIARY:
|
||||||
|
return selected() ? theme.textSelectedTertiary : theme.textTertiary;
|
||||||
|
default:
|
||||||
|
return theme.textPrimary;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SelectableText({
|
export const SelectableText: ParentComponent<
|
||||||
selected,
|
{
|
||||||
children,
|
selected: () => boolean;
|
||||||
...props
|
primary?: boolean;
|
||||||
}: {
|
secondary?: boolean;
|
||||||
selected: () => boolean;
|
tertiary?: boolean;
|
||||||
children: JSXElement;
|
} & TextOptions
|
||||||
} & TextOptions) {
|
> = (props) => {
|
||||||
const { theme } = useTheme();
|
const child = solidChildren(() => props.children);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<text fg={selected() ? theme.surface : theme.text} {...props}>
|
<text
|
||||||
{children}
|
fg={getTextColor(
|
||||||
|
props.primary
|
||||||
|
? ColorSet.PRIMARY
|
||||||
|
: props.secondary
|
||||||
|
? ColorSet.SECONDARY
|
||||||
|
: props.tertiary
|
||||||
|
? ColorSet.TERTIARY
|
||||||
|
: ColorSet.DEFAULT,
|
||||||
|
props.selected,
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{child()}
|
||||||
</text>
|
</text>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -30,18 +30,19 @@ export function TabNavigation(props: TabNavigationProps) {
|
|||||||
>
|
>
|
||||||
<For each={tabs}>
|
<For each={tabs}>
|
||||||
{(tab) => (
|
{(tab) => (
|
||||||
<SelectableBox
|
<SelectableBox
|
||||||
border
|
border
|
||||||
selected={() => tab.id == props.activeTab}
|
selected={() => tab.id == props.activeTab}
|
||||||
onMouseDown={() => props.onTabSelect(tab.id)}
|
onMouseDown={() => props.onTabSelect(tab.id)}
|
||||||
>
|
>
|
||||||
<SelectableText
|
<SelectableText
|
||||||
selected={() => tab.id == props.activeTab}
|
selected={() => tab.id == props.activeTab}
|
||||||
alignSelf="center"
|
primary
|
||||||
>
|
alignSelf="center"
|
||||||
{tab.label}
|
>
|
||||||
</SelectableText>
|
{tab.label}
|
||||||
</SelectableBox>
|
</SelectableText>
|
||||||
|
</SelectableBox>
|
||||||
)}
|
)}
|
||||||
</For>
|
</For>
|
||||||
</box>
|
</box>
|
||||||
|
|||||||
@@ -14,4 +14,6 @@
|
|||||||
"audio-play": [],
|
"audio-play": [],
|
||||||
"audio-next": ["<leader>n"],
|
"audio-next": ["<leader>n"],
|
||||||
"audio-prev": ["<leader>l"],
|
"audio-prev": ["<leader>l"],
|
||||||
|
"audio-seek-forward": ["<leader>sf"],
|
||||||
|
"audio-seek-backward": ["<leader>sb"],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ import {
|
|||||||
} from "../utils/keybinds-persistence";
|
} from "../utils/keybinds-persistence";
|
||||||
import { createStore } from "solid-js/store";
|
import { createStore } from "solid-js/store";
|
||||||
|
|
||||||
// ── Type Definitions ────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
export type KeybindsResolved = {
|
export type KeybindsResolved = {
|
||||||
up: string[];
|
up: string[];
|
||||||
down: string[];
|
down: string[];
|
||||||
@@ -25,9 +23,27 @@ export type KeybindsResolved = {
|
|||||||
"audio-play": string[];
|
"audio-play": string[];
|
||||||
"audio-next": string[];
|
"audio-next": string[];
|
||||||
"audio-prev": string[];
|
"audio-prev": string[];
|
||||||
|
"audio-seek-forward": string[];
|
||||||
|
"audio-seek-backward": string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
// ── Context Implementation ────────────────────────────────────────────────────────────
|
export enum KeybindAction {
|
||||||
|
UP,
|
||||||
|
DOWN,
|
||||||
|
LEFT,
|
||||||
|
RIGHT,
|
||||||
|
CYCLE,
|
||||||
|
DIVE,
|
||||||
|
OUT,
|
||||||
|
QUIT,
|
||||||
|
AUDIO_TOGGLE,
|
||||||
|
AUDIO_PAUSE,
|
||||||
|
AUDIO_PLAY,
|
||||||
|
AUDIO_NEXT,
|
||||||
|
AUDIO_PREV,
|
||||||
|
AUDIO_SEEK_F,
|
||||||
|
AUDIO_SEEK_B,
|
||||||
|
}
|
||||||
|
|
||||||
export const { use: useKeybinds, provider: KeybindProvider } =
|
export const { use: useKeybinds, provider: KeybindProvider } =
|
||||||
createSimpleContext({
|
createSimpleContext({
|
||||||
@@ -49,7 +65,9 @@ export const { use: useKeybinds, provider: KeybindProvider } =
|
|||||||
"audio-play": [],
|
"audio-play": [],
|
||||||
"audio-next": [],
|
"audio-next": [],
|
||||||
"audio-prev": [],
|
"audio-prev": [],
|
||||||
});
|
"audio-seek-forward": [],
|
||||||
|
"audio-seek-backward": [],
|
||||||
|
} as KeybindsResolved);
|
||||||
const [ready, setReady] = createSignal(false);
|
const [ready, setReady] = createSignal(false);
|
||||||
|
|
||||||
async function load() {
|
async function load() {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import {
|
|||||||
type TerminalColors,
|
type TerminalColors,
|
||||||
} from "@opentui/core";
|
} from "@opentui/core";
|
||||||
|
|
||||||
type ThemeResolved = {
|
export type ThemeResolved = {
|
||||||
primary: RGBA;
|
primary: RGBA;
|
||||||
secondary: RGBA;
|
secondary: RGBA;
|
||||||
accent: RGBA;
|
accent: RGBA;
|
||||||
@@ -32,7 +32,13 @@ type ThemeResolved = {
|
|||||||
info: RGBA;
|
info: RGBA;
|
||||||
text: RGBA;
|
text: RGBA;
|
||||||
textMuted: RGBA;
|
textMuted: RGBA;
|
||||||
selectedListItemText: RGBA;
|
textPrimary: RGBA;
|
||||||
|
textSecondary: RGBA;
|
||||||
|
textTertiary: RGBA;
|
||||||
|
textSelectedPrimary: RGBA;
|
||||||
|
textSelectedSecondary: RGBA;
|
||||||
|
textSelectedTertiary: RGBA;
|
||||||
|
|
||||||
background: RGBA;
|
background: RGBA;
|
||||||
backgroundPanel: RGBA;
|
backgroundPanel: RGBA;
|
||||||
backgroundElement: RGBA;
|
backgroundElement: RGBA;
|
||||||
@@ -77,6 +83,7 @@ type ThemeResolved = {
|
|||||||
syntaxPunctuation: RGBA;
|
syntaxPunctuation: RGBA;
|
||||||
muted?: RGBA;
|
muted?: RGBA;
|
||||||
surface?: RGBA;
|
surface?: RGBA;
|
||||||
|
selectedListItemText?: RGBA;
|
||||||
layerBackgrounds?: {
|
layerBackgrounds?: {
|
||||||
layer0: RGBA;
|
layer0: RGBA;
|
||||||
layer1: RGBA;
|
layer1: RGBA;
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ import { useAppStore } from "../stores/app"
|
|||||||
import { useProgressStore } from "../stores/progress"
|
import { useProgressStore } from "../stores/progress"
|
||||||
import { useMediaRegistry } from "../utils/media-registry"
|
import { useMediaRegistry } from "../utils/media-registry"
|
||||||
import type { Episode } from "../types/episode"
|
import type { Episode } from "../types/episode"
|
||||||
|
import type { Feed } from "../types/feed"
|
||||||
|
import { useAudioNavStore, AudioSource } from "../stores/audio-nav"
|
||||||
|
import { useFeedStore } from "../stores/feed"
|
||||||
|
|
||||||
export interface AudioControls {
|
export interface AudioControls {
|
||||||
// Signals (reactive getters)
|
// Signals (reactive getters)
|
||||||
@@ -49,6 +52,8 @@ export interface AudioControls {
|
|||||||
setVolume: (volume: number) => Promise<void>
|
setVolume: (volume: number) => Promise<void>
|
||||||
setSpeed: (speed: number) => Promise<void>
|
setSpeed: (speed: number) => Promise<void>
|
||||||
switchBackend: (name: BackendName) => Promise<void>
|
switchBackend: (name: BackendName) => Promise<void>
|
||||||
|
prev: () => Promise<void>
|
||||||
|
next: () => Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
// Singleton state — shared across all components that call useAudio()
|
// Singleton state — shared across all components that call useAudio()
|
||||||
@@ -401,6 +406,76 @@ export function useAudio(): AudioControls {
|
|||||||
await doSetSpeed(next)
|
await doSetSpeed(next)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const audioNav = useAudioNavStore();
|
||||||
|
const feedStore = useFeedStore();
|
||||||
|
|
||||||
|
async function prev(): Promise<void> {
|
||||||
|
const current = currentEpisode();
|
||||||
|
if (!current) return;
|
||||||
|
|
||||||
|
const currentPos = position();
|
||||||
|
const currentDur = duration();
|
||||||
|
|
||||||
|
const NAV_START_THRESHOLD = 30;
|
||||||
|
|
||||||
|
if (currentPos > NAV_START_THRESHOLD && currentDur > 0) {
|
||||||
|
await seek(NAV_START_THRESHOLD);
|
||||||
|
} else {
|
||||||
|
const source = audioNav.getSource();
|
||||||
|
let episodes: Array<{ episode: Episode; feed: Feed }> = [];
|
||||||
|
|
||||||
|
if (source === AudioSource.FEED) {
|
||||||
|
episodes = feedStore.getAllEpisodesChronological();
|
||||||
|
} else if (source === AudioSource.MY_SHOWS) {
|
||||||
|
const podcastId = audioNav.getPodcastId();
|
||||||
|
if (!podcastId) return;
|
||||||
|
|
||||||
|
const feed = feedStore.getFilteredFeeds().find(f => f.podcast.id === podcastId);
|
||||||
|
if (!feed) return;
|
||||||
|
|
||||||
|
episodes = feed.episodes.map(ep => ({ episode: ep, feed }));
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentIndex = audioNav.getCurrentIndex();
|
||||||
|
const newIndex = Math.max(0, currentIndex - 1);
|
||||||
|
|
||||||
|
if (newIndex < episodes.length && episodes[newIndex]) {
|
||||||
|
const { episode } = episodes[newIndex];
|
||||||
|
await play(episode);
|
||||||
|
audioNav.prev(newIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function next(): Promise<void> {
|
||||||
|
const current = currentEpisode();
|
||||||
|
if (!current) return;
|
||||||
|
|
||||||
|
const source = audioNav.getSource();
|
||||||
|
let episodes: Array<{ episode: Episode; feed: Feed }> = [];
|
||||||
|
|
||||||
|
if (source === AudioSource.FEED) {
|
||||||
|
episodes = feedStore.getAllEpisodesChronological();
|
||||||
|
} else if (source === AudioSource.MY_SHOWS) {
|
||||||
|
const podcastId = audioNav.getPodcastId();
|
||||||
|
if (!podcastId) return;
|
||||||
|
|
||||||
|
const feed = feedStore.getFilteredFeeds().find(f => f.podcast.id === podcastId);
|
||||||
|
if (!feed) return;
|
||||||
|
|
||||||
|
episodes = feed.episodes.map(ep => ({ episode: ep, feed }));
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentIndex = audioNav.getCurrentIndex();
|
||||||
|
const newIndex = Math.min(episodes.length - 1, currentIndex + 1);
|
||||||
|
|
||||||
|
if (newIndex >= 0 && episodes[newIndex]) {
|
||||||
|
const { episode } = episodes[newIndex];
|
||||||
|
await play(episode);
|
||||||
|
audioNav.next(newIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onCleanup(() => {
|
onCleanup(() => {
|
||||||
refCount--
|
refCount--
|
||||||
unsubPlay()
|
unsubPlay()
|
||||||
@@ -447,5 +522,7 @@ export function useAudio(): AudioControls {
|
|||||||
setVolume: doSetVolume,
|
setVolume: doSetVolume,
|
||||||
setSpeed: doSetSpeed,
|
setSpeed: doSetSpeed,
|
||||||
switchBackend,
|
switchBackend,
|
||||||
|
prev,
|
||||||
|
next,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,19 +61,19 @@ export function DiscoverPage(props: PageProps) {
|
|||||||
const isSelected = () =>
|
const isSelected = () =>
|
||||||
discoverStore.selectedCategory() === category.id;
|
discoverStore.selectedCategory() === category.id;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SelectableBox
|
<SelectableBox
|
||||||
selected={isSelected}
|
selected={isSelected}
|
||||||
onMouseDown={() => handleCategorySelect(category.id)}
|
onMouseDown={() => handleCategorySelect(category.id)}
|
||||||
>
|
>
|
||||||
<SelectableText
|
<SelectableText
|
||||||
selected={isSelected}
|
selected={isSelected}
|
||||||
fg={theme.primary}
|
primary
|
||||||
>
|
>
|
||||||
{category.icon} {category.name}
|
{category.icon} {category.name}
|
||||||
</SelectableText>
|
</SelectableText>
|
||||||
</SelectableBox>
|
</SelectableBox>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
</For>
|
</For>
|
||||||
</box>
|
</box>
|
||||||
@@ -85,14 +85,15 @@ export function DiscoverPage(props: PageProps) {
|
|||||||
borderColor={theme.border}
|
borderColor={theme.border}
|
||||||
>
|
>
|
||||||
<box padding={1}>
|
<box padding={1}>
|
||||||
<text
|
<SelectableText
|
||||||
fg={props.depth() == DiscoverPagePaneType.SHOWS ? theme.primary : theme.textMuted}
|
selected={() => false}
|
||||||
>
|
primary={props.depth() == DiscoverPagePaneType.SHOWS}
|
||||||
|
>
|
||||||
Trending in{" "}
|
Trending in{" "}
|
||||||
{DISCOVER_CATEGORIES.find(
|
{DISCOVER_CATEGORIES.find(
|
||||||
(c) => c.id === discoverStore.selectedCategory(),
|
(c) => c.id === discoverStore.selectedCategory(),
|
||||||
)?.name ?? "All"}
|
)?.name ?? "All"}
|
||||||
</text>
|
</SelectableText>
|
||||||
</box>
|
</box>
|
||||||
<box flexDirection="column" height="100%">
|
<box flexDirection="column" height="100%">
|
||||||
<Show
|
<Show
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export function PodcastCard(props: PodcastCardProps) {
|
|||||||
onMouseDown={props.onSelect}
|
onMouseDown={props.onSelect}
|
||||||
>
|
>
|
||||||
<box flexDirection="row" gap={2} alignItems="center">
|
<box flexDirection="row" gap={2} alignItems="center">
|
||||||
<SelectableText selected={() => props.selected}>
|
<SelectableText selected={() => props.selected} primary>
|
||||||
<strong>{props.podcast.title}</strong>
|
<strong>{props.podcast.title}</strong>
|
||||||
</SelectableText>
|
</SelectableText>
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ export function PodcastCard(props: PodcastCardProps) {
|
|||||||
<Show when={props.podcast.author && !props.compact}>
|
<Show when={props.podcast.author && !props.compact}>
|
||||||
<SelectableText
|
<SelectableText
|
||||||
selected={() => props.selected}
|
selected={() => props.selected}
|
||||||
fg={theme.textMuted}
|
tertiary
|
||||||
>
|
>
|
||||||
by {props.podcast.author}
|
by {props.podcast.author}
|
||||||
</SelectableText>
|
</SelectableText>
|
||||||
@@ -52,7 +52,7 @@ export function PodcastCard(props: PodcastCardProps) {
|
|||||||
<Show when={props.podcast.description && !props.compact}>
|
<Show when={props.podcast.description && !props.compact}>
|
||||||
<SelectableText
|
<SelectableText
|
||||||
selected={() => props.selected}
|
selected={() => props.selected}
|
||||||
fg={theme.text}
|
tertiary
|
||||||
>
|
>
|
||||||
{props.podcast.description!.length > 80
|
{props.podcast.description!.length > 80
|
||||||
? props.podcast.description!.slice(0, 80) + "..."
|
? props.podcast.description!.slice(0, 80) + "..."
|
||||||
|
|||||||
@@ -86,54 +86,54 @@ export function FeedDetail(props: FeedDetailProps) {
|
|||||||
{/* Header with back button */}
|
{/* Header with back button */}
|
||||||
<box flexDirection="row" justifyContent="space-between">
|
<box flexDirection="row" justifyContent="space-between">
|
||||||
<box border padding={0} onMouseDown={props.onBack} borderColor={theme.border}>
|
<box border padding={0} onMouseDown={props.onBack} borderColor={theme.border}>
|
||||||
<text fg={theme.primary}>[Esc] Back</text>
|
<SelectableText selected={() => false} primary>[Esc] Back</SelectableText>
|
||||||
</box>
|
</box>
|
||||||
<box border padding={0} onMouseDown={() => setShowInfo((v) => !v)} borderColor={theme.border}>
|
<box border padding={0} onMouseDown={() => setShowInfo((v) => !v)} borderColor={theme.border}>
|
||||||
<text fg={theme.primary}>[i] {showInfo() ? "Hide" : "Show"} Info</text>
|
<SelectableText selected={() => false} primary>[i] {showInfo() ? "Hide" : "Show"} Info</SelectableText>
|
||||||
</box>
|
</box>
|
||||||
</box>
|
</box>
|
||||||
|
|
||||||
{/* Podcast info section */}
|
{/* Podcast info section */}
|
||||||
<Show when={showInfo()}>
|
<Show when={showInfo()}>
|
||||||
<box border padding={1} flexDirection="column" gap={0} borderColor={theme.border}>
|
<box border padding={1} flexDirection="column" gap={0} borderColor={theme.border}>
|
||||||
<text fg={theme.text}>
|
<SelectableText selected={() => false} primary>
|
||||||
<strong>{props.feed.customName || props.feed.podcast.title}</strong>
|
<strong>{props.feed.customName || props.feed.podcast.title}</strong>
|
||||||
</text>
|
</SelectableText>
|
||||||
{props.feed.podcast.author && (
|
{props.feed.podcast.author && (
|
||||||
<box flexDirection="row" gap={1}>
|
<box flexDirection="row" gap={1}>
|
||||||
<text fg={theme.textMuted}>by</text>
|
<SelectableText selected={() => false} tertiary>by</SelectableText>
|
||||||
<text fg={theme.primary}>{props.feed.podcast.author}</text>
|
<SelectableText selected={() => false} primary>{props.feed.podcast.author}</SelectableText>
|
||||||
</box>
|
</box>
|
||||||
)}
|
)}
|
||||||
<box height={1} />
|
<box height={1} />
|
||||||
<text fg={theme.textMuted}>
|
<SelectableText selected={() => false} tertiary>
|
||||||
{props.feed.podcast.description?.slice(0, 200)}
|
{props.feed.podcast.description?.slice(0, 200)}
|
||||||
{(props.feed.podcast.description?.length || 0) > 200 ? "..." : ""}
|
{(props.feed.podcast.description?.length || 0) > 200 ? "..." : ""}
|
||||||
</text>
|
</SelectableText>
|
||||||
<box height={1} />
|
<box height={1} />
|
||||||
<box flexDirection="row" gap={2}>
|
<box flexDirection="row" gap={2}>
|
||||||
<box flexDirection="row" gap={1}>
|
<box flexDirection="row" gap={1}>
|
||||||
<text fg={theme.textMuted}>Episodes:</text>
|
<SelectableText selected={() => false} tertiary>Episodes:</SelectableText>
|
||||||
<text fg={theme.text}>{props.feed.episodes.length}</text>
|
<SelectableText selected={() => false} tertiary>{props.feed.episodes.length}</SelectableText>
|
||||||
</box>
|
</box>
|
||||||
<box flexDirection="row" gap={1}>
|
<box flexDirection="row" gap={1}>
|
||||||
<text fg={theme.textMuted}>Updated:</text>
|
<SelectableText selected={() => false} tertiary>Updated:</SelectableText>
|
||||||
<text fg={theme.text}>{formatDate(props.feed.lastUpdated)}</text>
|
<SelectableText selected={() => false} tertiary>{formatDate(props.feed.lastUpdated)}</SelectableText>
|
||||||
</box>
|
</box>
|
||||||
<text fg={props.feed.visibility === "public" ? theme.success : theme.warning}>
|
<SelectableText selected={() => false} tertiary>
|
||||||
{props.feed.visibility === "public" ? "[Public]" : "[Private]"}
|
{props.feed.visibility === "public" ? "[Public]" : "[Private]"}
|
||||||
</text>
|
</SelectableText>
|
||||||
{props.feed.isPinned && <text fg={theme.warning}>[Pinned]</text>}
|
{props.feed.isPinned && <SelectableText selected={() => false} tertiary>[Pinned]</SelectableText>}
|
||||||
</box>
|
</box>
|
||||||
</box>
|
</box>
|
||||||
</Show>
|
</Show>
|
||||||
|
|
||||||
{/* Episodes header */}
|
{/* Episodes header */}
|
||||||
<box flexDirection="row" justifyContent="space-between">
|
<box flexDirection="row" justifyContent="space-between">
|
||||||
<text fg={theme.text}>
|
<SelectableText selected={() => false} primary>
|
||||||
<strong>Episodes</strong>
|
<strong>Episodes</strong>
|
||||||
</text>
|
</SelectableText>
|
||||||
<text fg={theme.textMuted}>({episodes().length} total)</text>
|
<SelectableText selected={() => false} tertiary>({episodes().length} total)</SelectableText>
|
||||||
</box>
|
</box>
|
||||||
|
|
||||||
{/* Episode list */}
|
{/* Episode list */}
|
||||||
@@ -154,20 +154,20 @@ export function FeedDetail(props: FeedDetailProps) {
|
|||||||
>
|
>
|
||||||
<SelectableText
|
<SelectableText
|
||||||
selected={() => index() === selectedIndex()}
|
selected={() => index() === selectedIndex()}
|
||||||
fg={theme.primary}
|
primary
|
||||||
>
|
>
|
||||||
{index() === selectedIndex() ? ">" : " "}
|
{index() === selectedIndex() ? ">" : " "}
|
||||||
</SelectableText>
|
</SelectableText>
|
||||||
<SelectableText
|
<SelectableText
|
||||||
selected={() => index() === selectedIndex()}
|
selected={() => index() === selectedIndex()}
|
||||||
fg={theme.text}
|
primary
|
||||||
>
|
>
|
||||||
{episode.episodeNumber ? `#${episode.episodeNumber} - ` : ""}
|
{episode.episodeNumber ? `#${episode.episodeNumber} - ` : ""}
|
||||||
{episode.title}
|
{episode.title}
|
||||||
</SelectableText>
|
</SelectableText>
|
||||||
<box flexDirection="row" gap={2} paddingLeft={2}>
|
<box flexDirection="row" gap={2} paddingLeft={2}>
|
||||||
<text fg={theme.textMuted}>{formatDate(episode.pubDate)}</text>
|
<SelectableText selected={() => index() === selectedIndex()} tertiary>{formatDate(episode.pubDate)}</SelectableText>
|
||||||
<text fg={theme.textMuted}>{formatDuration(episode.duration)}</text>
|
<SelectableText selected={() => index() === selectedIndex()} tertiary>{formatDuration(episode.duration)}</SelectableText>
|
||||||
</box>
|
</box>
|
||||||
</SelectableBox>
|
</SelectableBox>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -54,26 +54,26 @@ export function FeedItem(props: FeedItemProps) {
|
|||||||
>
|
>
|
||||||
<SelectableText
|
<SelectableText
|
||||||
selected={() => props.isSelected}
|
selected={() => props.isSelected}
|
||||||
fg={theme.primary}
|
primary
|
||||||
>
|
>
|
||||||
{props.isSelected ? ">" : " "}
|
{props.isSelected ? ">" : " "}
|
||||||
</SelectableText>
|
</SelectableText>
|
||||||
<SelectableText
|
<SelectableText
|
||||||
selected={() => props.isSelected}
|
selected={() => props.isSelected}
|
||||||
fg={visibilityColor()}
|
tertiary
|
||||||
>
|
>
|
||||||
{visibilityIcon()}
|
{visibilityIcon()}
|
||||||
</SelectableText>
|
</SelectableText>
|
||||||
<SelectableText
|
<SelectableText
|
||||||
selected={() => props.isSelected}
|
selected={() => props.isSelected}
|
||||||
fg={theme.text}
|
primary
|
||||||
>
|
>
|
||||||
{props.feed.customName || props.feed.podcast.title}
|
{props.feed.customName || props.feed.podcast.title}
|
||||||
</SelectableText>
|
</SelectableText>
|
||||||
{props.showEpisodeCount && (
|
{props.showEpisodeCount && (
|
||||||
<SelectableText
|
<SelectableText
|
||||||
selected={() => props.isSelected}
|
selected={() => props.isSelected}
|
||||||
fg={theme.textMuted}
|
tertiary
|
||||||
>
|
>
|
||||||
({episodeCount()})
|
({episodeCount()})
|
||||||
</SelectableText>
|
</SelectableText>
|
||||||
@@ -95,25 +95,25 @@ export function FeedItem(props: FeedItemProps) {
|
|||||||
<box flexDirection="row" gap={1}>
|
<box flexDirection="row" gap={1}>
|
||||||
<SelectableText
|
<SelectableText
|
||||||
selected={() => props.isSelected}
|
selected={() => props.isSelected}
|
||||||
fg={theme.primary}
|
primary
|
||||||
>
|
>
|
||||||
{props.isSelected ? ">" : " "}
|
{props.isSelected ? ">" : " "}
|
||||||
</SelectableText>
|
</SelectableText>
|
||||||
<SelectableText
|
<SelectableText
|
||||||
selected={() => props.isSelected}
|
selected={() => props.isSelected}
|
||||||
fg={visibilityColor()}
|
tertiary
|
||||||
>
|
>
|
||||||
{visibilityIcon()}
|
{visibilityIcon()}
|
||||||
</SelectableText>
|
</SelectableText>
|
||||||
<SelectableText
|
<SelectableText
|
||||||
selected={() => props.isSelected}
|
selected={() => props.isSelected}
|
||||||
fg={theme.warning}
|
secondary
|
||||||
>
|
>
|
||||||
{pinnedIndicator()}
|
{pinnedIndicator()}
|
||||||
</SelectableText>
|
</SelectableText>
|
||||||
<SelectableText
|
<SelectableText
|
||||||
selected={() => props.isSelected}
|
selected={() => props.isSelected}
|
||||||
fg={theme.text}
|
primary
|
||||||
>
|
>
|
||||||
<strong>{props.feed.customName || props.feed.podcast.title}</strong>
|
<strong>{props.feed.customName || props.feed.podcast.title}</strong>
|
||||||
</SelectableText>
|
</SelectableText>
|
||||||
@@ -123,7 +123,7 @@ export function FeedItem(props: FeedItemProps) {
|
|||||||
{props.showEpisodeCount && (
|
{props.showEpisodeCount && (
|
||||||
<SelectableText
|
<SelectableText
|
||||||
selected={() => props.isSelected}
|
selected={() => props.isSelected}
|
||||||
fg={theme.textMuted}
|
tertiary
|
||||||
>
|
>
|
||||||
{episodeCount()} episodes ({unplayedCount()} new)
|
{episodeCount()} episodes ({unplayedCount()} new)
|
||||||
</SelectableText>
|
</SelectableText>
|
||||||
@@ -131,7 +131,7 @@ export function FeedItem(props: FeedItemProps) {
|
|||||||
{props.showLastUpdated && (
|
{props.showLastUpdated && (
|
||||||
<SelectableText
|
<SelectableText
|
||||||
selected={() => props.isSelected}
|
selected={() => props.isSelected}
|
||||||
fg={theme.textMuted}
|
tertiary
|
||||||
>
|
>
|
||||||
Updated: {formatDate(props.feed.lastUpdated)}
|
Updated: {formatDate(props.feed.lastUpdated)}
|
||||||
</SelectableText>
|
</SelectableText>
|
||||||
@@ -143,7 +143,7 @@ export function FeedItem(props: FeedItemProps) {
|
|||||||
selected={() => props.isSelected}
|
selected={() => props.isSelected}
|
||||||
paddingLeft={4}
|
paddingLeft={4}
|
||||||
paddingTop={0}
|
paddingTop={0}
|
||||||
fg={theme.textMuted}
|
tertiary
|
||||||
>
|
>
|
||||||
{props.feed.podcast.description.slice(0, 60)}
|
{props.feed.podcast.description.slice(0, 60)}
|
||||||
{props.feed.podcast.description.length > 60 ? "..." : ""}
|
{props.feed.podcast.description.length > 60 ? "..." : ""}
|
||||||
|
|||||||
@@ -5,22 +5,27 @@
|
|||||||
|
|
||||||
import { createSignal, For, Show } from "solid-js";
|
import { createSignal, For, Show } from "solid-js";
|
||||||
import { useFeedStore } from "@/stores/feed";
|
import { useFeedStore } from "@/stores/feed";
|
||||||
|
import { useKeyboard } from "@opentui/solid";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import type { Episode } from "@/types/episode";
|
import type { Episode } from "@/types/episode";
|
||||||
import type { Feed } from "@/types/feed";
|
import type { Feed } from "@/types/feed";
|
||||||
import { useTheme } from "@/context/ThemeContext";
|
import { useTheme } from "@/context/ThemeContext";
|
||||||
import { PageProps } from "@/App";
|
import { PageProps } from "@/App";
|
||||||
import { SelectableBox, SelectableText } from "@/components/Selectable";
|
import { SelectableBox, SelectableText } from "@/components/Selectable";
|
||||||
|
import { se } from "date-fns/locale";
|
||||||
|
|
||||||
enum FeedPaneType {
|
enum FeedPaneType {
|
||||||
FEED = 1,
|
FEED = 1,
|
||||||
}
|
}
|
||||||
export const FeedPaneCount = 1;
|
export const FeedPaneCount = 1;
|
||||||
|
|
||||||
|
/** Episodes to load per batch */
|
||||||
|
const ITEMS_PER_BATCH = 50;
|
||||||
|
|
||||||
export function FeedPage(props: PageProps) {
|
export function FeedPage(props: PageProps) {
|
||||||
const feedStore = useFeedStore();
|
const feedStore = useFeedStore();
|
||||||
const [selectedIndex, setSelectedIndex] = createSignal(0);
|
|
||||||
const [isRefreshing, setIsRefreshing] = createSignal(false);
|
const [isRefreshing, setIsRefreshing] = createSignal(false);
|
||||||
|
const [loadedEpisodesCount, setLoadedEpisodesCount] = createSignal(ITEMS_PER_BATCH);
|
||||||
|
|
||||||
const allEpisodes = () => feedStore.getAllEpisodesChronological();
|
const allEpisodes = () => feedStore.getAllEpisodesChronological();
|
||||||
|
|
||||||
@@ -28,9 +33,14 @@ export function FeedPage(props: PageProps) {
|
|||||||
return format(date, "MMM d, yyyy");
|
return format(date, "MMM d, yyyy");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const paginatedEpisodes = () => {
|
||||||
|
const episodes = allEpisodes();
|
||||||
|
return episodes.slice(0, loadedEpisodesCount());
|
||||||
|
};
|
||||||
|
|
||||||
const episodesByDate = () => {
|
const episodesByDate = () => {
|
||||||
const groups: Record<string, { episode: Episode; feed: Feed }> = {};
|
const groups: Record<string, { episode: Episode; feed: Feed }> = {};
|
||||||
const sortedEpisodes = allEpisodes();
|
const sortedEpisodes = paginatedEpisodes();
|
||||||
|
|
||||||
for (const episode of sortedEpisodes) {
|
for (const episode of sortedEpisodes) {
|
||||||
const dateKey = formatDate(new Date(episode.episode.pubDate));
|
const dateKey = formatDate(new Date(episode.episode.pubDate));
|
||||||
@@ -76,45 +86,69 @@ export function FeedPage(props: PageProps) {
|
|||||||
</box>
|
</box>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<scrollbox height="100%" focused={props.depth() == FeedPaneType.FEED}>
|
<scrollbox height="100%" focused={props.depth() == FeedPaneType.FEED}>
|
||||||
<For each={Object.entries(episodesByDate()).sort(([a], [b]) => b.localeCompare(a))}>
|
<For
|
||||||
{([date, episode], groupIndex) => (
|
each={Object.entries(episodesByDate()).sort(([a], [b]) =>
|
||||||
<>
|
b.localeCompare(a),
|
||||||
<box flexDirection="column" gap={0} paddingLeft={1} paddingRight={1} paddingTop={1} paddingBottom={1}>
|
|
||||||
<text fg={theme.primary}>{date}</text>
|
|
||||||
</box>
|
|
||||||
<SelectableBox
|
|
||||||
selected={() => groupIndex() === selectedIndex()}
|
|
||||||
flexDirection="column"
|
|
||||||
gap={0}
|
|
||||||
paddingLeft={1}
|
|
||||||
paddingRight={1}
|
|
||||||
paddingTop={0}
|
|
||||||
paddingBottom={0}
|
|
||||||
onMouseDown={() => setSelectedIndex(groupIndex())}
|
|
||||||
>
|
|
||||||
<SelectableText selected={() => groupIndex() === selectedIndex()}>
|
|
||||||
{groupIndex() === selectedIndex() ? ">" : " "}
|
|
||||||
</SelectableText>
|
|
||||||
<SelectableText
|
|
||||||
selected={() => groupIndex() === selectedIndex()}
|
|
||||||
fg={theme.text}
|
|
||||||
>
|
|
||||||
{episode.episode.title}
|
|
||||||
</SelectableText>
|
|
||||||
<box flexDirection="row" gap={2} paddingLeft={2}>
|
|
||||||
<text fg={theme.primary}>{episode.feed.podcast.title}</text>
|
|
||||||
<text fg={theme.textMuted}>
|
|
||||||
{formatDate(episode.episode.pubDate)}
|
|
||||||
</text>
|
|
||||||
<text fg={theme.textMuted}>
|
|
||||||
{formatDuration(episode.episode.duration)}
|
|
||||||
</text>
|
|
||||||
</box>
|
|
||||||
</SelectableBox>
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
|
>
|
||||||
|
{([date, episode], groupIndex) => {
|
||||||
|
const index = typeof props.focusedIndex === 'function' ? props.focusedIndex() : props.focusedIndex;
|
||||||
|
const selected = () => groupIndex() === index;
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<box
|
||||||
|
flexDirection="column"
|
||||||
|
gap={0}
|
||||||
|
paddingLeft={1}
|
||||||
|
paddingRight={1}
|
||||||
|
paddingTop={1}
|
||||||
|
paddingBottom={1}
|
||||||
|
>
|
||||||
|
<SelectableText selected={() => false} primary>
|
||||||
|
{date}
|
||||||
|
</SelectableText>
|
||||||
|
</box>
|
||||||
|
<SelectableBox
|
||||||
|
selected={selected}
|
||||||
|
flexDirection="column"
|
||||||
|
gap={0}
|
||||||
|
paddingLeft={1}
|
||||||
|
paddingRight={1}
|
||||||
|
paddingTop={0}
|
||||||
|
paddingBottom={0}
|
||||||
|
onMouseDown={() => {
|
||||||
|
// Selection is handled by App's keyboard navigation
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<SelectableText selected={selected} primary>
|
||||||
|
{selected() ? ">" : " "}
|
||||||
|
</SelectableText>
|
||||||
|
<SelectableText selected={selected} primary>
|
||||||
|
{episode.episode.title}
|
||||||
|
</SelectableText>
|
||||||
|
<box flexDirection="row" gap={2} paddingLeft={2}>
|
||||||
|
<SelectableText selected={selected} primary>
|
||||||
|
{episode.feed.podcast.title}
|
||||||
|
</SelectableText>
|
||||||
|
<SelectableText selected={selected} tertiary>
|
||||||
|
{formatDate(episode.episode.pubDate)}
|
||||||
|
</SelectableText>
|
||||||
|
<SelectableText selected={selected} tertiary>
|
||||||
|
{formatDuration(episode.episode.duration)}
|
||||||
|
</SelectableText>
|
||||||
|
</box>
|
||||||
|
</SelectableBox>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}}
|
||||||
</For>
|
</For>
|
||||||
|
{/* Loading indicator */}
|
||||||
|
<Show when={feedStore.isLoadingMore()}>
|
||||||
|
<box padding={1}>
|
||||||
|
<text fg={theme.textMuted}>Loading more episodes...</text>
|
||||||
|
</box>
|
||||||
|
</Show>
|
||||||
</scrollbox>
|
</scrollbox>
|
||||||
</Show>
|
</Show>
|
||||||
</box>
|
</box>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { DownloadStatus } from "@/types/episode";
|
|||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import { PageProps } from "@/App";
|
import { PageProps } from "@/App";
|
||||||
import { useTheme } from "@/context/ThemeContext";
|
import { useTheme } from "@/context/ThemeContext";
|
||||||
|
import { useAudioNavStore, AudioSource } from "@/stores/audio-nav";
|
||||||
|
|
||||||
enum MyShowsPaneType {
|
enum MyShowsPaneType {
|
||||||
SHOWS = 1,
|
SHOWS = 1,
|
||||||
@@ -22,8 +23,7 @@ export const MyShowsPaneCount = 2;
|
|||||||
export function MyShowsPage(props: PageProps) {
|
export function MyShowsPage(props: PageProps) {
|
||||||
const feedStore = useFeedStore();
|
const feedStore = useFeedStore();
|
||||||
const downloadStore = useDownloadStore();
|
const downloadStore = useDownloadStore();
|
||||||
const [showIndex, setShowIndex] = createSignal(0);
|
const audioNav = useAudioNavStore();
|
||||||
const [episodeIndex, setEpisodeIndex] = createSignal(0);
|
|
||||||
const [isRefreshing, setIsRefreshing] = createSignal(false);
|
const [isRefreshing, setIsRefreshing] = createSignal(false);
|
||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
const mutedColor = () => theme.muted || theme.text;
|
const mutedColor = () => theme.muted || theme.text;
|
||||||
@@ -35,8 +35,8 @@ export function MyShowsPage(props: PageProps) {
|
|||||||
|
|
||||||
const selectedShow = createMemo(() => {
|
const selectedShow = createMemo(() => {
|
||||||
const s = shows();
|
const s = shows();
|
||||||
const idx = showIndex();
|
const index = typeof props.focusedIndex === 'function' ? props.focusedIndex() : props.focusedIndex;
|
||||||
return idx < s.length ? s[idx] : undefined;
|
return index < s.length ? s[index] : undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
const episodes = createMemo(() => {
|
const episodes = createMemo(() => {
|
||||||
@@ -47,23 +47,6 @@ export function MyShowsPage(props: PageProps) {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Detect when user navigates near the bottom and load more episodes
|
|
||||||
createEffect(() => {
|
|
||||||
const idx = episodeIndex();
|
|
||||||
const eps = episodes();
|
|
||||||
const show = selectedShow();
|
|
||||||
if (!show || eps.length === 0) return;
|
|
||||||
|
|
||||||
const nearBottom = idx >= eps.length - LOAD_MORE_THRESHOLD;
|
|
||||||
if (
|
|
||||||
nearBottom &&
|
|
||||||
feedStore.hasMoreEpisodes(show.id) &&
|
|
||||||
!feedStore.isLoadingMore()
|
|
||||||
) {
|
|
||||||
feedStore.loadMoreEpisodes(show.id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const formatDate = (date: Date): string => {
|
const formatDate = (date: Date): string => {
|
||||||
return format(date, "MMM d, yyyy");
|
return format(date, "MMM d, yyyy");
|
||||||
};
|
};
|
||||||
@@ -160,6 +143,7 @@ export function MyShowsPage(props: PageProps) {
|
|||||||
onMouseDown={() => {
|
onMouseDown={() => {
|
||||||
setShowIndex(index());
|
setShowIndex(index());
|
||||||
setEpisodeIndex(0);
|
setEpisodeIndex(0);
|
||||||
|
audioNav.setSource(AudioSource.MY_SHOWS, selectedShow()?.podcast.id);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<text
|
<text
|
||||||
|
|||||||
@@ -27,45 +27,45 @@ export function ResultCard(props: ResultCardProps) {
|
|||||||
justifyContent="space-between"
|
justifyContent="space-between"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
>
|
>
|
||||||
<box flexDirection="row" gap={2} alignItems="center">
|
<box flexDirection="row" gap={2} alignItems="center">
|
||||||
<SelectableText
|
<SelectableText
|
||||||
selected={() => props.selected}
|
selected={() => props.selected}
|
||||||
fg={theme.primary}
|
primary
|
||||||
>
|
>
|
||||||
<strong>{podcast().title}</strong>
|
<strong>{podcast().title}</strong>
|
||||||
</SelectableText>
|
</SelectableText>
|
||||||
<SourceBadge
|
<SourceBadge
|
||||||
sourceId={props.result.sourceId}
|
sourceId={props.result.sourceId}
|
||||||
sourceName={props.result.sourceName}
|
sourceName={props.result.sourceName}
|
||||||
sourceType={props.result.sourceType}
|
sourceType={props.result.sourceType}
|
||||||
/>
|
/>
|
||||||
</box>
|
</box>
|
||||||
<Show when={podcast().isSubscribed}>
|
<Show when={podcast().isSubscribed}>
|
||||||
<text fg={theme.success}>[Subscribed]</text>
|
<text fg={theme.success}>[Subscribed]</text>
|
||||||
</Show>
|
</Show>
|
||||||
</box>
|
</box>
|
||||||
|
|
||||||
<Show when={podcast().author}>
|
<Show when={podcast().author}>
|
||||||
<SelectableText
|
<SelectableText
|
||||||
selected={() => props.selected}
|
selected={() => props.selected}
|
||||||
fg={theme.textMuted}
|
tertiary
|
||||||
>
|
>
|
||||||
by {podcast().author}
|
by {podcast().author}
|
||||||
</SelectableText>
|
</SelectableText>
|
||||||
</Show>
|
</Show>
|
||||||
|
|
||||||
<Show when={podcast().description}>
|
<Show when={podcast().description}>
|
||||||
{(description) => (
|
{(description) => (
|
||||||
<SelectableText
|
<SelectableText
|
||||||
selected={() => props.selected}
|
selected={() => props.selected}
|
||||||
fg={theme.text}
|
tertiary
|
||||||
>
|
>
|
||||||
{description().length > 120
|
{description().length > 120
|
||||||
? description().slice(0, 120) + "..."
|
? description().slice(0, 120) + "..."
|
||||||
: description()}
|
: description()}
|
||||||
</SelectableText>
|
</SelectableText>
|
||||||
)}
|
)}
|
||||||
</Show>
|
</Show>
|
||||||
|
|
||||||
<Show when={(podcast().categories ?? []).length > 0}>
|
<Show when={(podcast().categories ?? []).length > 0}>
|
||||||
<box flexDirection="row" gap={1}>
|
<box flexDirection="row" gap={1}>
|
||||||
|
|||||||
@@ -62,18 +62,18 @@ export function SearchHistory(props: SearchHistoryProps) {
|
|||||||
paddingRight={1}
|
paddingRight={1}
|
||||||
onMouseDown={() => handleSearchClick(index(), query)}
|
onMouseDown={() => handleSearchClick(index(), query)}
|
||||||
>
|
>
|
||||||
<SelectableText
|
<SelectableText
|
||||||
selected={isSelected}
|
selected={isSelected}
|
||||||
fg={theme.textMuted}
|
tertiary
|
||||||
>
|
>
|
||||||
{">"}
|
{">"}
|
||||||
</SelectableText>
|
</SelectableText>
|
||||||
<SelectableText
|
<SelectableText
|
||||||
selected={isSelected}
|
selected={isSelected}
|
||||||
fg={theme.primary}
|
primary
|
||||||
>
|
>
|
||||||
{query}
|
{query}
|
||||||
</SelectableText>
|
</SelectableText>
|
||||||
<box onMouseDown={() => handleRemoveClick(query)} padding={0}>
|
<box onMouseDown={() => handleRemoveClick(query)} padding={0}>
|
||||||
<text fg={theme.error}>[x]</text>
|
<text fg={theme.error}>[x]</text>
|
||||||
</box>
|
</box>
|
||||||
|
|||||||
@@ -198,23 +198,20 @@ export function SourceManager(props: SourceManagerProps) {
|
|||||||
feedStore.toggleSource(source.id);
|
feedStore.toggleSource(source.id);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<text
|
<SelectableText
|
||||||
fg={
|
selected={() => focusArea() === "list" && index() === selectedIndex()}
|
||||||
focusArea() === "list" && index() === selectedIndex()
|
primary
|
||||||
? theme.primary
|
>
|
||||||
: theme.textMuted
|
{focusArea() === "list" && index() === selectedIndex()
|
||||||
}
|
? ">"
|
||||||
>
|
: " "}
|
||||||
{focusArea() === "list" && index() === selectedIndex()
|
</SelectableText>
|
||||||
? ">"
|
<SelectableText
|
||||||
: " "}
|
selected={() => focusArea() === "list" && index() === selectedIndex()}
|
||||||
</text>
|
primary
|
||||||
<SelectableText
|
>
|
||||||
selected={() => focusArea() === "list" && index() === selectedIndex()}
|
{source.name}
|
||||||
fg={theme.text}
|
</SelectableText>
|
||||||
>
|
|
||||||
{source.name}
|
|
||||||
</SelectableText>
|
|
||||||
</SelectableBox>
|
</SelectableBox>
|
||||||
)}
|
)}
|
||||||
</For>
|
</For>
|
||||||
@@ -223,114 +220,98 @@ export function SourceManager(props: SourceManagerProps) {
|
|||||||
Space/Enter to toggle, d to delete, a to add
|
Space/Enter to toggle, d to delete, a to add
|
||||||
</text>
|
</text>
|
||||||
|
|
||||||
{/* API settings */}
|
{/* API settings */}
|
||||||
<box flexDirection="column" gap={1}>
|
<box flexDirection="column" gap={1}>
|
||||||
<text fg={isApiSource() ? theme.textMuted : theme.accent}>
|
<SelectableText selected={() => false} primary={isApiSource()}>
|
||||||
{isApiSource()
|
{isApiSource()
|
||||||
? "API Settings"
|
? "API Settings"
|
||||||
: "API Settings (select an API source)"}
|
: "API Settings (select an API source)"}
|
||||||
</text>
|
</SelectableText>
|
||||||
<box flexDirection="row" gap={2}>
|
<box flexDirection="row" gap={2}>
|
||||||
<box
|
<box
|
||||||
border
|
border
|
||||||
borderColor={theme.border}
|
borderColor={theme.border}
|
||||||
padding={0}
|
padding={0}
|
||||||
backgroundColor={
|
backgroundColor={
|
||||||
focusArea() === "country" ? theme.primary : undefined
|
focusArea() === "country" ? theme.primary : undefined
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<text
|
<SelectableText selected={() => false} primary={focusArea() === "country"}>
|
||||||
fg={focusArea() === "country" ? theme.primary : theme.textMuted}
|
Country: {sourceCountry()}
|
||||||
>
|
</SelectableText>
|
||||||
Country: {sourceCountry()}
|
</box>
|
||||||
</text>
|
<box
|
||||||
</box>
|
border
|
||||||
<box
|
borderColor={theme.border}
|
||||||
border
|
padding={0}
|
||||||
borderColor={theme.border}
|
backgroundColor={
|
||||||
padding={0}
|
focusArea() === "language" ? theme.primary : undefined
|
||||||
backgroundColor={
|
}
|
||||||
focusArea() === "language" ? theme.primary : undefined
|
>
|
||||||
}
|
<SelectableText selected={() => false} primary={focusArea() === "language"}>
|
||||||
>
|
Language:{" "}
|
||||||
<text
|
{sourceLanguage() === "ja_jp" ? "Japanese" : "English"}
|
||||||
fg={
|
</SelectableText>
|
||||||
focusArea() === "language" ? theme.primary : theme.textMuted
|
</box>
|
||||||
}
|
<box
|
||||||
>
|
border
|
||||||
Language:{" "}
|
borderColor={theme.border}
|
||||||
{sourceLanguage() === "ja_jp" ? "Japanese" : "English"}
|
padding={0}
|
||||||
</text>
|
backgroundColor={
|
||||||
</box>
|
focusArea() === "explicit" ? theme.primary : undefined
|
||||||
<box
|
}
|
||||||
border
|
>
|
||||||
borderColor={theme.border}
|
<SelectableText selected={() => false} primary={focusArea() === "explicit"}>
|
||||||
padding={0}
|
Explicit: {sourceExplicit() ? "Yes" : "No"}
|
||||||
backgroundColor={
|
</SelectableText>
|
||||||
focusArea() === "explicit" ? theme.primary : undefined
|
</box>
|
||||||
}
|
</box>
|
||||||
>
|
<SelectableText selected={() => false} tertiary>
|
||||||
<text
|
Enter/Space to toggle focused setting
|
||||||
fg={
|
</SelectableText>
|
||||||
focusArea() === "explicit" ? theme.primary : theme.textMuted
|
</box>
|
||||||
}
|
|
||||||
>
|
|
||||||
Explicit: {sourceExplicit() ? "Yes" : "No"}
|
|
||||||
</text>
|
|
||||||
</box>
|
|
||||||
</box>
|
|
||||||
<text fg={theme.textMuted}>
|
|
||||||
Enter/Space to toggle focused setting
|
|
||||||
</text>
|
|
||||||
</box>
|
|
||||||
</box>
|
</box>
|
||||||
|
|
||||||
{/* Add new source form */}
|
{/* Add new source form */}
|
||||||
<box border borderColor={theme.border} padding={1} flexDirection="column" gap={1}>
|
<box border borderColor={theme.border} padding={1} flexDirection="column" gap={1}>
|
||||||
<text
|
<SelectableText selected={() => false} primary={focusArea() === "add" || focusArea() === "url"}>
|
||||||
fg={
|
Add New Source:
|
||||||
focusArea() === "add" || focusArea() === "url"
|
</SelectableText>
|
||||||
? theme.primary
|
|
||||||
: theme.textMuted
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Add New Source:
|
|
||||||
</text>
|
|
||||||
|
|
||||||
<box flexDirection="row" gap={1}>
|
<box flexDirection="row" gap={1}>
|
||||||
<text fg={theme.textMuted}>Name:</text>
|
<SelectableText selected={() => false} tertiary>Name:</SelectableText>
|
||||||
<input
|
<input
|
||||||
value={newSourceName()}
|
value={newSourceName()}
|
||||||
onInput={setNewSourceName}
|
onInput={setNewSourceName}
|
||||||
placeholder="My Custom Feed"
|
placeholder="My Custom Feed"
|
||||||
focused={props.focused && focusArea() === "add"}
|
focused={props.focused && focusArea() === "add"}
|
||||||
width={25}
|
width={25}
|
||||||
/>
|
/>
|
||||||
</box>
|
</box>
|
||||||
|
|
||||||
<box flexDirection="row" gap={1}>
|
<box flexDirection="row" gap={1}>
|
||||||
<text fg={theme.textMuted}>URL:</text>
|
<SelectableText selected={() => false} tertiary>URL:</SelectableText>
|
||||||
<input
|
<input
|
||||||
value={newSourceUrl()}
|
value={newSourceUrl()}
|
||||||
onInput={(v) => {
|
onInput={(v) => {
|
||||||
setNewSourceUrl(v);
|
setNewSourceUrl(v);
|
||||||
setError(null);
|
setError(null);
|
||||||
}}
|
}}
|
||||||
placeholder="https://example.com/feed.rss"
|
placeholder="https://example.com/feed.rss"
|
||||||
focused={props.focused && focusArea() === "url"}
|
focused={props.focused && focusArea() === "url"}
|
||||||
width={35}
|
width={35}
|
||||||
/>
|
/>
|
||||||
</box>
|
</box>
|
||||||
|
|
||||||
<box border borderColor={theme.border} padding={0} width={15} onMouseDown={handleAddSource}>
|
<box border borderColor={theme.border} padding={0} width={15} onMouseDown={handleAddSource}>
|
||||||
<text fg={theme.success}>[+] Add Source</text>
|
<SelectableText selected={() => false} primary>[+] Add Source</SelectableText>
|
||||||
</box>
|
</box>
|
||||||
</box>
|
</box>
|
||||||
|
|
||||||
{/* Error message */}
|
{/* Error message */}
|
||||||
{error() && <text fg={theme.error}>{error()}</text>}
|
{error() && <SelectableText selected={() => false} tertiary>{error()}</SelectableText>}
|
||||||
|
|
||||||
<text fg={theme.textMuted}>Tab to switch sections, Esc to close</text>
|
<SelectableText selected={() => false} tertiary>Tab to switch sections, Esc to close</SelectableText>
|
||||||
</box>
|
</box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
126
src/stores/audio-nav.ts
Normal file
126
src/stores/audio-nav.ts
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
/**
|
||||||
|
* Audio navigation store for tracking episode order and position
|
||||||
|
* Persists the current episode context (source type, index, and podcastId)
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { createSignal } from "solid-js";
|
||||||
|
import {
|
||||||
|
loadAudioNavFromFile,
|
||||||
|
saveAudioNavToFile,
|
||||||
|
} from "../utils/app-persistence";
|
||||||
|
|
||||||
|
/** Source type for audio navigation */
|
||||||
|
export enum AudioSource {
|
||||||
|
FEED = "feed",
|
||||||
|
MY_SHOWS = "my_shows",
|
||||||
|
SEARCH = "search",
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Audio navigation state */
|
||||||
|
export interface AudioNavState {
|
||||||
|
/** Current source type */
|
||||||
|
source: AudioSource;
|
||||||
|
/** Index of current episode in the ordered list */
|
||||||
|
currentIndex: number;
|
||||||
|
/** Podcast ID for My Shows source */
|
||||||
|
podcastId?: string;
|
||||||
|
/** Timestamp when navigation state was last saved */
|
||||||
|
lastUpdated: Date;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Default navigation state */
|
||||||
|
const defaultNavState: AudioNavState = {
|
||||||
|
source: AudioSource.FEED,
|
||||||
|
currentIndex: 0,
|
||||||
|
lastUpdated: new Date(),
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Create audio navigation store */
|
||||||
|
export function createAudioNavStore() {
|
||||||
|
const [navState, setNavState] = createSignal<AudioNavState>(defaultNavState);
|
||||||
|
|
||||||
|
/** Persist current navigation state to file (fire-and-forget) */
|
||||||
|
function persist(): void {
|
||||||
|
saveAudioNavToFile(navState()).catch(() => {});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Load navigation state from file */
|
||||||
|
async function init(): Promise<void> {
|
||||||
|
const loaded = await loadAudioNavFromFile<AudioNavState>();
|
||||||
|
if (loaded) {
|
||||||
|
setNavState(loaded);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Fire-and-forget initialization */
|
||||||
|
init();
|
||||||
|
|
||||||
|
return {
|
||||||
|
/** Get current navigation state */
|
||||||
|
get state(): AudioNavState {
|
||||||
|
return navState();
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Update source type */
|
||||||
|
setSource: (source: AudioSource, podcastId?: string) => {
|
||||||
|
setNavState((prev) => ({
|
||||||
|
...prev,
|
||||||
|
source,
|
||||||
|
podcastId,
|
||||||
|
lastUpdated: new Date(),
|
||||||
|
}));
|
||||||
|
persist();
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Move to next episode */
|
||||||
|
next: (currentIndex: number) => {
|
||||||
|
setNavState((prev) => ({
|
||||||
|
...prev,
|
||||||
|
currentIndex,
|
||||||
|
lastUpdated: new Date(),
|
||||||
|
}));
|
||||||
|
persist();
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Move to previous episode */
|
||||||
|
prev: (currentIndex: number) => {
|
||||||
|
setNavState((prev) => ({
|
||||||
|
...prev,
|
||||||
|
currentIndex,
|
||||||
|
lastUpdated: new Date(),
|
||||||
|
}));
|
||||||
|
persist();
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Reset to default state */
|
||||||
|
reset: () => {
|
||||||
|
setNavState(defaultNavState);
|
||||||
|
persist();
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Get current index */
|
||||||
|
getCurrentIndex: (): number => {
|
||||||
|
return navState().currentIndex;
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Get current source */
|
||||||
|
getSource: (): AudioSource => {
|
||||||
|
return navState().source;
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Get current podcast ID */
|
||||||
|
getPodcastId: (): string | undefined => {
|
||||||
|
return navState().podcastId;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Singleton instance */
|
||||||
|
let audioNavInstance: ReturnType<typeof createAudioNavStore> | null = null;
|
||||||
|
|
||||||
|
export function useAudioNavStore() {
|
||||||
|
if (!audioNavInstance) {
|
||||||
|
audioNavInstance = createAudioNavStore();
|
||||||
|
}
|
||||||
|
return audioNavInstance;
|
||||||
|
}
|
||||||
@@ -16,10 +16,18 @@ export const BASE_THEME_COLORS: ThemeColors = {
|
|||||||
secondary: "#a9b1d6",
|
secondary: "#a9b1d6",
|
||||||
accent: "#f6c177",
|
accent: "#f6c177",
|
||||||
text: "#e6edf3",
|
text: "#e6edf3",
|
||||||
|
textPrimary: "#e6edf3",
|
||||||
|
textSecondary: "#a9b1d6",
|
||||||
|
textTertiary: "#7d8590",
|
||||||
|
textSelectedPrimary: "#1b1f27",
|
||||||
|
textSelectedSecondary: "#e6edf3",
|
||||||
|
textSelectedTertiary: "#a9b1d6",
|
||||||
muted: "#7d8590",
|
muted: "#7d8590",
|
||||||
warning: "#f0b429",
|
warning: "#f0b429",
|
||||||
error: "#f47067",
|
error: "#f47067",
|
||||||
success: "#3fb950",
|
success: "#3fb950",
|
||||||
|
_hasSelectedListItemText: true,
|
||||||
|
thinkingOpacity: 0.5,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Base layer backgrounds
|
// Base layer backgrounds
|
||||||
@@ -61,16 +69,22 @@ export const THEMES_DESKTOP: DesktopTheme = {
|
|||||||
secondary: "#cba6f7",
|
secondary: "#cba6f7",
|
||||||
accent: "#f9e2af",
|
accent: "#f9e2af",
|
||||||
text: "#cdd6f4",
|
text: "#cdd6f4",
|
||||||
|
textPrimary: "#cdd6f4",
|
||||||
|
textSecondary: "#cba6f7",
|
||||||
|
textTertiary: "#7f849c",
|
||||||
|
textSelectedPrimary: "#1e1e2e",
|
||||||
|
textSelectedSecondary: "#cdd6f4",
|
||||||
|
textSelectedTertiary: "#cba6f7",
|
||||||
muted: "#7f849c",
|
muted: "#7f849c",
|
||||||
warning: "#fab387",
|
warning: "#fab387",
|
||||||
error: "#f38ba8",
|
error: "#f38ba8",
|
||||||
success: "#a6e3a1",
|
success: "#a6e3a1",
|
||||||
layerBackgrounds: {
|
layerBackgrounds: {
|
||||||
layer0: "transparent",
|
layer0: "transparent",
|
||||||
layer1: "#181825",
|
layer1: "#181825",
|
||||||
layer2: "#11111b",
|
layer2: "#11111b",
|
||||||
layer3: "#0a0a0f",
|
layer3: "#0a0a0f",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -82,6 +96,12 @@ export const THEMES_DESKTOP: DesktopTheme = {
|
|||||||
secondary: "#83a598",
|
secondary: "#83a598",
|
||||||
accent: "#fe8019",
|
accent: "#fe8019",
|
||||||
text: "#ebdbb2",
|
text: "#ebdbb2",
|
||||||
|
textPrimary: "#ebdbb2",
|
||||||
|
textSecondary: "#83a598",
|
||||||
|
textTertiary: "#928374",
|
||||||
|
textSelectedPrimary: "#282828",
|
||||||
|
textSelectedSecondary: "#ebdbb2",
|
||||||
|
textSelectedTertiary: "#83a598",
|
||||||
muted: "#928374",
|
muted: "#928374",
|
||||||
warning: "#fabd2f",
|
warning: "#fabd2f",
|
||||||
error: "#fb4934",
|
error: "#fb4934",
|
||||||
@@ -103,6 +123,12 @@ export const THEMES_DESKTOP: DesktopTheme = {
|
|||||||
secondary: "#bb9af7",
|
secondary: "#bb9af7",
|
||||||
accent: "#e0af68",
|
accent: "#e0af68",
|
||||||
text: "#c0caf5",
|
text: "#c0caf5",
|
||||||
|
textPrimary: "#c0caf5",
|
||||||
|
textSecondary: "#bb9af7",
|
||||||
|
textTertiary: "#565f89",
|
||||||
|
textSelectedPrimary: "#1a1b26",
|
||||||
|
textSelectedSecondary: "#c0caf5",
|
||||||
|
textSelectedTertiary: "#bb9af7",
|
||||||
muted: "#565f89",
|
muted: "#565f89",
|
||||||
warning: "#e0af68",
|
warning: "#e0af68",
|
||||||
error: "#f7768e",
|
error: "#f7768e",
|
||||||
@@ -124,6 +150,12 @@ export const THEMES_DESKTOP: DesktopTheme = {
|
|||||||
secondary: "#81a1c1",
|
secondary: "#81a1c1",
|
||||||
accent: "#ebcb8b",
|
accent: "#ebcb8b",
|
||||||
text: "#eceff4",
|
text: "#eceff4",
|
||||||
|
textPrimary: "#eceff4",
|
||||||
|
textSecondary: "#81a1c1",
|
||||||
|
textTertiary: "#4c566a",
|
||||||
|
textSelectedPrimary: "#2e3440",
|
||||||
|
textSelectedSecondary: "#eceff4",
|
||||||
|
textSelectedTertiary: "#81a1c1",
|
||||||
muted: "#4c566a",
|
muted: "#4c566a",
|
||||||
warning: "#ebcb8b",
|
warning: "#ebcb8b",
|
||||||
error: "#bf616a",
|
error: "#bf616a",
|
||||||
|
|||||||
@@ -23,11 +23,20 @@ export type ThemeColors = {
|
|||||||
secondary: ColorValue;
|
secondary: ColorValue;
|
||||||
accent: ColorValue;
|
accent: ColorValue;
|
||||||
text: ColorValue;
|
text: ColorValue;
|
||||||
|
textPrimary?: ColorValue;
|
||||||
|
textSecondary?: ColorValue;
|
||||||
|
textTertiary?: ColorValue;
|
||||||
|
textSelectedPrimary?: ColorValue;
|
||||||
|
textSelectedSecondary?: ColorValue;
|
||||||
|
textSelectedTertiary?: ColorValue;
|
||||||
muted: ColorValue;
|
muted: ColorValue;
|
||||||
warning: ColorValue;
|
warning: ColorValue;
|
||||||
error: ColorValue;
|
error: ColorValue;
|
||||||
success: ColorValue;
|
success: ColorValue;
|
||||||
layerBackgrounds?: LayerBackgrounds;
|
layerBackgrounds?: LayerBackgrounds;
|
||||||
|
_hasSelectedListItemText?: boolean;
|
||||||
|
thinkingOpacity?: number;
|
||||||
|
selectedListItemText?: ColorValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ThemeVariant = {
|
export type ThemeVariant = {
|
||||||
|
|||||||
@@ -23,4 +23,10 @@ export type ThemeJson = {
|
|||||||
export type ThemeColors = Record<string, RGBA> & {
|
export type ThemeColors = Record<string, RGBA> & {
|
||||||
_hasSelectedListItemText: boolean
|
_hasSelectedListItemText: boolean
|
||||||
thinkingOpacity: number
|
thinkingOpacity: number
|
||||||
|
textPrimary?: ColorValue
|
||||||
|
textSecondary?: ColorValue
|
||||||
|
textTertiary?: ColorValue
|
||||||
|
textSelectedPrimary?: ColorValue
|
||||||
|
textSelectedSecondary?: ColorValue
|
||||||
|
textSelectedTertiary?: ColorValue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -295,39 +295,30 @@ function CommandDialog(props: {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<box flexDirection="column" flexGrow={1}>
|
<box flexDirection="column" flexGrow={1}>
|
||||||
<SelectableText
|
<SelectableText
|
||||||
selected={() => index() === selectedIndex()}
|
selected={() => index() === selectedIndex()}
|
||||||
fg={
|
primary
|
||||||
index() === selectedIndex()
|
>
|
||||||
? theme.selectedListItemText
|
{option.title}
|
||||||
: theme.text
|
</SelectableText>
|
||||||
}
|
<Show when={option.footer}>
|
||||||
attributes={
|
<SelectableText
|
||||||
index() === selectedIndex()
|
selected={() => index() === selectedIndex()}
|
||||||
? TextAttributes.BOLD
|
tertiary
|
||||||
: undefined
|
>
|
||||||
}
|
{option.footer}
|
||||||
>
|
</SelectableText>
|
||||||
{option.title}
|
</Show>
|
||||||
</SelectableText>
|
<Show when={option.description}>
|
||||||
<Show when={option.footer}>
|
<SelectableText
|
||||||
<SelectableText
|
selected={() => index() === selectedIndex()}
|
||||||
selected={() => index() === selectedIndex()}
|
tertiary
|
||||||
fg={theme.textMuted}
|
>
|
||||||
>
|
{option.description}
|
||||||
{option.footer}
|
</SelectableText>
|
||||||
</SelectableText>
|
</Show>
|
||||||
</Show>
|
</box>
|
||||||
<Show when={option.description}>
|
|
||||||
<SelectableText
|
|
||||||
selected={() => index() === selectedIndex()}
|
|
||||||
fg={theme.textMuted}
|
|
||||||
>
|
|
||||||
{option.description}
|
|
||||||
</SelectableText>
|
|
||||||
</Show>
|
|
||||||
</box>
|
|
||||||
</SelectableBox>
|
</SelectableBox>
|
||||||
)}
|
)}
|
||||||
</For>
|
</For>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { DEFAULT_THEME } from "../constants/themes";
|
|||||||
|
|
||||||
const APP_STATE_FILE = "app-state.json";
|
const APP_STATE_FILE = "app-state.json";
|
||||||
const PROGRESS_FILE = "progress.json";
|
const PROGRESS_FILE = "progress.json";
|
||||||
|
const AUDIO_NAV_FILE = "audio-nav.json";
|
||||||
|
|
||||||
// --- Defaults ---
|
// --- Defaults ---
|
||||||
|
|
||||||
@@ -119,3 +120,39 @@ export async function saveProgressToFile(
|
|||||||
// Silently ignore write errors
|
// Silently ignore write errors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface AudioNavEntry {
|
||||||
|
source: string;
|
||||||
|
currentIndex: number;
|
||||||
|
podcastId?: string;
|
||||||
|
lastUpdated: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Load audio navigation state from JSON file */
|
||||||
|
export async function loadAudioNavFromFile<T>(): Promise<T | null> {
|
||||||
|
try {
|
||||||
|
const filePath = getConfigFilePath(AUDIO_NAV_FILE);
|
||||||
|
const file = Bun.file(filePath);
|
||||||
|
if (!(await file.exists())) return null;
|
||||||
|
|
||||||
|
const raw = await file.json();
|
||||||
|
if (!raw || typeof raw !== "object") return null;
|
||||||
|
|
||||||
|
return raw as T;
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Save audio navigation state to JSON file */
|
||||||
|
export async function saveAudioNavToFile<T>(
|
||||||
|
data: T,
|
||||||
|
): Promise<void> {
|
||||||
|
try {
|
||||||
|
await ensureConfigDir();
|
||||||
|
const filePath = getConfigFilePath(AUDIO_NAV_FILE);
|
||||||
|
await Bun.write(filePath, JSON.stringify(data, null, 2));
|
||||||
|
} catch {
|
||||||
|
// Silently ignore write errors
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -11,7 +11,12 @@ import { parseJSONC } from "./jsonc";
|
|||||||
import { getConfigFilePath, ensureConfigDir } from "./config-dir";
|
import { getConfigFilePath, ensureConfigDir } from "./config-dir";
|
||||||
import type { KeybindsResolved } from "../context/KeybindContext";
|
import type { KeybindsResolved } from "../context/KeybindContext";
|
||||||
|
|
||||||
const KEYBINDS_SOURCE = path.join(process.cwd(), "src", "config", "keybind.jsonc");
|
const KEYBINDS_SOURCE = path.join(
|
||||||
|
process.cwd(),
|
||||||
|
"src",
|
||||||
|
"config",
|
||||||
|
"keybind.jsonc",
|
||||||
|
);
|
||||||
const KEYBINDS_FILE = "keybinds.jsonc";
|
const KEYBINDS_FILE = "keybinds.jsonc";
|
||||||
|
|
||||||
/** Default keybinds from package */
|
/** Default keybinds from package */
|
||||||
@@ -31,6 +36,8 @@ const DEFAULT_KEYBINDS: KeybindsResolved = {
|
|||||||
"audio-play": [],
|
"audio-play": [],
|
||||||
"audio-next": ["<leader>n"],
|
"audio-next": ["<leader>n"],
|
||||||
"audio-prev": ["<leader>l"],
|
"audio-prev": ["<leader>l"],
|
||||||
|
"audio-seek-forward": ["<leader>sf"],
|
||||||
|
"audio-seek-backward": ["<leader>sb"],
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Copy keybind.jsonc to user config directory on first run */
|
/** Copy keybind.jsonc to user config directory on first run */
|
||||||
@@ -69,7 +76,9 @@ export async function loadKeybindsFromFile(): Promise<KeybindsResolved> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Save keybinds to JSONC file */
|
/** Save keybinds to JSONC file */
|
||||||
export async function saveKeybindsToFile(keybinds: KeybindsResolved): Promise<void> {
|
export async function saveKeybindsToFile(
|
||||||
|
keybinds: KeybindsResolved,
|
||||||
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await ensureConfigDir();
|
await ensureConfigDir();
|
||||||
const filePath = getConfigFilePath(KEYBINDS_FILE);
|
const filePath = getConfigFilePath(KEYBINDS_FILE);
|
||||||
|
|||||||
@@ -64,6 +64,19 @@ export function generateSystemTheme(
|
|||||||
const diffAddedLineNumberBg = tint(grays[3], ansi.green, diffAlpha);
|
const diffAddedLineNumberBg = tint(grays[3], ansi.green, diffAlpha);
|
||||||
const diffRemovedLineNumberBg = tint(grays[3], ansi.red, diffAlpha);
|
const diffRemovedLineNumberBg = tint(grays[3], ansi.red, diffAlpha);
|
||||||
|
|
||||||
|
// Create darker shades for selected text colors to ensure contrast
|
||||||
|
const darken = (color: RGBA, factor: number = 0.6) => {
|
||||||
|
return RGBA.fromInts(
|
||||||
|
Math.round(color.r * 255 * factor),
|
||||||
|
Math.round(color.g * 255 * factor),
|
||||||
|
Math.round(color.b * 255 * factor)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const selectedPrimary = darken(ansi.cyan, isDark ? 0.4 : 0.6);
|
||||||
|
const selectedSecondary = darken(ansi.magenta, isDark ? 0.4 : 0.6);
|
||||||
|
const selectedTertiary = darken(textMuted, isDark ? 0.5 : 0.5);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
theme: {
|
theme: {
|
||||||
primary: ansi.cyan,
|
primary: ansi.cyan,
|
||||||
@@ -75,6 +88,12 @@ export function generateSystemTheme(
|
|||||||
info: ansi.cyan,
|
info: ansi.cyan,
|
||||||
text: fg,
|
text: fg,
|
||||||
textMuted,
|
textMuted,
|
||||||
|
textPrimary: fg,
|
||||||
|
textSecondary: textMuted,
|
||||||
|
textTertiary: textMuted,
|
||||||
|
textSelectedPrimary: selectedPrimary,
|
||||||
|
textSelectedSecondary: selectedSecondary,
|
||||||
|
textSelectedTertiary: selectedTertiary,
|
||||||
selectedListItemText: bg,
|
selectedListItemText: bg,
|
||||||
background: transparent,
|
background: transparent,
|
||||||
backgroundPanel: grays[2],
|
backgroundPanel: grays[2],
|
||||||
|
|||||||
Reference in New Issue
Block a user