//
//  UserActivityType.swift
//  Tusker
//
//  Created by Shadowfacts on 10/19/18.
//  Copyright © 2018 Shadowfacts. All rights reserved.
//

import Foundation

enum UserActivityType: String {
    case mainScene = "space.vaccor.Tusker.activity.main-scene"
    case newPost = "space.vaccor.Tusker.activity.new-post"
    case checkNotifications = "space.vaccor.Tusker.activity.check-notifications"
    case showTimeline = "space.vaccor.Tusker.activity.show-timeline"
    case search = "space.vaccor.Tusker.activity.search"
    case bookmarks = "space.vaccor.Tusker.activity.bookmarks"
    case showConversation = "space.vaccor.Tusker.activity.show-conversation"
    case myProfile = "space.vaccor.Tusker.activity.my-profile"
    case showProfile = "space.vaccor.Tusker.activity.show-profile"
}

extension UserActivityType {
    @MainActor
    var handle: (UserActivityManager) -> @MainActor (NSUserActivity) -> Void {
        switch self {
        case .mainScene:
            fatalError("cannot handle main scene activity")
        case .newPost:
            return UserActivityManager.handleNewPost
        case .checkNotifications:
            return UserActivityManager.handleCheckNotifications
        case .showTimeline:
            return UserActivityManager.handleShowTimeline
        case .search:
            return UserActivityManager.handleSearch
        case .bookmarks:
            return UserActivityManager.handleBookmarks
        case .showConversation:
            return UserActivityManager.handleShowConversation
        case .myProfile:
            return UserActivityManager.handleMyProfile
        case .showProfile:
            return UserActivityManager.handleShowProfile
        }
    }
}
