Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix marking local book as read crashing iOS app #362

Merged
merged 1 commit into from
Sep 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions ios/App/Shared/models/local/LocalMediaProgress.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,19 @@ extension LocalMediaProgress {
}
}

static func getLocalMediaProgressId(localLibraryItemId: String?, localEpisodeId: String?) -> String? {
if let itemId = localLibraryItemId, let episodeId = localEpisodeId {
return "\(itemId)-\(episodeId)"
} else if let itemId = localLibraryItemId {
return itemId
} else {
return nil
}
}

static func fetchOrCreateLocalMediaProgress(localMediaProgressId: String?, localLibraryItemId: String?, localEpisodeId: String?) throws -> LocalMediaProgress? {
let localMediaProgressId = localMediaProgressId != nil ? localMediaProgressId : LocalMediaProgress.getLocalMediaProgressId(localLibraryItemId: localLibraryItemId, localEpisodeId: localEpisodeId)

let realm = try Realm()
return try realm.write { () -> LocalMediaProgress? in
if let localMediaProgressId = localMediaProgressId {
Expand Down