Repository: Automattic/pocket-casts-android
File: modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/bookmark/BookmarkManagerImpl.kt (Kotlin)

Code before:
        addedAt: Instant,
    ): Bookmark {
        // Prevent adding more than one bookmark at the same place
        val existingBookmark = findByEpisodeTime(episode = episode, timeSecs = timeSecs)
        if (existingBookmark != null) {
            return existingBookmark
        }
        val addedAtMs = addedAt.toEpochMilli()
        val bookmark = Bookmark(
            uuid = UUID.randomUUID().toString(),
            episodeUuid = episode.uuid,
            podcastUuid = episode.podcastOrSubstituteUuid,
            timeSecs = timeSecs,
            createdAt = Date.from(addedAt),
            title = title,
            titleModified = addedAtMs,
            deleted = false,
            deletedModified = addedAtMs,
            syncStatus = SyncStatus.NOT_SYNCED,
        )
        bookmarkDao.insert(bookmark)
        val podcastUuid = if (episode is PodcastEpisode) episode.podcastOrSubstituteUuid else "user_file"
        eventHorizon.track(
            BookmarkCreatedEvent(
                source = creationSource,
                time = addedAtMs,
                episodeUuid = episode.uuid,
                podcastUuid = podcastUuid,
            ),
        )
        return bookmark
    }

    override suspend fun updateTitle(bookmarkUuid: String, title: String) {
        bookmarkDao.updateTitle(
            bookmarkUuid = bookmarkUuid,
            title = title,
            titleModified = System.currentTimeMillis(),
            syncStatus = SyncStatus.NOT_SYNCED,
        )
        eventHorizon.track(
            BookmarkUpdateTitleEvent(
                source = sourceView.eventHorizonValue,
            ),
        )
    }

    /**
     * Find the bookmark by its UUID.
     */
    override suspend fun findBookmark(

Review comment (bug):
I think this is an existing bug but the description of this is "The time in the episode the bookmark was created for" which I read should the episode playback progress time, not the time the bookmark was added. 
This is the iOS version https://github.com/Automattic/pocket-casts-ios/blob/f6e337aaab05d9f99fe349d541f8251559633a3b/podcasts/PlaybackManager.swift#L2362


Code after:
        addedAt: Instant,
    ): Bookmark {
        // Prevent adding more than one bookmark at the same place
        val existingBookmark = findByEpisodeTime(episode = episode, timeSecs = timeSecs)
        if (existingBookmark != null) {
            return existingBookmark
        }
        val addedAtMs = addedAt.toEpochMilli()
        val bookmark = Bookmark(
            uuid = UUID.randomUUID().toString(),
            episodeUuid = episode.uuid,
            podcastUuid = episode.podcastOrSubstituteUuid,
            timeSecs = timeSecs,
            createdAt = Date.from(addedAt),
            title = title,
            titleModified = addedAtMs,
            deleted = false,
            deletedModified = addedAtMs,
            syncStatus = SyncStatus.NOT_SYNCED,
        )
        bookmarkDao.insert(bookmark)
        val podcastUuid = if (episode is PodcastEpisode) episode.podcastOrSubstituteUuid else "user_file"
        eventHorizon.track(
            BookmarkCreatedEvent(
                source = creationSource,
                time = timeSecs.toLong(),
                episodeUuid = episode.uuid,
                podcastUuid = podcastUuid,
            ),
        )
        return bookmark
    }

    override suspend fun updateTitle(bookmarkUuid: String, title: String) {
        bookmarkDao.updateTitle(
            bookmarkUuid = bookmarkUuid,
            title = title,
            titleModified = System.currentTimeMillis(),
            syncStatus = SyncStatus.NOT_SYNCED,
        )
        eventHorizon.track(
            BookmarkUpdateTitleEvent(
                source = sourceView.eventHorizonValue,
            ),
        )
    }

    /**
     * Find the bookmark by its UUID.
     */
    override suspend fun findBookmark(