2019-09-05 16:49:17 +00:00
|
|
|
//
|
|
|
|
// 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)
|
2020-01-05 20:25:07 +00:00
|
|
|
mastodonController.run(request) { (response) in
|
2020-10-12 22:20:57 +00:00
|
|
|
switch response {
|
|
|
|
case .failure(_):
|
2019-09-05 16:49:17 +00:00
|
|
|
// todo: display error message
|
|
|
|
UINotificationFeedbackGenerator().notificationOccurred(.error)
|
|
|
|
fatalError()
|
2020-10-12 22:20:57 +00:00
|
|
|
case let .success(relationship, _):
|
|
|
|
self.mastodonController.persistentContainer.addOrUpdate(relationship: relationship)
|
2019-09-05 16:49:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|