Skip to content

Commit

Permalink
adds 'toast' notifications for less obvious actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mwhickson committed Nov 23, 2024
1 parent 7261e5a commit f78029e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tuipod/ui/podcast_app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
import uuid

from textual import on
from textual.app import App, ComposeResult
Expand Down Expand Up @@ -100,6 +99,7 @@ async def _refresh_podcast_list(self, search_term: str) -> None:
async def action_submit(self, event: Input.Submitted) -> None:
search_input: Input = event.input
search_term = search_input.value
self.notify("searching for: {0}".format(search_term), timeout=3)
await self._refresh_podcast_list(search_term)

def _set_player_button_status(self, mode: str):
Expand Down Expand Up @@ -144,6 +144,8 @@ def _action_episode_row_highlighted(self, event: DataTable.RowSelected) -> None:
break

def _action_podcast_row_selected(self, event: DataTable.RowSelected) -> None:
self.notify("getting episodes for: {0}".format(self.current_podcast.title), timeout=3)

episode_list = self.query_one(EpisodeList)
table = episode_list.query_one(DataTable)
table.loading = True
Expand Down Expand Up @@ -173,6 +175,7 @@ def _action_episode_row_selected(self, event: DataTable.RowSelected) -> None:
if playing_episode and playing_episode.is_playing:
playing_episode.stop_episode()

self.notify("playing: {0}".format(self.current_episode.title), timeout=3)
self.current_episode.play_episode()
self._set_player_button_status("playing")
except Exception as err:
Expand Down Expand Up @@ -200,9 +203,11 @@ def action_toggle_play(self) -> None:
if self.current_episode.is_playing:
self.current_episode.stop_episode()
self._set_player_button_status("paused")
self.notify("paused: {0}".format(self.current_episode.title), timeout=3)
else:
self.current_episode.play_episode()
self._set_player_button_status("playing")
self.notify("playing: {0}".format(self.current_episode.title), timeout=3)

def action_display_about(self) -> None:
self.app.push_screen(AboutInfoScreen())
Expand All @@ -219,9 +224,12 @@ async def action_subscribe_to_podcast(self) -> None:
self.subscriptions.add_podcast(self.current_podcast)
self.subscriptions.persist()
await self._refresh_podcast_list(self.searcher.search_text)
self.notify("subscribed to: {0}".format(self.current_podcast.title), timeout=3)

async def action_unsubscribe_from_podcast(self) -> None:
if not self.current_podcast is None:
title = self.current_podcast.title
self.subscriptions.remove_podcast(self.current_podcast.url)
self.subscriptions.persist()
await self._refresh_podcast_list(self.searcher.search_text)
self.notify("unsubscribed from: {0}".format(title), timeout=3)

0 comments on commit f78029e

Please sign in to comment.