forked from shadowfacts/Tusker
42 lines
1.1 KiB
Swift
42 lines
1.1 KiB
Swift
//
|
|
// BookmarkStatusActivity.swift
|
|
// Tusker
|
|
//
|
|
// Created by Shadowfacts on 12/14/19.
|
|
// Copyright © 2019 Shadowfacts. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import Pachyderm
|
|
|
|
class BookmarkStatusActivity: StatusActivity {
|
|
|
|
override var activityType: UIActivity.ActivityType? {
|
|
return .bookmarkStatus
|
|
}
|
|
|
|
override var activityTitle: String? {
|
|
return NSLocalizedString("Bookmark", comment: "bookmark status activity title")
|
|
}
|
|
|
|
override var activityImage: UIImage? {
|
|
return UIImage(systemName: "bookmark")
|
|
}
|
|
|
|
override func perform() {
|
|
guard let status = status else { return }
|
|
|
|
let request = Status.bookmark(status.id)
|
|
mastodonController.run(request) { (response) in
|
|
if case let .success(status, _) = response {
|
|
self.mastodonController.persistentContainer.addOrUpdate(status: status)
|
|
} else {
|
|
// todo: display error message
|
|
UINotificationFeedbackGenerator().notificationOccurred(.error)
|
|
fatalError()
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|