pEpForiOS/UI/EmailDisplay/RatingReEvaluator.swift
author Dirk Zimmermann <dirk@pep-project.org>
Thu, 01 Feb 2018 11:29:01 +0100
changeset 3866 b5901734830a
parent 2922 72456bbb5fe6
permissions -rw-r--r--
IOS-915 logging to pinpoint the problem
     1 //
     2 //  RatingReEvaluator.swift
     3 //  pEpForiOS
     4 //
     5 //  Created by Dirk Zimmermann on 17/02/2017.
     6 //  Copyright © 2017 p≡p Security S.A. All rights reserved.
     7 //
     8 
     9 import UIKit
    10 
    11 import MessageModel
    12 
    13 public protocol RatingReEvaluatorDelegate: class {
    14     func ratingChanged(message: Message)
    15 }
    16 
    17 class RatingReEvaluator {
    18     let message: Message
    19     lazy var queue = LimitedOperationQueue()
    20     weak var delegate: RatingReEvaluatorDelegate?
    21     let parentName: String
    22 
    23     init(parentName: String = #function, message: Message) {
    24         self.parentName = parentName
    25         self.message = message
    26     }
    27 
    28     func reevaluateRating() {
    29         let op = ReevaluateMessageRatingOperation(parentName: parentName, message: message)
    30         op.completionBlock = {
    31             op.completionBlock = nil
    32             if !op.hasErrors() {
    33                 self.delegate?.ratingChanged(message: self.message)
    34             }
    35         }
    36         queue.addOperation(op)
    37     }
    38 }