Hide follow-button for myself

This commit is contained in:
Nathan Mattes 2023-10-24 12:45:24 +02:00
parent c597ee3039
commit ded7972f18
3 changed files with 20 additions and 8 deletions

View File

@ -29,13 +29,24 @@ extension UserSection {
tableView.register(TimelineBottomLoaderTableViewCell.self, forCellReuseIdentifier: String(describing: TimelineBottomLoaderTableViewCell.self))
tableView.register(TimelineFooterTableViewCell.self, forCellReuseIdentifier: String(describing: TimelineFooterTableViewCell.self))
return UITableViewDiffableDataSource(tableView: tableView) { tableView, indexPath, item -> UITableViewCell? in
return UITableViewDiffableDataSource(tableView: tableView) {
tableView,
indexPath,
item -> UITableViewCell? in
switch item {
case .account(let account, let relationship):
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: UserTableViewCell.self), for: indexPath) as! UserTableViewCell
guard let me = authContext.mastodonAuthenticationBox.authentication.user(in: context.managedObjectContext) else { return cell }
cell.userView.setButtonState(.loading)
cell.configure(tableView: tableView, account: account, relationship: relationship, delegate: userTableViewCellDelegate)
cell.configure(
me: me,
tableView: tableView,
account: account,
relationship: relationship,
delegate: userTableViewCellDelegate
)
return cell

View File

@ -14,7 +14,7 @@ import MastodonLocalization
extension UITableViewDelegate where Self: DataSourceProvider & AuthContextProvider {
func aspectTableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true )
tableView.deselectRow(at: indexPath, animated: true)
Task {
let source = DataSourceItem.Source(tableViewCell: nil, indexPath: indexPath)
guard let item = await item(from: source) else {

View File

@ -32,18 +32,20 @@ extension UserTableViewCell {
extension UserTableViewCell {
func configure(
me: MastodonUser? = nil,
me: MastodonUser,
tableView: UITableView,
account: Mastodon.Entity.Account,
relationship: Mastodon.Entity.Relationship?,
delegate: UserTableViewCellDelegate?
) {
//TODO: Implement
userView.configure(with: account)
let buttonState: UserView.ButtonState
if let relationship {
if relationship.following {
let isMe = account.id == me.id
if isMe {
buttonState = .none
} else if relationship.following {
buttonState = .unfollow
} else if relationship.blocking || (relationship.domainBlocking ?? false) {
buttonState = .blocked
@ -57,10 +59,9 @@ extension UserTableViewCell {
}
userView.setButtonState(buttonState)
}
//TODO: Duplicate
func configure(
me: MastodonUser? = nil,
tableView: UITableView,