Tusker/Tusker/Activities/Account Activities/UnfollowAccountActivity.swift

43 lines
1.2 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) { (response) in
if case let .success(relationship, _) = response {
self.mastodonController.cache.add(relationship: relationship)
} else {
// todo: display error message
UINotificationFeedbackGenerator().notificationOccurred(.error)
fatalError()
}
}
}
}