Cleanup (IOS-192)

This commit is contained in:
Nathan Mattes 2024-02-20 17:41:10 +01:00
parent a170a462ee
commit f6e630aa66
10 changed files with 111 additions and 118 deletions

View File

@ -57,7 +57,7 @@ extension ProfileCardView.ViewModel {
private func bindHeader(view: ProfileCardView) { private func bindHeader(view: ProfileCardView) {
$authorBannerImageURL $authorBannerImageURL
.sink { url in .sink { url in
guard let url = url, !url.absoluteString.hasSuffix(Mastodon.Entity.Account.missingImageName) else { guard let url, !url.absoluteString.hasSuffix(Mastodon.Entity.Account.missingImageName) else {
view.bannerImageView.image = .placeholder(color: .systemGray3) view.bannerImageView.image = .placeholder(color: .systemGray3)
return return
} }

View File

@ -46,7 +46,6 @@ final class DiscoveryPostsViewModel {
self.context = context self.context = context
self.authContext = authContext self.authContext = authContext
self.dataController = StatusDataController() self.dataController = StatusDataController()
// end init
Task { Task {
await checkServerEndpoint() await checkServerEndpoint()

View File

@ -25,7 +25,6 @@ extension NotificationTimelineViewController: DataSourceProvider {
let item: DataSourceItem? = { let item: DataSourceItem? = {
guard feed.kind == .notificationAll || feed.kind == .notificationMentions else { return nil } guard feed.kind == .notificationAll || feed.kind == .notificationMentions else { return nil }
//TODO: Get relationship
if let notification = feed.notification { if let notification = feed.notification {
let mastodonNotification = MastodonNotification.fromEntity(notification, relationship: nil) let mastodonNotification = MastodonNotification.fromEntity(notification, relationship: nil)
return .notification(record: mastodonNotification) return .notification(record: mastodonNotification)

View File

@ -56,7 +56,6 @@ final class NotificationTimelineViewModel {
switch scope { switch scope {
case .everything: case .everything:
//TODO: I need the relationship here, too
self.dataController.records = (try? FileManager.default.cachedNotificationsAll(for: authContext.mastodonAuthenticationBox))?.map({ notification in self.dataController.records = (try? FileManager.default.cachedNotificationsAll(for: authContext.mastodonAuthenticationBox))?.map({ notification in
MastodonFeed.fromNotification(notification, relationship: nil, kind: .notificationAll) MastodonFeed.fromNotification(notification, relationship: nil, kind: .notificationAll)
}) ?? [] }) ?? []

View File

@ -409,7 +409,6 @@ extension ProfileViewController {
guard let relationship else { return } guard let relationship else { return }
// they don't run as there's not a change, probably?
self.viewModel.relationship = relationship self.viewModel.relationship = relationship
self.viewModel.account = account self.viewModel.account = account
} }

View File

@ -22,7 +22,7 @@ public enum Persistence {
private var filename: String { private var filename: String {
switch self { switch self {
case .searchHistory(let userIdentifier): case .searchHistory(let userIdentifier):
return "search_history_\(uniqueUserDomainIdentifier(for: userIdentifier))" // todo: @zeitschlag should this be user-scoped as well? return "search_history_\(uniqueUserDomainIdentifier(for: userIdentifier))"
case let .homeTimeline(userIdentifier): case let .homeTimeline(userIdentifier):
return "home_timeline_\(uniqueUserDomainIdentifier(for: userIdentifier))" return "home_timeline_\(uniqueUserDomainIdentifier(for: userIdentifier))"
case let .notificationsMentions(userIdentifier): case let .notificationsMentions(userIdentifier):

View File

@ -97,8 +97,7 @@ extension NotificationService {
extension NotificationService { extension NotificationService {
public func unreadApplicationShortcutItems() async throws -> [UIApplicationShortcutItem] { public func unreadApplicationShortcutItems() async throws -> [UIApplicationShortcutItem] {
guard let authenticationService = self.authenticationService else { return [] } guard let authenticationService = self.authenticationService else { return [] }
let managedObjectContext = authenticationService.managedObjectContext
return try await managedObjectContext.perform {
var items: [UIApplicationShortcutItem] = [] var items: [UIApplicationShortcutItem] = []
for authentication in AuthenticationServiceProvider.shared.authentications { for authentication in AuthenticationServiceProvider.shared.authentications {
guard let account = authentication.account() else { continue } guard let account = authentication.account() else { continue }
@ -121,9 +120,7 @@ extension NotificationService {
items.append(item) items.append(item)
} }
return items return items
} }}
}
}
extension NotificationService { extension NotificationService {