Hide follow-button for myself
This commit is contained in:
parent
c597ee3039
commit
ded7972f18
|
@ -29,13 +29,24 @@ extension UserSection {
|
||||||
tableView.register(TimelineBottomLoaderTableViewCell.self, forCellReuseIdentifier: String(describing: TimelineBottomLoaderTableViewCell.self))
|
tableView.register(TimelineBottomLoaderTableViewCell.self, forCellReuseIdentifier: String(describing: TimelineBottomLoaderTableViewCell.self))
|
||||||
tableView.register(TimelineFooterTableViewCell.self, forCellReuseIdentifier: String(describing: TimelineFooterTableViewCell.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 {
|
switch item {
|
||||||
case .account(let account, let relationship):
|
case .account(let account, let relationship):
|
||||||
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: UserTableViewCell.self), for: indexPath) as! UserTableViewCell
|
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.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
|
return cell
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import MastodonLocalization
|
||||||
extension UITableViewDelegate where Self: DataSourceProvider & AuthContextProvider {
|
extension UITableViewDelegate where Self: DataSourceProvider & AuthContextProvider {
|
||||||
|
|
||||||
func aspectTableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
func aspectTableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||||
tableView.deselectRow(at: indexPath, animated: true )
|
tableView.deselectRow(at: indexPath, animated: true)
|
||||||
Task {
|
Task {
|
||||||
let source = DataSourceItem.Source(tableViewCell: nil, indexPath: indexPath)
|
let source = DataSourceItem.Source(tableViewCell: nil, indexPath: indexPath)
|
||||||
guard let item = await item(from: source) else {
|
guard let item = await item(from: source) else {
|
||||||
|
|
|
@ -32,18 +32,20 @@ extension UserTableViewCell {
|
||||||
extension UserTableViewCell {
|
extension UserTableViewCell {
|
||||||
|
|
||||||
func configure(
|
func configure(
|
||||||
me: MastodonUser? = nil,
|
me: MastodonUser,
|
||||||
tableView: UITableView,
|
tableView: UITableView,
|
||||||
account: Mastodon.Entity.Account,
|
account: Mastodon.Entity.Account,
|
||||||
relationship: Mastodon.Entity.Relationship?,
|
relationship: Mastodon.Entity.Relationship?,
|
||||||
delegate: UserTableViewCellDelegate?
|
delegate: UserTableViewCellDelegate?
|
||||||
) {
|
) {
|
||||||
//TODO: Implement
|
|
||||||
userView.configure(with: account)
|
userView.configure(with: account)
|
||||||
|
|
||||||
let buttonState: UserView.ButtonState
|
let buttonState: UserView.ButtonState
|
||||||
if let relationship {
|
if let relationship {
|
||||||
if relationship.following {
|
let isMe = account.id == me.id
|
||||||
|
if isMe {
|
||||||
|
buttonState = .none
|
||||||
|
} else if relationship.following {
|
||||||
buttonState = .unfollow
|
buttonState = .unfollow
|
||||||
} else if relationship.blocking || (relationship.domainBlocking ?? false) {
|
} else if relationship.blocking || (relationship.domainBlocking ?? false) {
|
||||||
buttonState = .blocked
|
buttonState = .blocked
|
||||||
|
@ -57,10 +59,9 @@ extension UserTableViewCell {
|
||||||
}
|
}
|
||||||
|
|
||||||
userView.setButtonState(buttonState)
|
userView.setButtonState(buttonState)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO: Duplicate
|
|
||||||
func configure(
|
func configure(
|
||||||
me: MastodonUser? = nil,
|
me: MastodonUser? = nil,
|
||||||
tableView: UITableView,
|
tableView: UITableView,
|
||||||
|
|
Loading…
Reference in New Issue