fix: profile block state i18n strings not set with name issue. resolve #171

This commit is contained in:
CMK 2021-06-24 14:32:01 +08:00
parent 27f569f14e
commit 4af2c0ca78
8 changed files with 61 additions and 24 deletions

View File

@ -183,8 +183,10 @@
},
"header": {
"no_status_found": "No Status Found",
"blocking_warning": "You cant view Artbots profile\n until you unblock them.\nYour account looks like this to them.",
"blocked_warning": "You cant view Artbots profile\n until they unblock you.",
"blocking_warning": "You cant view this profile\n until you unblock them.\nYour account looks like this to them.",
"user_blocking_warning": "You cant view %s's profile\n until you unblock them.\nYour account looks like this to them.",
"blocked_warning": "You cant view thiss profile\n until they unblock you.",
"user_blocked_warning": "You cant view %ss profile\n until they unblock you.",
"suspended_warning": "This account has been suspended.",
"user_suspended_warning": "%ss account has been suspended."
},

View File

@ -12,7 +12,7 @@
<key>CoreDataStack.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>20</integer>
<integer>21</integer>
</dict>
<key>Mastodon - ASDK.xcscheme_^#shared#^_</key>
<dict>
@ -37,7 +37,7 @@
<key>NotificationService.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>21</integer>
<integer>20</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>

View File

