forked from zotero/zotero-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply partially "Background downloads (zotero#832)"
- Loading branch information
Showing
4 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// RDownload.swift | ||
// Zotero | ||
// | ||
// Created by Michal Rentka on 20.12.2023. | ||
// Copyright © 2023 Corporation for Digital Scholarship. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
import RealmSwift | ||
|
||
final class RDownload: Object { | ||
@Persisted(indexed: true) var taskId: Int? | ||
@Persisted(indexed: true) var key: String | ||
@Persisted var parentKey: String? | ||
@Persisted var customLibraryKey: RCustomLibraryType? | ||
@Persisted var groupKey: Int? | ||
|
||
var libraryId: LibraryIdentifier? { | ||
get { | ||
guard !self.isInvalidated else { return nil } | ||
|
||
if let key = self.customLibraryKey { | ||
return .custom(key) | ||
} | ||
if let key = self.groupKey { | ||
return .group(key) | ||
} | ||
return nil | ||
} | ||
|
||
set { | ||
guard let identifier = newValue else { | ||
self.groupKey = nil | ||
self.customLibraryKey = nil | ||
return | ||
} | ||
|
||
switch identifier { | ||
case .custom(let type): | ||
self.customLibraryKey = type | ||
|
||
case .group(let id): | ||
self.groupKey = id | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters