Merge branch 'release/0.8.11' into main

This commit is contained in:
CMK 2021-07-12 20:05:05 +08:00
commit 3ef7c76e8c
10 changed files with 120 additions and 109 deletions

View File

@ -3910,7 +3910,7 @@
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Mastodon/Mastodon.entitlements; CODE_SIGN_ENTITLEMENTS = Mastodon/Mastodon.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 36; CURRENT_PROJECT_VERSION = 37;
DEVELOPMENT_ASSET_PATHS = "Mastodon/Resources/Preview\\ Assets.xcassets"; DEVELOPMENT_ASSET_PATHS = "Mastodon/Resources/Preview\\ Assets.xcassets";
DEVELOPMENT_TEAM = 5Z4GVSS33P; DEVELOPMENT_TEAM = 5Z4GVSS33P;
INFOPLIST_FILE = Mastodon/Info.plist; INFOPLIST_FILE = Mastodon/Info.plist;
@ -3918,7 +3918,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 0.8.10; MARKETING_VERSION = 0.8.11;
PRODUCT_BUNDLE_IDENTIFIER = org.joinmastodon.app; PRODUCT_BUNDLE_IDENTIFIER = org.joinmastodon.app;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
@ -3937,7 +3937,7 @@
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Mastodon/Mastodon.entitlements; CODE_SIGN_ENTITLEMENTS = Mastodon/Mastodon.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 36; CURRENT_PROJECT_VERSION = 37;
DEVELOPMENT_ASSET_PATHS = "Mastodon/Resources/Preview\\ Assets.xcassets"; DEVELOPMENT_ASSET_PATHS = "Mastodon/Resources/Preview\\ Assets.xcassets";
DEVELOPMENT_TEAM = 5Z4GVSS33P; DEVELOPMENT_TEAM = 5Z4GVSS33P;
INFOPLIST_FILE = Mastodon/Info.plist; INFOPLIST_FILE = Mastodon/Info.plist;
@ -3945,7 +3945,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 0.8.10; MARKETING_VERSION = 0.8.11;
PRODUCT_BUNDLE_IDENTIFIER = org.joinmastodon.app; PRODUCT_BUNDLE_IDENTIFIER = org.joinmastodon.app;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
@ -4265,7 +4265,7 @@
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Mastodon/Mastodon.entitlements; CODE_SIGN_ENTITLEMENTS = Mastodon/Mastodon.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 36; CURRENT_PROJECT_VERSION = 37;
DEVELOPMENT_ASSET_PATHS = "Mastodon/Resources/Preview\\ Assets.xcassets"; DEVELOPMENT_ASSET_PATHS = "Mastodon/Resources/Preview\\ Assets.xcassets";
DEVELOPMENT_TEAM = 5Z4GVSS33P; DEVELOPMENT_TEAM = 5Z4GVSS33P;
INFOPLIST_FILE = Mastodon/Info.plist; INFOPLIST_FILE = Mastodon/Info.plist;
@ -4273,7 +4273,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 0.8.10; MARKETING_VERSION = 0.8.11;
PRODUCT_BUNDLE_IDENTIFIER = org.joinmastodon.app; PRODUCT_BUNDLE_IDENTIFIER = org.joinmastodon.app;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
@ -4379,7 +4379,7 @@
buildSettings = { buildSettings = {
CODE_SIGN_ENTITLEMENTS = NotificationService/NotificationService.entitlements; CODE_SIGN_ENTITLEMENTS = NotificationService/NotificationService.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 36; CURRENT_PROJECT_VERSION = 37;
DEVELOPMENT_TEAM = 5Z4GVSS33P; DEVELOPMENT_TEAM = 5Z4GVSS33P;
INFOPLIST_FILE = NotificationService/Info.plist; INFOPLIST_FILE = NotificationService/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
@ -4387,7 +4387,7 @@
"@executable_path/Frameworks", "@executable_path/Frameworks",
"@executable_path/../../Frameworks", "@executable_path/../../Frameworks",
); );
MARKETING_VERSION = 0.8.10; MARKETING_VERSION = 0.8.11;
PRODUCT_BUNDLE_IDENTIFIER = org.joinmastodon.app.NotificationService; PRODUCT_BUNDLE_IDENTIFIER = org.joinmastodon.app.NotificationService;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
@ -4498,7 +4498,7 @@
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Mastodon/Mastodon.entitlements; CODE_SIGN_ENTITLEMENTS = Mastodon/Mastodon.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 36; CURRENT_PROJECT_VERSION = 37;
DEVELOPMENT_ASSET_PATHS = "Mastodon/Resources/Preview\\ Assets.xcassets"; DEVELOPMENT_ASSET_PATHS = "Mastodon/Resources/Preview\\ Assets.xcassets";
DEVELOPMENT_TEAM = 5Z4GVSS33P; DEVELOPMENT_TEAM = 5Z4GVSS33P;
INFOPLIST_FILE = Mastodon/Info.plist; INFOPLIST_FILE = Mastodon/Info.plist;
@ -4506,7 +4506,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 0.8.10; MARKETING_VERSION = 0.8.11;
PRODUCT_BUNDLE_IDENTIFIER = org.joinmastodon.app; PRODUCT_BUNDLE_IDENTIFIER = org.joinmastodon.app;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
@ -4612,7 +4612,7 @@
buildSettings = { buildSettings = {
CODE_SIGN_ENTITLEMENTS = NotificationService/NotificationService.entitlements; CODE_SIGN_ENTITLEMENTS = NotificationService/NotificationService.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 36; CURRENT_PROJECT_VERSION = 37;
DEVELOPMENT_TEAM = 5Z4GVSS33P; DEVELOPMENT_TEAM = 5Z4GVSS33P;
INFOPLIST_FILE = NotificationService/Info.plist; INFOPLIST_FILE = NotificationService/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
@ -4620,7 +4620,7 @@
"@executable_path/Frameworks", "@executable_path/Frameworks",
"@executable_path/../../Frameworks", "@executable_path/../../Frameworks",
); );
MARKETING_VERSION = 0.8.10; MARKETING_VERSION = 0.8.11;
PRODUCT_BUNDLE_IDENTIFIER = org.joinmastodon.app.NotificationService; PRODUCT_BUNDLE_IDENTIFIER = org.joinmastodon.app.NotificationService;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
@ -4666,7 +4666,7 @@
buildSettings = { buildSettings = {
CODE_SIGN_ENTITLEMENTS = NotificationService/NotificationService.entitlements; CODE_SIGN_ENTITLEMENTS = NotificationService/NotificationService.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 36; CURRENT_PROJECT_VERSION = 37;
DEVELOPMENT_TEAM = 5Z4GVSS33P; DEVELOPMENT_TEAM = 5Z4GVSS33P;
INFOPLIST_FILE = NotificationService/Info.plist; INFOPLIST_FILE = NotificationService/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
@ -4674,7 +4674,7 @@
"@executable_path/Frameworks", "@executable_path/Frameworks",
"@executable_path/../../Frameworks", "@executable_path/../../Frameworks",
); );
MARKETING_VERSION = 0.8.10; MARKETING_VERSION = 0.8.11;
PRODUCT_BUNDLE_IDENTIFIER = org.joinmastodon.app.NotificationService; PRODUCT_BUNDLE_IDENTIFIER = org.joinmastodon.app.NotificationService;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
@ -4689,7 +4689,7 @@
buildSettings = { buildSettings = {
CODE_SIGN_ENTITLEMENTS = NotificationService/NotificationService.entitlements; CODE_SIGN_ENTITLEMENTS = NotificationService/NotificationService.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 36; CURRENT_PROJECT_VERSION = 37;
DEVELOPMENT_TEAM = 5Z4GVSS33P; DEVELOPMENT_TEAM = 5Z4GVSS33P;
INFOPLIST_FILE = NotificationService/Info.plist; INFOPLIST_FILE = NotificationService/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
@ -4697,7 +4697,7 @@
"@executable_path/Frameworks", "@executable_path/Frameworks",
"@executable_path/../../Frameworks", "@executable_path/../../Frameworks",
); );
MARKETING_VERSION = 0.8.10; MARKETING_VERSION = 0.8.11;
PRODUCT_BUNDLE_IDENTIFIER = org.joinmastodon.app.NotificationService; PRODUCT_BUNDLE_IDENTIFIER = org.joinmastodon.app.NotificationService;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES; SKIP_INSTALL = YES;

View File

@ -30,7 +30,8 @@ extension NotificationSection {
guard let dependency = dependency else { return nil } guard let dependency = dependency else { return nil }
switch notificationItem { switch notificationItem {
case .notification(let objectID, let attribute): case .notification(let objectID, let attribute):
guard let notification = try? managedObjectContext.existingObject(with: objectID) as? MastodonNotification else { guard let notification = try? managedObjectContext.existingObject(with: objectID) as? MastodonNotification,
!notification.isDeleted else {
return UITableViewCell() return UITableViewCell()
} }
@ -38,21 +39,21 @@ extension NotificationSection {
cell.delegate = delegate cell.delegate = delegate
// configure author // configure author
cell.avatarImageViewTask = Nuke.loadImage( cell.configure(
with: notification.account.avatarImageURL(), with: AvatarConfigurableViewConfiguration(
options: ImageLoadingOptions( avatarImageURL: notification.account.avatarImageURL()
placeholder: UIImage.placeholder(color: .systemFill), )
transition: .fadeIn(duration: 0.2)
),
into: cell.avatarImageView
) )
cell.actionImageView.image = UIImage( cell.actionImageView.image = UIImage(
systemName: notification.notificationType.actionImageName, systemName: notification.notificationType.actionImageName,
withConfiguration: UIImage.SymbolConfiguration( withConfiguration: UIImage.SymbolConfiguration(
pointSize: 12, weight: .semibold pointSize: 12, weight: .semibold
) )
)?.withRenderingMode(.alwaysTemplate) )?
cell.actionImageBackground.backgroundColor = notification.notificationType.color .withRenderingMode(.alwaysTemplate)
.af.imageAspectScaled(toFit: CGSize(width: 14, height: 14))
cell.actionImageView.backgroundColor = notification.notificationType.color
// configure author name, notification description, timestamp // configure author name, notification description, timestamp
cell.nameLabel.configure(content: notification.account.displayNameWithFallback, emojiDict: notification.account.emojiDict) cell.nameLabel.configure(content: notification.account.displayNameWithFallback, emojiDict: notification.account.emojiDict)

View File

@ -188,8 +188,8 @@ extension StatusProviderFacade {
static func responseToStatusActiveLabelAction(provider: StatusProvider, node: ASCellNode, didSelectActiveEntityType type: ActiveEntityType) { static func responseToStatusActiveLabelAction(provider: StatusProvider, node: ASCellNode, didSelectActiveEntityType type: ActiveEntityType) {
switch type { switch type {
case .hashtag(let text, _): case .hashtag(let text, _):
let hashtagTimelienViewModel = HashtagTimelineViewModel(context: provider.context, hashtag: text) let hashtagTimelineViewModel = HashtagTimelineViewModel(context: provider.context, hashtag: text)
provider.coordinator.present(scene: .hashtagTimeline(viewModel: hashtagTimelienViewModel), from: provider, transition: .show) provider.coordinator.present(scene: .hashtagTimeline(viewModel: hashtagTimelineViewModel), from: provider, transition: .show)
case .mention(let text, _): case .mention(let text, _):
coordinateToStatusMentionProfileScene(for: .primary, provider: provider, node: node, mention: text) coordinateToStatusMentionProfileScene(for: .primary, provider: provider, node: node, mention: text)
case .url(_, _, let url, _): case .url(_, _, let url, _):
@ -212,7 +212,7 @@ extension StatusProviderFacade {
private static func coordinateToStatusMentionProfileScene(for target: Target, provider: StatusProvider, node: ASCellNode, mention: String) { private static func coordinateToStatusMentionProfileScene(for target: Target, provider: StatusProvider, node: ASCellNode, mention: String) {
guard let status = provider.status(node: node, indexPath: nil) else { return } guard let status = provider.status(node: node, indexPath: nil) else { return }
coordinateToStatusMentionProfileScene(for: target, provider: provider, status: status, mention: mention) coordinateToStatusMentionProfileScene(for: target, provider: provider, status: status, mention: mention, href: nil)
} }
#endif #endif

View File

@ -198,32 +198,34 @@ extension NotificationViewController {
// MARK: - StatusTableViewControllerAspect // MARK: - StatusTableViewControllerAspect
extension NotificationViewController: StatusTableViewControllerAspect { } extension NotificationViewController: StatusTableViewControllerAspect { }
// MARK: - TableViewCellHeightCacheableContainer extension NotificationViewController {
extension NotificationViewController: TableViewCellHeightCacheableContainer {
var cellFrameCache: NSCache<NSNumber, NSValue> {
viewModel.cellFrameCache
}
func cacheTableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath) { func cacheTableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath) {
guard let diffableDataSource = viewModel.diffableDataSource else { return } guard let diffableDataSource = viewModel.diffableDataSource else { return }
guard let item = diffableDataSource.itemIdentifier(for: indexPath) else { return } guard let item = diffableDataSource.itemIdentifier(for: indexPath) else { return }
let key = item.hashValue switch item {
let frame = cell.frame case .notification(let objectID, _):
viewModel.cellFrameCache.setObject(NSValue(cgRect: frame), forKey: NSNumber(value: key)) guard let object = try? viewModel.fetchedResultsController.managedObjectContext.existingObject(with: objectID) as? MastodonNotification else { return }
let key = object.id as NSString
let frame = cell.frame
viewModel.cellFrameCache.setObject(NSValue(cgRect: frame), forKey: key)
case .bottomLoader:
break
}
} }
func handleTableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { func handleTableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
guard let diffableDataSource = viewModel.diffableDataSource else { return UITableView.automaticDimension } guard let diffableDataSource = viewModel.diffableDataSource else { return UITableView.automaticDimension }
guard let item = diffableDataSource.itemIdentifier(for: indexPath) else { return UITableView.automaticDimension } guard let item = diffableDataSource.itemIdentifier(for: indexPath) else { return UITableView.automaticDimension }
guard let frame = viewModel.cellFrameCache.object(forKey: NSNumber(value: item.hashValue))?.cgRectValue else { switch item {
if case .bottomLoader = item { case .notification(let objectID, _):
return TimelineLoaderTableViewCell.cellHeight guard let object = try? viewModel.fetchedResultsController.managedObjectContext.existingObject(with: objectID) as? MastodonNotification else { return UITableView.automaticDimension }
} else { let key = object.id as NSString
return UITableView.automaticDimension guard let frame = viewModel.cellFrameCache.object(forKey: key)?.cgRectValue else { return UITableView.automaticDimension }
} return frame.height
case .bottomLoader:
return TimelineLoaderTableViewCell.cellHeight
} }
return ceil(frame.height)
} }
} }
@ -237,6 +239,14 @@ extension NotificationViewController: UITableViewDelegate {
open(item: item) open(item: item)
} }
func tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath) {
cacheTableView(tableView, didEndDisplaying: cell, forRowAt: indexPath)
}
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return handleTableView(tableView, estimatedHeightForRowAt: indexPath)
}
} }
extension NotificationViewController { extension NotificationViewController {

View File

@ -19,7 +19,7 @@ extension NotificationViewModel {
) { ) {
diffableDataSource = NotificationSection.tableViewDiffableDataSource( diffableDataSource = NotificationSection.tableViewDiffableDataSource(
for: tableView, for: tableView,
managedObjectContext: context.managedObjectContext, managedObjectContext: fetchedResultsController.managedObjectContext,
delegate: delegate, delegate: delegate,
dependency: dependency dependency: dependency
) )

View File

@ -71,43 +71,44 @@ extension NotificationViewModel.LoadOldestState {
sinceID: nil, sinceID: nil,
minID: nil, minID: nil,
limit: nil, limit: nil,
excludeTypes: [.followRequest], excludeTypes: [],
accountID: nil) accountID: nil
)
viewModel.context.apiService.allNotifications( viewModel.context.apiService.allNotifications(
domain: activeMastodonAuthenticationBox.domain, domain: activeMastodonAuthenticationBox.domain,
query: query, query: query,
mastodonAuthenticationBox: activeMastodonAuthenticationBox mastodonAuthenticationBox: activeMastodonAuthenticationBox
) )
.sink { completion in .sink { completion in
switch completion { switch completion {
case .failure(let error): case .failure(let error):
os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: fetch notification failed. %s", (#file as NSString).lastPathComponent, #line, #function, error.localizedDescription) os_log(.info, log: .debug, "%{public}s[%{public}ld], %{public}s: fetch notification failed. %s", (#file as NSString).lastPathComponent, #line, #function, error.localizedDescription)
case .finished: case .finished:
// handle isFetchingLatestTimeline in fetch controller delegate // handle isFetchingLatestTimeline in fetch controller delegate
break break
}
stateMachine.enter(Idle.self)
} receiveValue: { [weak viewModel] response in
guard let viewModel = viewModel else { return }
switch viewModel.selectedIndex.value {
case .EveryThing:
if response.value.isEmpty {
stateMachine.enter(NoMore.self)
} else {
stateMachine.enter(Idle.self)
} }
case .Mentions:
stateMachine.enter(Idle.self) viewModel.noMoreNotification.value = response.value.isEmpty
} receiveValue: { [weak viewModel] response in let list = response.value.filter { $0.type == Mastodon.Entity.Notification.NotificationType.mention }
guard let viewModel = viewModel else { return } if list.isEmpty {
switch viewModel.selectedIndex.value { stateMachine.enter(NoMore.self)
case .EveryThing: } else {
if response.value.isEmpty { stateMachine.enter(Idle.self)
stateMachine.enter(NoMore.self)
} else {
stateMachine.enter(Idle.self)
}
case .Mentions:
viewModel.noMoreNotification.value = response.value.isEmpty
let list = response.value.filter { $0.type == Mastodon.Entity.Notification.NotificationType.mention }
if list.isEmpty {
stateMachine.enter(NoMore.self)
} else {
stateMachine.enter(Idle.self)
}
} }
} }
.store(in: &viewModel.disposeBag) }
.store(in: &viewModel.disposeBag)
} }
} }