@ -62,15 +62,15 @@ extension Item {
enum Reason: Equatable {
case noStatusFound
case blocking
case blocked
case blocking(name: String?)
case blocked(name: String?)
case suspended(name: String?)
static func == (lhs: Item.EmptyStateHeaderAttribute.Reason, rhs: Item.EmptyStateHeaderAttribute.Reason) -> Bool {
switch (lhs, rhs) {
case (.noStatusFound, noStatusFound): return true
case (.blocking, blocking): return true
case (.blocked, blocked): return true
case (.blocking(let nameLeft), blocking(let nameRight)): return nameLeft == nameRight
case (.blocked(let nameLeft), blocked(let nameRight)): return nameLeft == nameRight
case (.suspended(let nameLeft), .suspended(let nameRight)): return nameLeft == nameRight
default: return false
}

View File

@ -355,14 +355,22 @@ internal enum L10n {
}
}
internal enum Header {
/// You cant view Artbots profile\n until they unblock you.
/// You cant view thiss profile\n until they unblock you.
internal static let blockedWarning = L10n.tr("Localizable", "Common.Controls.Timeline.Header.BlockedWarning")
/// You cant view Artbots profile\n until you unblock them.\nYour account looks like this to them.
/// You cant view this profile\n until you unblock them.\nYour account looks like this to them.
internal static let blockingWarning = L10n.tr("Localizable", "Common.Controls.Timeline.Header.BlockingWarning")
/// No Status Found
internal static let noStatusFound = L10n.tr("Localizable", "Common.Controls.Timeline.Header.NoStatusFound")
/// This account has been suspended.
internal static let suspendedWarning = L10n.tr("Localizable", "Common.Controls.Timeline.Header.SuspendedWarning")
/// You cant view %@s profile\n until they unblock you.
internal static func userBlockedWarning(_ p1: Any) -> String {
return L10n.tr("Localizable", "Common.Controls.Timeline.Header.UserBlockedWarning", String(describing: p1))
}
/// You cant view %@'s profile\n until you unblock them.\nYour account looks like this to them.
internal static func userBlockingWarning(_ p1: Any) -> String {
return L10n.tr("Localizable", "Common.Controls.Timeline.Header.UserBlockingWarning", String(describing: p1))
}
/// %@s account has been suspended.
internal static func userSuspendedWarning(_ p1: Any) -> String {
return L10n.tr("Localizable", "Common.Controls.Timeline.Header.UserSuspendedWarning", String(describing: p1))

View File

@ -120,13 +120,18 @@ Please check your internet connection.";
"Common.Controls.Timeline.Accessibility.CountFavorites" = "%@ favorites";
"Common.Controls.Timeline.Accessibility.CountReblogs" = "%@ reblogs";
"Common.Controls.Timeline.Accessibility.CountReplies" = "%@ replies";
"Common.Controls.Timeline.Header.BlockedWarning" = "You cant view Artbots profile
"Common.Controls.Timeline.Header.BlockedWarning" = "You cant view thiss profile
until they unblock you.";
"Common.Controls.Timeline.Header.BlockingWarning" = "You cant view Artbots profile
"Common.Controls.Timeline.Header.BlockingWarning" = "You cant view this profile
until you unblock them.
Your account looks like this to them.";
"Common.Controls.Timeline.Header.NoStatusFound" = "No Status Found";
"Common.Controls.Timeline.Header.SuspendedWarning" = "This account has been suspended.";
"Common.Controls.Timeline.Header.UserBlockedWarning" = "You cant view %@s profile
until they unblock you.";
"Common.Controls.Timeline.Header.UserBlockingWarning" = "You cant view %@'s profile
until you unblock them.
Your account looks like this to them.";
"Common.Controls.Timeline.Header.UserSuspendedWarning" = "%@s account has been suspended.";
"Common.Controls.Timeline.Loader.LoadMissingPosts" = "Load missing posts";
"Common.Controls.Timeline.Loader.LoadingMissingPosts" = "Loading missing posts...";

View File

@ -120,13 +120,18 @@ Please check your internet connection.";
"Common.Controls.Timeline.Accessibility.CountFavorites" = "%@ favorites";
"Common.Controls.Timeline.Accessibility.CountReblogs" = "%@ reblogs";
"Common.Controls.Timeline.Accessibility.CountReplies" = "%@ replies";
"Common.Controls.Timeline.Header.BlockedWarning" = "You cant view Artbots profile
"Common.Controls.Timeline.Header.BlockedWarning" = "You cant view thiss profile
until they unblock you.";
"Common.Controls.Timeline.Header.BlockingWarning" = "You cant view Artbots profile
"Common.Controls.Timeline.Header.BlockingWarning" = "You cant view this profile
until you unblock them.
Your account looks like this to them.";
"Common.Controls.Timeline.Header.NoStatusFound" = "No Status Found";
"Common.Controls.Timeline.Header.SuspendedWarning" = "This account has been suspended.";
"Common.Controls.Timeline.Header.UserBlockedWarning" = "You cant view %@s profile
until they unblock you.";
"Common.Controls.Timeline.Header.UserBlockingWarning" = "You cant view %@'s profile
until you unblock them.
Your account looks like this to them.";
"Common.Controls.Timeline.Header.UserSuspendedWarning" = "%@s account has been suspended.";
"Common.Controls.Timeline.Loader.LoadMissingPosts" = "Load missing posts";
"Common.Controls.Timeline.Loader.LoadingMissingPosts" = "Loading missing posts...";

View File

@ -82,19 +82,28 @@ final class UserTimelineViewModel {
diffableDataSource.apply(snapshot, animatingDifferences: !items.isEmpty)
}
let name = self.userDisplayName.value
guard !isBlocking else {
snapshot.appendItems([Item.emptyStateHeader(attribute: Item.EmptyStateHeaderAttribute(reason: .blocking))], toSection: .main)
snapshot.appendItems(
[Item.emptyStateHeader(attribute: Item.EmptyStateHeaderAttribute(reason: .blocking(name: name)))],
toSection: .main
)
return
}
guard !isBlockedBy else {
snapshot.appendItems([Item.emptyStateHeader(attribute: Item.EmptyStateHeaderAttribute(reason: .blocked))], toSection: .main)
snapshot.appendItems(
[Item.emptyStateHeader(attribute: Item.EmptyStateHeaderAttribute(reason: .blocked(name: name)))],
toSection: .main
)
return
}
let name = self.userDisplayName.value
guard !isSuspended else {
snapshot.appendItems([Item.emptyStateHeader(attribute: Item.EmptyStateHeaderAttribute(reason: .suspended(name: name)))], toSection: .main)
snapshot.appendItems(
[Item.emptyStateHeader(attribute: Item.EmptyStateHeaderAttribute(reason: .suspended(name: name)))],
toSection: .main
)
return
}

View File

@ -97,10 +97,18 @@ extension Item.EmptyStateHeaderAttribute.Reason {
switch self {
case .noStatusFound:
return L10n.Common.Controls.Timeline.Header.noStatusFound
case .blocking:
return L10n.Common.Controls.Timeline.Header.blockingWarning
case .blocked:
return L10n.Common.Controls.Timeline.Header.blockedWarning
case .blocking(let name):
if let name = name {
return L10n.Common.Controls.Timeline.Header.userBlockingWarning(name)
} else {
return L10n.Common.Controls.Timeline.Header.blockingWarning
}
case .blocked(let name):
if let name = name {
return L10n.Common.Controls.Timeline.Header.userBlockedWarning(name)
} else {
return L10n.Common.Controls.Timeline.Header.blockedWarning
}
case .suspended(let name):
if let name = name {
return L10n.Common.Controls.Timeline.Header.userSuspendedWarning(name)
@ -119,8 +127,8 @@ struct TimelineHeaderView_Previews: PreviewProvider {
Group {
UIViewPreview(width: 375) {
let headerView = TimelineHeaderView()
headerView.iconImageView.image = Item.EmptyStateHeaderAttribute.Reason.blocking.iconImage
headerView.messageLabel.text = Item.EmptyStateHeaderAttribute.Reason.blocking.message
headerView.iconImageView.image = Item.EmptyStateHeaderAttribute.Reason.blocking(name: nil).iconImage
headerView.messageLabel.text = Item.EmptyStateHeaderAttribute.Reason.blocking(name: nil).message
return headerView
}
.previewLayout(.fixed(width: 375, height: 400))