2021-04-01 08:39:15 +02:00
//
// M e P r o f i l e V i e w M o d e l . s w i f t
// M a s t o d o n
//
// C r e a t e d b y M a i n a s u K C i r n o o n 2 0 2 1 - 3 - 3 0 .
//
import os . log
import UIKit
import Combine
import CoreData
import CoreDataStack
2022-10-08 07:43:06 +02:00
import MastodonCore
2021-04-01 08:39:15 +02:00
import MastodonSDK
final class MeProfileViewModel : ProfileViewModel {
2022-10-09 14:07:57 +02:00
init ( context : AppContext , authContext : AuthContext ) {
let user = authContext . mastodonAuthenticationBox . authenticationRecord . object ( in : context . managedObjectContext ) ? . user
2021-04-01 08:39:15 +02:00
super . init (
context : context ,
2022-10-09 14:07:57 +02:00
authContext : authContext ,
optionalMastodonUser : user
2021-04-01 08:39:15 +02:00
)
2022-02-10 12:30:41 +01:00
$ me
. sink { [ weak self ] me in
os_log ( " %{public}s[%{public}ld], %{public}s: current active mastodon user: %s " , ( ( #file as NSString ) . lastPathComponent ) , #line , #function , me ? . username ? ? " <nil> " )
2021-04-01 08:39:15 +02:00
guard let self = self else { return }
2022-02-10 12:30:41 +01:00
self . user = me
2021-04-01 08:39:15 +02:00
}
. store ( in : & disposeBag )
}
}