//
//  ConversationsManager.swift
//  Drift
//
//  Created by Brian McDonald on 08/06/2017.
//  Copyright © 2017 Drift. All rights reserved.
//

import Foundation

class ConversationsManager {
    
    class func checkForConversations(userId: Int) {
        DriftAPIManager.getEnrichedConversations(userId) { (result) in
            switch result {
            case .success(let conversations):
                let conversationsToShow = conversations.filter({$0.unreadMessages > 0})
                PresentationManager.sharedInstance.didRecieveNewMessages(conversationsToShow)
            case .failure(let error):
                LoggerManager.didRecieveError(error)
            }
        }
    }
    
    class func markMessageAsRead(_ messageId: Int) {
        DriftAPIManager.markConversationAsRead(messageId: messageId) { (result) in
            switch result {
            case .success:
                LoggerManager.log("Successfully marked Message Read: \(messageId)")
            case .failure(let error):
                LoggerManager.didRecieveError(error)
            }
        }
    }

}

//
//  ConversationsManager.swift
//  Drift
//
//  Created by Brian McDonald on 08/06/2017.
//  Copyright © 2017 Drift. All rights reserved.
//

import Foundation

class ConversationsManager {
    
    class func checkForConversations(userId: Int) {
        DriftAPIManager.getEnrichedConversations(userId) { (result) in
            switch result {
            case .success(let conversations):
                let conversationsToShow = conversations.filter({$0.unreadMessages > 0})
                PresentationManager.sharedInstance.didRecieveNewMessages(conversationsToShow)
            case .failure(let error):
                LoggerManager.didRecieveError(error)
            }
        }
    }
    
    class func markMessageAsRead(_ messageId: Int) {
        DriftAPIManager.markMessageAsRead(messageId: messageId) { (result) in
            switch result {
            case .success:
                LoggerManager.log("Successfully marked Message Read: \(messageId)")
            case .failure(let error):
                LoggerManager.didRecieveError(error)
            }
        }
    }

}

--- 
+++ 
@@ -23,7 +23,7 @@
     }
     
     class func markMessageAsRead(_ messageId: Int) {
-        DriftAPIManager.markMessageAsRead(messageId: messageId) { (result) in
+        DriftAPIManager.markConversationAsRead(messageId: messageId) { (result) in
             switch result {
             case .success:
                 LoggerManager.log("Successfully marked Message Read: \(messageId)")
Mark conversations as read rather than a single message at a time