View File

@ -29,7 +29,7 @@ final class NotificationViewModel: NSObject {
let activeMastodonAuthenticationBox: CurrentValueSubject<AuthenticationService.MastodonAuthenticationBox?, Never> let activeMastodonAuthenticationBox: CurrentValueSubject<AuthenticationService.MastodonAuthenticationBox?, Never>
let fetchedResultsController: NSFetchedResultsController<MastodonNotification>! let fetchedResultsController: NSFetchedResultsController<MastodonNotification>!
let notificationPredicate = CurrentValueSubject<NSPredicate?, Never>(nil) let notificationPredicate = CurrentValueSubject<NSPredicate?, Never>(nil)
let cellFrameCache = NSCache<NSNumber, NSValue>() let cellFrameCache = NSCache<NSString, NSValue>()
var needsScrollToTopAfterDataSourceUpdate = false var needsScrollToTopAfterDataSourceUpdate = false
let dataSourceDidUpdated = PassthroughSubject<Void, Never>() let dataSourceDidUpdated = PassthroughSubject<Void, Never>()
@ -75,6 +75,7 @@ final class NotificationViewModel: NSObject {
self.fetchedResultsController = { self.fetchedResultsController = {
let fetchRequest = MastodonNotification.sortedFetchRequest let fetchRequest = MastodonNotification.sortedFetchRequest
fetchRequest.returnsObjectsAsFaults = false fetchRequest.returnsObjectsAsFaults = false
fetchRequest.fetchBatchSize = 10
fetchRequest.relationshipKeyPathsForPrefetching = [#keyPath(MastodonNotification.status), #keyPath(MastodonNotification.account)] fetchRequest.relationshipKeyPathsForPrefetching = [#keyPath(MastodonNotification.status), #keyPath(MastodonNotification.account)]
let controller = NSFetchedResultsController( let controller = NSFetchedResultsController(
fetchRequest: fetchRequest, fetchRequest: fetchRequest,

View File

@ -37,6 +37,7 @@ final class NotificationStatusTableViewCell: UITableViewCell, StatusCell {
static let actionImageBorderWidth: CGFloat = 2 static let actionImageBorderWidth: CGFloat = 2
static let statusPadding = UIEdgeInsets(top: 50, left: 73, bottom: 24, right: 24) static let statusPadding = UIEdgeInsets(top: 50, left: 73, bottom: 24, right: 24)
static let actionImageViewSize = CGSize(width: 24, height: 24)
var disposeBag = Set<AnyCancellable>() var disposeBag = Set<AnyCancellable>()
var pollCountdownSubscription: AnyCancellable? var pollCountdownSubscription: AnyCancellable?
@ -45,32 +46,26 @@ final class NotificationStatusTableViewCell: UITableViewCell, StatusCell {
var containerStackViewBottomLayoutConstraint: NSLayoutConstraint! var containerStackViewBottomLayoutConstraint: NSLayoutConstraint!
let containerStackView = UIStackView() let containerStackView = UIStackView()
var avatarImageViewTask: ImageTask?
let avatarImageView: UIImageView = { let avatarImageView: UIImageView = {
let imageView = FLAnimatedImageView() let imageView = FLAnimatedImageView()
imageView.layer.cornerRadius = 4
imageView.layer.cornerCurve = .continuous
imageView.clipsToBounds = true
return imageView return imageView
}() }()
let actionImageView: UIImageView = { let actionImageView: UIImageView = {
let imageView = UIImageView() let imageView = UIImageView()
imageView.contentMode = .center
imageView.tintColor = Asset.Colors.Background.systemBackground.color imageView.tintColor = Asset.Colors.Background.systemBackground.color
imageView.isOpaque = true
imageView.layer.masksToBounds = true
imageView.layer.cornerRadius = NotificationStatusTableViewCell.actionImageViewSize.width * 0.5
imageView.layer.cornerCurve = .circular
imageView.layer.borderWidth = NotificationStatusTableViewCell.actionImageBorderWidth
imageView.layer.borderColor = Asset.Colors.Background.systemBackground.color.cgColor
imageView.layer.shouldRasterize = true
imageView.layer.rasterizationScale = UIScreen.main.scale
return imageView return imageView
}() }()
let actionImageBackground: UIView = {
let view = UIView()
view.layer.cornerRadius = (24 + NotificationStatusTableViewCell.actionImageBorderWidth) / 2
view.layer.cornerCurve = .continuous
view.clipsToBounds = true
view.layer.borderWidth = NotificationStatusTableViewCell.actionImageBorderWidth
view.layer.borderColor = Asset.Colors.Background.systemBackground.color.cgColor
view.tintColor = Asset.Colors.Background.systemBackground.color
return view
}()
let avatarContainer: UIView = { let avatarContainer: UIView = {
let view = UIView() let view = UIView()
return view return view
@ -148,8 +143,6 @@ final class NotificationStatusTableViewCell: UITableViewCell, StatusCell {
override func prepareForReuse() { override func prepareForReuse() {
super.prepareForReuse() super.prepareForReuse()
isFiltered = false isFiltered = false
avatarImageViewTask?.cancel()
avatarImageViewTask = nil
statusView.updateContentWarningDisplay(isHidden: true, animated: false) statusView.updateContentWarningDisplay(isHidden: true, animated: false)
statusView.pollTableView.dataSource = nil statusView.pollTableView.dataSource = nil
statusView.playerContainerView.reset() statusView.playerContainerView.reset()
@ -199,20 +192,13 @@ extension NotificationStatusTableViewCell {
avatarImageView.widthAnchor.constraint(equalToConstant: 35).priority(.required - 1), avatarImageView.widthAnchor.constraint(equalToConstant: 35).priority(.required - 1),
]) ])
actionImageBackground.translatesAutoresizingMaskIntoConstraints = false
avatarContainer.addSubview(actionImageBackground)
NSLayoutConstraint.activate([
actionImageBackground.heightAnchor.constraint(equalToConstant: 24 + NotificationStatusTableViewCell.actionImageBorderWidth).priority(.required - 1),
actionImageBackground.widthAnchor.constraint(equalToConstant: 24 + NotificationStatusTableViewCell.actionImageBorderWidth).priority(.required - 1),
actionImageBackground.centerYAnchor.constraint(equalTo: avatarImageView.bottomAnchor),
actionImageBackground.centerXAnchor.constraint(equalTo: avatarContainer.trailingAnchor),
])
actionImageView.translatesAutoresizingMaskIntoConstraints = false actionImageView.translatesAutoresizingMaskIntoConstraints = false
actionImageBackground.addSubview(actionImageView) avatarContainer.addSubview(actionImageView)
NSLayoutConstraint.activate([ NSLayoutConstraint.activate([
actionImageView.centerXAnchor.constraint(equalTo: actionImageBackground.centerXAnchor), actionImageView.centerYAnchor.constraint(equalTo: avatarContainer.bottomAnchor),
actionImageView.centerYAnchor.constraint(equalTo: actionImageBackground.centerYAnchor), actionImageView.centerXAnchor.constraint(equalTo: avatarContainer.trailingAnchor),
actionImageView.widthAnchor.constraint(equalToConstant: NotificationStatusTableViewCell.actionImageViewSize.width),
actionImageView.heightAnchor.constraint(equalToConstant: NotificationStatusTableViewCell.actionImageViewSize.height),
]) ])
containerStackView.addArrangedSubview(contentStackView) containerStackView.addArrangedSubview(contentStackView)
@ -302,7 +288,7 @@ extension NotificationStatusTableViewCell {
super.traitCollectionDidChange(previousTraitCollection) super.traitCollectionDidChange(previousTraitCollection)
resetSeparatorLineLayout() resetSeparatorLineLayout()
actionImageBackground.layer.borderColor = Asset.Colors.Background.systemBackground.color.cgColor avatarImageView.layer.borderColor = Asset.Colors.Background.systemBackground.color.cgColor
statusContainerView.layer.borderColor = Asset.Colors.Border.notificationStatus.color.cgColor statusContainerView.layer.borderColor = Asset.Colors.Border.notificationStatus.color.cgColor
} }
@ -405,3 +391,11 @@ extension NotificationStatusTableViewCell {
} }
} }
// MARK: - AvatarConfigurableView
extension NotificationStatusTableViewCell: AvatarConfigurableView {
static var configurableAvatarImageSize: CGSize { CGSize(width: 35, height: 35) }
static var configurableAvatarImageCornerRadius: CGFloat { 4 }
var configurableAvatarImageView: UIImageView? { avatarImageView }
var configurableAvatarButton: UIButton? { nil }
}

View File

@ -152,6 +152,7 @@ final class StatusView: UIView {
let pollTableView: PollTableView = { let pollTableView: PollTableView = {
let tableView = PollTableView(frame: CGRect(x: 0, y: 0, width: 100, height: 100)) let tableView = PollTableView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
tableView.register(PollOptionTableViewCell.self, forCellReuseIdentifier: String(describing: PollOptionTableViewCell.self)) tableView.register(PollOptionTableViewCell.self, forCellReuseIdentifier: String(describing: PollOptionTableViewCell.self))
tableView.rowHeight = PollOptionView.height
tableView.isScrollEnabled = false tableView.isScrollEnabled = false
tableView.separatorStyle = .none tableView.separatorStyle = .none
tableView.backgroundColor = .clear tableView.backgroundColor = .clear
@ -450,7 +451,7 @@ extension StatusView {
// action toolbar container // action toolbar container
containerStackView.addArrangedSubview(actionToolbarContainer) containerStackView.addArrangedSubview(actionToolbarContainer)
containerStackView.sendSubviewToBack(actionToolbarContainer) containerStackView.sendSubviewToBack(actionToolbarContainer)
actionToolbarContainer.setContentCompressionResistancePriority(.defaultLow, for: .vertical) actionToolbarContainer.setContentCompressionResistancePriority(.defaultHigh, for: .vertical)
actionToolbarContainer.setContentHuggingPriority(.required - 1, for: .vertical) actionToolbarContainer.setContentHuggingPriority(.required - 1, for: .vertical)
headerContainerView.isHidden = true headerContainerView.isHidden = true

View File

@ -192,7 +192,10 @@ final class StatusNode: ASCellNode {
} }
verticalStack.children = verticalStackChildren verticalStack.children = verticalStackChildren
return verticalStack return ASInsetLayoutSpec(
insets: UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16),
child: verticalStack
)
} }
} }
@ -230,7 +233,7 @@ extension StatusNode: ASMultiplexImageNodeDataSource {
case "url" as NSString: case "url" as NSString:
return meta.url return meta.url
case "previewURL" as NSString: case "previewURL" as NSString:
return meta.priviewURL return meta.previewURL
default: default:
assertionFailure() assertionFailure()
return nil return nil