> For the complete documentation index, see [llms.txt](https://wiki.cjpais.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.cjpais.com/brain-dump/april-20th-april-26th-2020/0.04-dev-journal.md).

# 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>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://wiki.cjpais.com/brain-dump/april-20th-april-26th-2020/0.04-dev-journal.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
