Show text on relationship-button based on relationship (IOS-192)
This commit is contained in:
parent
1b1274c2f7
commit
dda0ae2d7c
@ -150,10 +150,10 @@ extension Persistence.MastodonUser {
|
|||||||
relationship.requested.flatMap { user.update(isFollowRequested: $0, by: me) }
|
relationship.requested.flatMap { user.update(isFollowRequested: $0, by: me) }
|
||||||
// relationship.endorsed.flatMap { user.update(isEndorsed: $0, by: me) }
|
// relationship.endorsed.flatMap { user.update(isEndorsed: $0, by: me) }
|
||||||
me.update(isFollowing: relationship.followedBy, by: user)
|
me.update(isFollowing: relationship.followedBy, by: user)
|
||||||
relationship.muting.flatMap { user.update(isMuting: $0, by: me) }
|
user.update(isMuting: relationship.muting, by: me)
|
||||||
user.update(isBlocking: relationship.blocking, by: me)
|
user.update(isBlocking: relationship.blocking, by: me)
|
||||||
relationship.domainBlocking.flatMap { user.update(isDomainBlocking: $0, by: me) }
|
user.update(isDomainBlocking: relationship.domainBlocking, by: me)
|
||||||
relationship.blockedBy.flatMap { me.update(isBlocking: $0, by: user) }
|
me.update(isBlocking: relationship.blockedBy, by: user)
|
||||||
relationship.showingReblogs.flatMap { me.update(isShowingReblogs: $0, by: user) }
|
me.update(isShowingReblogs: relationship.showingReblogs, by: user)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ extension APIService {
|
|||||||
authorization: authenticationBox.userAuthorization
|
authorization: authenticationBox.userAuthorization
|
||||||
).singleOutput().value.first
|
).singleOutput().value.first
|
||||||
|
|
||||||
let oldShowReblogs = relationship?.showingReblogs == true
|
let oldShowReblogs = relationship?.showingReblogs ?? true
|
||||||
let newShowReblogs = (oldShowReblogs == false)
|
let newShowReblogs = (oldShowReblogs == false)
|
||||||
|
|
||||||
let response = try await Mastodon.API.Account.follow(
|
let response = try await Mastodon.API.Account.follow(
|
||||||
|
@ -73,7 +73,7 @@ extension APIService {
|
|||||||
let muteContext = MastodonMuteContext(
|
let muteContext = MastodonMuteContext(
|
||||||
targetUserID: account.id,
|
targetUserID: account.id,
|
||||||
targetUsername: account.username,
|
targetUsername: account.username,
|
||||||
isMuting: relationship.muting ?? false
|
isMuting: relationship.muting
|
||||||
)
|
)
|
||||||
|
|
||||||
let result: Result<Mastodon.Response.Content<Mastodon.Entity.Relationship>, Error>
|
let result: Result<Mastodon.Response.Content<Mastodon.Entity.Relationship>, Error>
|
||||||
|
@ -17,20 +17,31 @@ extension Mastodon.Entity {
|
|||||||
/// # Reference
|
/// # Reference
|
||||||
/// [Document](https://docs.joinmastodon.org/entities/relationship/)
|
/// [Document](https://docs.joinmastodon.org/entities/relationship/)
|
||||||
public struct Relationship: Codable, Sendable, Equatable, Hashable {
|
public struct Relationship: Codable, Sendable, Equatable, Hashable {
|
||||||
public typealias ID = String
|
/// The account ID
|
||||||
|
public let id: String
|
||||||
public let id: ID
|
/// Are you following this user?
|
||||||
public let following: Bool
|
public let following: Bool
|
||||||
|
/// Do you have a pending follow request for this user?
|
||||||
public let requested: Bool?
|
public let requested: Bool?
|
||||||
public let endorsed: Bool?
|
/// Are you featuring this user on your profile?
|
||||||
|
public let endorsed: Bool
|
||||||
|
/// Are you followed by this user?
|
||||||
public let followedBy: Bool
|
public let followedBy: Bool
|
||||||
public let muting: Bool?
|
/// Are you muting this user?
|
||||||
public let mutingNotifications: Bool?
|
public let muting: Bool
|
||||||
public let showingReblogs: Bool?
|
/// Are you muting notifications from this user?
|
||||||
public let notifying: Bool?
|
public let mutingNotifications: Bool
|
||||||
|
/// Are you receiving this user’s boosts in your home timeline?
|
||||||
|
public let showingReblogs: Bool
|
||||||
|
/// Have you enabled notifications for this user?
|
||||||
|
public let notifying: Bool
|
||||||
|
/// Are you blocking this user?
|
||||||
public let blocking: Bool
|
public let blocking: Bool
|
||||||
public let domainBlocking: Bool?
|
/// Are you blocking this user’s domain?
|
||||||
public let blockedBy: Bool?
|
public let domainBlocking: Bool
|
||||||
|
/// Is this user blocking you?
|
||||||
|
public let blockedBy: Bool
|
||||||
|
/// This user’s profile bio
|
||||||
public let note: String?
|
public let note: String?
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
|
@ -248,7 +248,7 @@ extension StatusView {
|
|||||||
).singleOutput().value {
|
).singleOutput().value {
|
||||||
guard let rel = relationship.first else { return }
|
guard let rel = relationship.first else { return }
|
||||||
DispatchQueue.main.async { [self] in
|
DispatchQueue.main.async { [self] in
|
||||||
viewModel.isMuting = rel.muting ?? false
|
viewModel.isMuting = rel.muting
|
||||||
viewModel.isBlocking = rel.blocking
|
viewModel.isBlocking = rel.blocking
|
||||||
viewModel.isFollowed = rel.followedBy
|
viewModel.isFollowed = rel.followedBy
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@ public extension UserView {
|
|||||||
buttonState = .none
|
buttonState = .none
|
||||||
} else if relationship.following {
|
} else if relationship.following {
|
||||||
buttonState = .unfollow
|
buttonState = .unfollow
|
||||||
} else if relationship.blocking || (relationship.domainBlocking ?? false) {
|
} else if relationship.blocking || relationship.domainBlocking {
|
||||||
buttonState = .blocked
|
buttonState = .blocked
|
||||||
} else if relationship.requested ?? false {
|
} else if relationship.requested ?? false {
|
||||||
buttonState = .pending
|
buttonState = .pending
|
||||||
|
@ -57,25 +57,37 @@ extension ProfileRelationshipActionButton {
|
|||||||
|
|
||||||
extension ProfileRelationshipActionButton {
|
extension ProfileRelationshipActionButton {
|
||||||
|
|
||||||
public func configure(relationship: Mastodon.Entity.Relationship, between user: Mastodon.Entity.Account, and me: Mastodon.Entity.Account, isEditing: Bool = false, isUpdating: Bool = false) {
|
public func configure(relationship: Mastodon.Entity.Relationship, between account: Mastodon.Entity.Account, and me: Mastodon.Entity.Account, isEditing: Bool = false, isUpdating: Bool = false) {
|
||||||
|
|
||||||
let isMyself = (user == me)
|
let isMyself = (account == me)
|
||||||
let title: String
|
let title: String
|
||||||
|
|
||||||
if isMyself {
|
if isMyself {
|
||||||
if isEditing {
|
if isEditing {
|
||||||
title = "SAVE"
|
title = L10n.Common.Controls.Actions.save
|
||||||
} else {
|
} else {
|
||||||
title = "EDIT"
|
title = L10n.Common.Controls.Friendship.editInfo
|
||||||
}
|
}
|
||||||
|
} else if relationship.blocking {
|
||||||
|
title = L10n.Common.Controls.Friendship.blocked
|
||||||
|
} else if relationship.domainBlocking {
|
||||||
|
#warning("Wait for #1198 (Domain Block, IOS-5) to be merged")
|
||||||
|
title = "Unblock domain"
|
||||||
|
} else if (relationship.requested ?? false) {
|
||||||
|
title = L10n.Common.Controls.Friendship.pending
|
||||||
|
} else if relationship.muting {
|
||||||
|
title = L10n.Common.Controls.Friendship.muted
|
||||||
} else if relationship.following {
|
} else if relationship.following {
|
||||||
title = L10n.Common.Controls.Friendship.follow
|
title = L10n.Common.Controls.Friendship.following
|
||||||
|
} else if account.locked {
|
||||||
|
title = L10n.Common.Controls.Friendship.request
|
||||||
} else {
|
} else {
|
||||||
title = "TITLE"
|
title = L10n.Common.Controls.Friendship.follow
|
||||||
}
|
}
|
||||||
|
|
||||||
setTitle(title, for: .normal)
|
setTitle(title, for: .normal)
|
||||||
|
|
||||||
if relationship.blocking || user.suspended ?? false {
|
if relationship.blocking || account.suspended ?? false {
|
||||||
isEnabled = false
|
isEnabled = false
|
||||||
} else {
|
} else {
|
||||||
isEnabled = true
|
isEnabled = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user