generated from obsidianmd/obsidian-sample-plugin
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add playlists, queue, and favorites
- Loading branch information
Showing
18 changed files
with
516 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Writable } from "svelte/store"; | ||
import { FAVORITES_SETTINGS } from "./constants"; | ||
import { IPodNotes } from "./types/IPodNotes"; | ||
import { Playlist } from "./types/Playlist"; | ||
import { StoreController } from "./types/StoreController"; | ||
|
||
export class FavoritesController extends StoreController<Playlist> { | ||
private plugin: IPodNotes; | ||
|
||
constructor(store: Writable<Playlist>, plugin: IPodNotes) { | ||
super(store) | ||
this.plugin = plugin; | ||
} | ||
|
||
protected onChange(value: Playlist) { | ||
this.plugin.settings.favorites = { | ||
...value, | ||
// To ensure we always keep the correct playlist name | ||
...FAVORITES_SETTINGS | ||
}; | ||
|
||
this.plugin.saveSettings(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Writable } from "svelte/store"; | ||
import { IPodNotes } from "./types/IPodNotes"; | ||
import { Playlist } from "./types/Playlist"; | ||
import { StoreController } from "./types/StoreController"; | ||
|
||
export class PlaylistController extends StoreController<{[playlistName: string]: Playlist}> { | ||
private plugin: IPodNotes; | ||
|
||
constructor(store: Writable<{[playlistName: string]: Playlist}>, plugin: IPodNotes) { | ||
super(store) | ||
this.plugin = plugin; | ||
} | ||
|
||
protected onChange(value: {[playlistName: string]: Playlist}) { | ||
this.plugin.settings.playlists = value; | ||
|
||
this.plugin.saveSettings(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Writable } from "svelte/store"; | ||
import { QUEUE_SETTINGS } from "./constants"; | ||
import { IPodNotes } from "./types/IPodNotes"; | ||
import { Playlist } from "./types/Playlist"; | ||
import { StoreController } from "./types/StoreController"; | ||
|
||
export class QueueController extends StoreController<Playlist> { | ||
private plugin: IPodNotes; | ||
|
||
constructor(store: Writable<Playlist>, plugin: IPodNotes) { | ||
super(store) | ||
this.plugin = plugin; | ||
} | ||
|
||
protected onChange(value: Playlist) { | ||
this.plugin.settings.queue = { | ||
...value, | ||
// To ensure we always keep the correct playlist name | ||
...QUEUE_SETTINGS | ||
}; | ||
|
||
this.plugin.saveSettings(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,39 @@ | ||
import { IPodNotesSettings } from "src/types/IPodNotesSettings"; | ||
import { Playlist } from "./types/Playlist"; | ||
|
||
export const VIEW_TYPE = "podcast_player_view"; | ||
|
||
type PlaylistSettings = Pick<Playlist, "icon" | "name" | "shouldEpisodeRemoveAfterPlay" | "shouldRepeat">; | ||
|
||
export const FAVORITES_SETTINGS: PlaylistSettings = { | ||
icon: "lucide-star", | ||
name: "Favorites", | ||
shouldEpisodeRemoveAfterPlay: false, | ||
shouldRepeat: false, | ||
} | ||
|
||
export const QUEUE_SETTINGS: PlaylistSettings = { | ||
icon: "list-ordered", | ||
name: "Queue", | ||
shouldEpisodeRemoveAfterPlay: true, | ||
shouldRepeat: false, | ||
} | ||
|
||
export const DEFAULT_SETTINGS: IPodNotesSettings = { | ||
savedFeeds: {}, | ||
podNotes: {}, | ||
defaultPlaybackRate: 1, | ||
playedEpisodes: {}, | ||
favorites: { | ||
...FAVORITES_SETTINGS, | ||
episodes: [], | ||
}, | ||
queue: { | ||
...QUEUE_SETTINGS, | ||
episodes: [], | ||
}, | ||
playlists: {}, | ||
skipBackwardLength: 15, | ||
skipForwardLength: 15, | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Episode } from "./Episode"; | ||
import { IconType } from "./IconType"; | ||
|
||
export type Playlist = { | ||
icon: IconType, | ||
name: string; | ||
episodes: Episode[]; | ||
|
||
currentEpisode?: Episode; | ||
|
||
shouldEpisodeRemoveAfterPlay: boolean; | ||
shouldRepeat: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<script lang="ts"> | ||
import { Playlist } from "src/types/Playlist"; | ||
import Icon from "../obsidian/Icon.svelte"; | ||
export let playlist: Playlist; | ||
</script> | ||
|
||
<div class="playlist-card" aria-label={playlist.name}> | ||
<Icon icon={playlist.icon} size={40} clickable={true}/> | ||
<span> | ||
({playlist.episodes.length}) | ||
</span> | ||
</div> | ||
|
||
<style> | ||
.playlist-card { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
width: 100%; | ||
height: 100%; | ||
cursor: pointer; | ||
border: 1px solid var(--background-modifier-border); | ||
text-align: center; | ||
overflow: hidden; | ||
} | ||
.playlist-card:hover { | ||
background-color: var(--background-modifier-border); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.