Skip to content
Snippets Groups Projects
Commit 30292513 authored by Bruno Muniz's avatar Bruno Muniz :apple:
Browse files

Show ban warning after fetching/processing banned list

parent 88f47a45
No related branches found
No related tags found
3 merge requests!71Releasing v1.1.5 (214),!69Implemented filtering for banned/blocked users and reporting,!67v1.1.5 b(203)
......@@ -8,6 +8,7 @@ import Keychain
import Foundation
import Integration
import Permissions
import ToastFeature
import DropboxFeature
import VersionChecking
import ReportingFeature
......@@ -36,6 +37,7 @@ final class LaunchViewModel {
@Dependency private var permissionHandler: PermissionHandling
@Dependency private var fetchBannedList: FetchBannedList
@Dependency private var processBannedList: ProcessBannedList
@Dependency private var toastController: ToastController
@Dependency private var session: SessionType
@KeyObject(.username, defaultValue: nil) var username: String?
......@@ -224,6 +226,7 @@ final class LaunchViewModel {
if contact.isBanned == false {
contact.isBanned = true
try! self.session.dbManager.saveContact(contact)
self.enqueueBanWarning(contact: contact)
}
} else {
try! self.session.dbManager.saveContact(.init(id: userId, isBanned: true))
......@@ -246,4 +249,12 @@ final class LaunchViewModel {
}
)
}
private func enqueueBanWarning(contact: Contact) {
let name = (contact.nickname ?? contact.username) ?? "One of your contacts"
toastController.enqueueToast(model: .init(
title: "\(name) has been banned for offensive content.",
leftImage: Asset.requestSentToaster.image
))
}
}
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment