-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathContentReportVC.swift
58 lines (49 loc) · 1.8 KB
/
ContentReportVC.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// PostReportVC.swift
// Commun
//
// Created by Chung Tran on 11/25/19.
// Copyright © 2019 Commun Limited. All rights reserved.
//
import Foundation
import CyberSwift
import RxSwift
class ContentReportVC<T: ResponseAPIContentMessageType>: ReportVC {
// MARK: - Properties
let content: T
// MARK: - Initializers
init(content: T) {
self.content = content
super.init()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - Methods
override func sendButtonDidTouch() {
guard checkValues(),
let communityId = content.community?.communityId,
let authorId = content.author?.userId
else {
return
}
let permlink = content.contentId.permlink
showIndetermineHudWithMessage("reporting".localized().uppercaseFirst + "...")
// modify text
let otherReason = self.otherReason?.trimmed.replacingOccurrences(of: "\n", with: " ")
BlockchainManager.instance.report(communityID: communityId, autorID: authorId, permlink: permlink, reasons: choosedReasons, message: otherReason)
// .observeOn(MainScheduler.instance)
.subscribe(onSuccess: { (_) in
self.hideHud()
self.showAlert(title: "thank you for reporting this post".localized().uppercaseFirst, message: "we have flagged this post for investigation".localized().uppercaseFirst) { _ in
self.dismiss(animated: true) {
self.content.notifyDeleted()
}
}
}) { (error) in
self.hideHud()
self.showError(error)
}
.disposed(by: disposeBag)
}
}