# 0.04 Dev Journal

## Summary

Overall a lot of cleanup and got to a functional state of playing episodes. Most basic end to end subscribe->get->play

* **Picker for the notes application side of things**
  * This allows picking between the dev and public stream environments
    * Needed this because I left myself in the dev env at the start of last week
    * Case switch statement for this. Toggles the API path&#x20;
* **New structure for the podcast app**
  * **Outer:**
    * Overall application state
    * `SceneDelegate`
    * `AppDelegate`
    * `PodcastState`
  * **Extensions:**
    * Have these extensions to encode URLs properly.&#x20;
    * Remove HTML from the JSON response that I get from the API.&#x20;
    * And then networking helpers is kind of this thing where, at least it lets me, download this image kind of cleanly and I can just call this.&#x20;
      * I don't know if this is the right way to do things. I don't think so
  * **Persistent Layer (Core Data):**
    * Local storage & persistent state management
    * Needs a lightweight data management layer on top
    * `PersistentPodcast`
      * Can convert from Podcast or to it for UI
    * `PersistentEpisode`
      * Can convert from Episode or to it for UI
  * **Models**
    * Decode JSON Response and use it in UI
    * Now everything is conforming to `Codable` to use `JSONDecoder()`
      * This is quite nice&#x20;
    * These are Episode and Podcast
  * **Internal**
    * Raw JSON that I got from the response so I don't have to hit the API as much.&#x20;
    * Something that I definitely need to integrate but I haven't haven't done yet.&#x20;
  * **Views**
    * **Podcast**
      * `PodcastSearchView`
        * Does the heavy lifting
        * Decodes JSON and fetches images async
          * May need to use a `DataTaskPublisher` in the future
      * `PodcastSubscriptionView`
        * Display current subs -> get to episodes
      * `PodcastListItemView`
        * Perhaps once list item created fetch image? Probably not
        * On subscribe write to the DB with `UIImage` `Data`
    * **Episode**
      * `PodcastEpisodesView`
        * Get episodes for a certain podcast
        * Can fetch from API
        * First gets local DB data
        * Refresh button in navbar to get latest podcasts
        * Worried about performance from all the DB queries
      * `EpisodeListItemView`
        * Play and pause buttons for a podcast and starts playing
      * `PodcastInboxView`
    * **Other**
      * `ContentView`
        * Minor modification to add `NowPlaying`
      * `NowPlaying`
        * Capture podcast that is playing and control it anywhere
* **Bugs:**
  * Multiple running ticks when playing/pausing podcasts
  * Create multiple `AVSessions`, should reuse.
  * No caching
  * `CoreData` subscribe is all messed up, bad state management, just refactor this
  * Relationships not fully managed yet
    * not loading images for episodes
  * sortDescriptors
* **Next:**
  * Begin integration into the main notes app.
    * Either I will integrate it there or do some interprocess communication&#x20;
    * Then all of that will go out to server, maybe it will record completely independently of each other to the server.&#x20;
      * I don't know
      * I think they should be sharing some kind of context I don't always want it to go out to the server.&#x20;
    * I don't know if this will be one app or separate apps I haven't decided yet. So these are all things to experiment with, I probably will do both because I can mostly just copy and paste.&#x20;
  * I might be using closure for the back end&#x20;
  * I, ideally would like run once and I can always push updates to it.&#x20;
    * I also would like it to be able to people to add their own API's in kind of a thing however you want to add handlers in. That would be great.&#x20;
  * This week was fixing all the mistakes I made last week, and making the code way easier to navigate and update, because it was a real pain to work with before it's still kind of a pain, but for me I can understand it in its current state. And I removed a lot of dependencies where I have to update, everything everywhere that still exists, and that's what I'm going to try to abstract away in the future.

## Demo

{% embed url="<https://youtu.be/CJwL9Vh6iWQ>" %}

## Video Journal

{% embed url="<https://youtu.be/x_--c485gZI>" %}
