44 lines
1.2 KiB
Swift
44 lines
1.2 KiB
Swift
//
|
|
// FollowAccountActivity.swift
|
|
// Tusker
|
|
//
|
|
// Created by Shadowfacts on 9/5/19.
|
|
// Copyright © 2019 Shadowfacts. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import Pachyderm
|
|
|
|
class FollowAccountActivity: AccountActivity {
|
|
|
|
override var activityType: UIActivity.ActivityType? {
|
|
return .followAccount
|
|
}
|
|
|
|
override var activityTitle: String? {
|
|
return NSLocalizedString("Follow", comment: "follow account activity title")
|
|
}
|
|
override var activityImage: UIImage? {
|
|
return UIImage(systemName: "person.badge.plus")
|
|
}
|
|
|
|
override func perform() {
|
|
guard let account = account else { return }
|
|
|
|
UIImpactFeedbackGenerator(style: .medium).impactOccurred()
|
|
|
|
let request = Account.follow(account.id)
|
|
mastodonController.run(request) { (response) in
|
|
switch response {
|
|
case .failure(_):
|
|
// todo: display error message
|
|
UINotificationFeedbackGenerator().notificationOccurred(.error)
|
|
fatalError()
|
|
case let .success(relationship, _):
|
|
self.mastodonController.persistentContainer.addOrUpdate(relationship: relationship)
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|