Tusker/Tusker/Activities/Account Activities/FollowAccountActivity.swift

40 lines
1.1 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).then { (relationship, _) -> Void in
self.mastodonController.cache.add(relationship: relationship)
}.catch { (error) -> Void in
print("could not follow account")
UINotificationFeedbackGenerator().notificationOccurred(.error)
}
}
}