40 lines
1.1 KiB
Swift
40 lines
1.1 KiB
Swift
//
|
|
// UnfollowActivity.swift
|
|
// Tusker
|
|
//
|
|
// Created by Shadowfacts on 9/5/19.
|
|
// Copyright © 2019 Shadowfacts. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import Pachyderm
|
|
|
|
class UnfollowAccountActivity: AccountActivity {
|
|
|
|
override var activityType: UIActivity.ActivityType? {
|
|
return .unfollowAccount
|
|
}
|
|
|
|
override var activityTitle: String? {
|
|
return NSLocalizedString("Unfollow", comment: "unfollow account activity title")
|
|
}
|
|
override var activityImage: UIImage? {
|
|
return UIImage(systemName: "person.badge.minus")
|
|
}
|
|
|
|
override func perform() {
|
|
guard let account = account else { return }
|
|
|
|
UIImpactFeedbackGenerator(style: .medium).impactOccurred()
|
|
|
|
let request = Account.unfollow(account.id)
|
|
mastodonController.run(request).then { (relationship, _) -> Void in
|
|
self.mastodonController.cache.add(relationship: relationship)
|
|
}.catch { (error) -> Void in
|
|
print("could not unfollow account: \(error)")
|
|
UINotificationFeedbackGenerator().notificationOccurred(.error)
|
|
}
|
|
}
|
|
|
|
}
|