fix: AccountList scene not display items issue
This commit is contained in:
parent
3100c59a3b
commit
668a1d28e2
|
@ -216,7 +216,7 @@ extension SceneCoordinator {
|
||||||
let rootViewController: UIViewController
|
let rootViewController: UIViewController
|
||||||
|
|
||||||
do {
|
do {
|
||||||
let request = MastodonAuthentication.sortedFetchRequest
|
let request = MastodonAuthentication.activeSortedFetchRequest // use active order
|
||||||
let _authentication = try appContext.managedObjectContext.fetch(request).first
|
let _authentication = try appContext.managedObjectContext.fetch(request).first
|
||||||
let _authContext = _authentication.flatMap { AuthContext(authentication: $0) }
|
let _authContext = _authentication.flatMap { AuthContext(authentication: $0) }
|
||||||
self.authContext = _authContext
|
self.authContext = _authContext
|
||||||
|
|
|
@ -50,6 +50,12 @@ final class AccountListViewModel: NSObject {
|
||||||
// end init
|
// end init
|
||||||
|
|
||||||
mastodonAuthenticationFetchedResultsController.delegate = self
|
mastodonAuthenticationFetchedResultsController.delegate = self
|
||||||
|
do {
|
||||||
|
try mastodonAuthenticationFetchedResultsController.performFetch()
|
||||||
|
authentications = mastodonAuthenticationFetchedResultsController.fetchedObjects?.compactMap { $0.asRecrod } ?? []
|
||||||
|
} catch {
|
||||||
|
assertionFailure(error.localizedDescription)
|
||||||
|
}
|
||||||
|
|
||||||
$authentications
|
$authentications
|
||||||
.receive(on: DispatchQueue.main)
|
.receive(on: DispatchQueue.main)
|
||||||
|
|
|
@ -148,6 +148,18 @@ extension MastodonAuthentication: Managed {
|
||||||
public static var defaultSortDescriptors: [NSSortDescriptor] {
|
public static var defaultSortDescriptors: [NSSortDescriptor] {
|
||||||
return [NSSortDescriptor(keyPath: \MastodonAuthentication.createdAt, ascending: false)]
|
return [NSSortDescriptor(keyPath: \MastodonAuthentication.createdAt, ascending: false)]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static var activeSortDescriptors: [NSSortDescriptor] {
|
||||||
|
return [NSSortDescriptor(keyPath: \MastodonAuthentication.activedAt, ascending: false)]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extension MastodonAuthentication {
|
||||||
|
public static var activeSortedFetchRequest: NSFetchRequest<MastodonAuthentication> {
|
||||||
|
let request = NSFetchRequest<MastodonAuthentication>(entityName: entityName)
|
||||||
|
request.sortDescriptors = activeSortDescriptors
|
||||||
|
return request
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension MastodonAuthentication {
|
extension MastodonAuthentication {
|
||||||
|
|
Loading…
Reference in New Issue