Skip to content

Commit 194806f

Browse files
Migrated Code From ALChannel to KMCoreChannel
1 parent 7818877 commit 194806f

10 files changed

+37
-37
lines changed

Example/Tests/ConversationVCNavBarSnapshotTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class ConversationVCNavBarSnapshotTests: QuickSpec, NavigationBarCallbacks {
2222
return alContact
2323
}()
2424

25-
let mockChannel: ALChannel = {
26-
let channel = ALChannel()
25+
let mockChannel: KMCoreChannel = {
26+
let channel = KMCoreChannel()
2727
channel.key = 1_244_444
2828
channel.name = "Demo Display Name"
2929
channel.type = Int16(SUPPORT_GROUP.rawValue)

Example/Tests/Mocks/ConversationDetailMock.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import KommunicateCore_iOS_SDK
1313
class ConversationDetailMock: ConversationDetail {
1414
var groupId: NSNumber!
1515

16-
override func updatedAssigneeDetails(groupId: NSNumber?, userId _: String?, completion: @escaping (ALContact?, ALChannel?) -> Void) {
16+
override func updatedAssigneeDetails(groupId: NSNumber?, userId _: String?, completion: @escaping (ALContact?, KMCoreChannel?) -> Void) {
1717
self.groupId = groupId
1818
completion(nil, nil)
1919
}

Sources/Kommunicate/Classes/ConversationDetail.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import Foundation
99
import KommunicateCore_iOS_SDK
1010

1111
class ConversationDetail {
12-
let channelService = ALChannelService()
12+
let channelService = KMCoreChannelService()
1313
let userService = ALUserService()
1414
let contactDbService = ALContactDBService()
15-
let channelDbService = ALChannelDBService()
15+
let channelDbService = KMCoreChannelDBService()
1616

17-
func conversationAssignee(groupId: NSNumber?, userId: String?) -> (ALContact?, ALChannel?) {
17+
func conversationAssignee(groupId: NSNumber?, userId: String?) -> (ALContact?, KMCoreChannel?) {
1818
// Check if group conversation.
1919
guard let channelKey = groupId else {
2020
guard let userId = userId else {
@@ -43,7 +43,7 @@ class ConversationDetail {
4343

4444
func updatedAssigneeDetails(groupId: NSNumber?,
4545
userId: String?,
46-
completion: @escaping (ALContact?, ALChannel?) -> Void) {
46+
completion: @escaping (ALContact?, KMCoreChannel?) -> Void) {
4747
var (assignee, alChannel) = conversationAssignee(groupId: groupId, userId: userId)
4848
guard let contact = assignee else {
4949
completion(nil, alChannel)
@@ -105,14 +105,14 @@ class ConversationDetail {
105105
}
106106
}
107107

108-
extension ALChannel {
108+
extension KMCoreChannel {
109109
static let ClosedStatus = 2
110110

111111
var isClosedConversation: Bool {
112112
guard let conversationStatus = metadata[AL_CHANNEL_CONVERSATION_STATUS] as? String else {
113113
return false
114114
}
115115
return type == Int16(SUPPORT_GROUP.rawValue) &&
116-
Int(conversationStatus) ?? 0 == ALChannel.ClosedStatus
116+
Int(conversationStatus) ?? 0 == KMCoreChannel.ClosedStatus
117117
}
118118
}

Sources/Kommunicate/Classes/ConversationVCNavBar.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class ConversationVCNavBar: UIView, Localizable {
150150
fatalError("init(coder:) has not been implemented")
151151
}
152152

153-
func updateView(assignee: ALContact?, channel: ALChannel) {
153+
func updateView(assignee: ALContact?, channel: KMCoreChannel) {
154154
setupProfile(assignee, channel)
155155
}
156156

@@ -276,7 +276,7 @@ class ConversationVCNavBar: UIView, Localizable {
276276
backButton.setImage(image.imageFlippedForRightToLeftLayoutDirection(), for: .normal)
277277
}
278278

279-
private func setupProfile(_ contact: ALContact?, _ channel: ALChannel) {
279+
private func setupProfile(_ contact: ALContact?, _ channel: KMCoreChannel) {
280280
var url: URL?
281281

282282
if let imageUrl = contact?.contactImageUrl {
@@ -303,7 +303,7 @@ class ConversationVCNavBar: UIView, Localizable {
303303
profileName.text = name
304304
}
305305

306-
private func placeHolderImage(channel: ALChannel) -> UIImage? {
306+
private func placeHolderImage(channel: KMCoreChannel) -> UIImage? {
307307
var placeHolder: UIImage?
308308

309309
if channel.type == Int16(SUPPORT_GROUP.rawValue) {

Sources/Kommunicate/Classes/KMBotService.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import KommunicateCore_iOS_SDK
1010

1111
/// `KMBotService` will have all the API releated to bots
1212
public struct KMBotService {
13-
var channelService: ALChannelService
14-
var channelDBService: ALChannelDBService
13+
var channelService: KMCoreChannelService
14+
var channelDBService: KMCoreChannelDBService
1515
static let conversationAssignee = "CONVERSATION_ASSIGNEE"
1616

1717
public init() {
18-
channelService = ALChannelService()
19-
channelDBService = ALChannelDBService()
18+
channelService = KMCoreChannelService()
19+
channelDBService = KMCoreChannelDBService()
2020
}
2121

2222
/// This method is used for fetching `BotDetail`

Sources/Kommunicate/Classes/KMConversationListViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class KMConversationListViewController: ALKBaseViewController, Localizabl
2828
public var conversationListTableViewController: ALKConversationListTableViewController
2929
private let registerUserClientService = ALRegisterUserClientService()
3030

31-
let channelService = ALChannelService()
31+
let channelService = KMCoreChannelService()
3232
var searchController: UISearchController!
3333
var searchBar: KMCustomSearchBar!
3434
lazy var resultVC = ALKSearchResultViewController(configuration: configuration)
@@ -367,7 +367,7 @@ public class KMConversationListViewController: ALKBaseViewController, Localizabl
367367
})
368368

369369
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0, execute: {
370-
let channelDbService = ALChannelDBService()
370+
let channelDbService = KMCoreChannelDBService()
371371
channelDbService.deleteChannel(conversation.groupId)
372372
self.viewModel.remove(message: conversation)
373373
self.tableView.reloadData()

Sources/Kommunicate/Classes/KMConversationService.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class KMConversationService: KMConservationServiceable, Localizable {
5555

5656
let groupMetadata: NSMutableDictionary = {
5757
let metadata = NSMutableDictionary(
58-
dictionary: ALChannelService().metadataToHideActionMessagesAndTurnOffNotifications())
58+
dictionary: KMCoreChannelService().metadataToHideActionMessagesAndTurnOffNotifications())
5959

6060
// Required for features like setting user language in server.
6161
guard let messageMetadata = Kommunicate.defaultConfiguration.messageMetadata,
@@ -67,7 +67,7 @@ public class KMConversationService: KMConservationServiceable, Localizable {
6767
return metadata
6868
}()
6969

70-
let channelService = ALChannelService()
70+
let channelService = KMCoreChannelService()
7171

7272
// MARK: - Initialization
7373

@@ -423,7 +423,7 @@ public class KMConversationService: KMConservationServiceable, Localizable {
423423

424424
func getMetaDataWith(_ conversation: KMConversation) -> NSMutableDictionary {
425425
let metadata = NSMutableDictionary(
426-
dictionary: ALChannelService().metadataToHideActionMessagesAndTurnOffNotifications())
426+
dictionary: KMCoreChannelService().metadataToHideActionMessagesAndTurnOffNotifications())
427427

428428
if !conversation.conversationMetadata.isEmpty {
429429
metadata.addEntries(from: conversation.conversationMetadata)
@@ -542,8 +542,8 @@ public class KMConversationService: KMConservationServiceable, Localizable {
542542
return agentIds.map { createAgentGroupUserFrom(agentId: $0) }
543543
}
544544

545-
internal func isGroupPresent(clientId: String, completion: @escaping (_ isPresent: Bool, _ channel: ALChannel?) -> Void) {
546-
let client = ALChannelService()
545+
internal func isGroupPresent(clientId: String, completion: @escaping (_ isPresent: Bool, _ channel: KMCoreChannel?) -> Void) {
546+
let client = KMCoreChannelService()
547547
client.getChannelInformation(byResponse: nil, orClientChannelKey: clientId, withCompletion: {
548548
_, channel, _ in
549549
guard let channel = channel else {
@@ -588,7 +588,7 @@ public class KMConversationService: KMConservationServiceable, Localizable {
588588
if let agentUsers = agentGroupUsersFor(agentIds: conversation.agentIds) {
589589
members.append(contentsOf: agentUsers)
590590
}
591-
let alChannelService = ALChannelService()
591+
let alChannelService = KMCoreChannelService()
592592
let groupUsers = members.map { $0.toDict() }
593593

594594
alChannelService.createChannel(
@@ -688,7 +688,7 @@ public class KMConversationService: KMConservationServiceable, Localizable {
688688
metadata: NSMutableDictionary,
689689
completion: @escaping ((Response) -> Void)
690690
) {
691-
ALChannelService().updateChannelMetaData(groupId, orClientChannelKey: channelKey, metadata: metadata) { error in
691+
KMCoreChannelService().updateChannelMetaData(groupId, orClientChannelKey: channelKey, metadata: metadata) { error in
692692
guard error == nil else {
693693
completion(Response(success: false, clientChannelKey: nil, error: error))
694694
return
@@ -702,7 +702,7 @@ public class KMConversationService: KMConservationServiceable, Localizable {
702702
metadata: NSMutableDictionary,
703703
completion: @escaping ((Response) -> Void)
704704
) {
705-
ALChannelService().updateChannelMetaData(nil, orClientChannelKey: groupId, metadata: metadata) { error in
705+
KMCoreChannelService().updateChannelMetaData(nil, orClientChannelKey: groupId, metadata: metadata) { error in
706706
guard error == nil else {
707707
completion(Response(success: false, clientChannelKey: nil, error: error))
708708
return
@@ -717,12 +717,12 @@ public class KMConversationService: KMConservationServiceable, Localizable {
717717
completion: @escaping ((Response) -> Void)
718718
) {
719719
let metadata = NSMutableDictionary(
720-
dictionary: ALChannelService().metadataToHideActionMessagesAndTurnOffNotifications())
720+
dictionary: KMCoreChannelService().metadataToHideActionMessagesAndTurnOffNotifications())
721721
if !teamID.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
722722
metadata.setValue(teamID, forKey: ChannelMetadataKeys.teamId)
723723
}
724724

725-
ALChannelService().updateChannelMetaData(NSNumber(pointer: groupID), orClientChannelKey: groupID, metadata: metadata) { error in
725+
KMCoreChannelService().updateChannelMetaData(NSNumber(pointer: groupID), orClientChannelKey: groupID, metadata: metadata) { error in
726726
guard error == nil else {
727727
completion(Response(success: false, clientChannelKey: nil, error: error))
728728
return

Sources/Kommunicate/Classes/KMConversationViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ open class KMConversationViewController: ALKConversationViewController, KMUpdate
113113

114114
private var isClosedConversation: Bool {
115115
guard let channelId = viewModel.channelKey,
116-
!ALChannelService.isChannelDeleted(channelId),
116+
!KMCoreChannelService.isChannelDeleted(channelId),
117117
conversationDetail.isClosedConversation(channelId: channelId.intValue)
118118
else {
119119
return false
@@ -709,7 +709,7 @@ open class KMConversationViewController: ALKConversationViewController, KMUpdate
709709
if let alChannel = channel {
710710
setupTopBar(alChannel: alChannel, contact: contact)
711711
} else {
712-
let alChannelService = ALChannelService()
712+
let alChannelService = KMCoreChannelService()
713713
alChannelService.getChannelInformation(viewModel.channelKey, orClientChannelKey: nil) { channel in
714714
guard let alChannel = channel else {
715715
print("Channel is nil in conversationAssignee")
@@ -719,7 +719,7 @@ open class KMConversationViewController: ALKConversationViewController, KMUpdate
719719
}
720720
}
721721
}
722-
private func setupTopBar(alChannel: ALChannel, contact: ALContact?) {
722+
private func setupTopBar(alChannel: KMCoreChannel, contact: ALContact?) {
723723
customNavigationView.updateView(assignee: contact, channel: alChannel)
724724
assigneeUserId = contact?.userId
725725
navigationItem.leftBarButtonItem = UIBarButtonItem(customView: customNavigationView)

Sources/Kommunicate/Classes/KMPushNotificationHelper.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class KMPushNotificationHelper {
2121
/// For group check mute only.
2222
self.groupId = groupId
2323
if let groupId = groupId {
24-
let group = ALChannelService().getChannelByKey(groupId)
24+
let group = KMCoreChannelService().getChannelByKey(groupId)
2525
isMute = group?.isNotificationMuted() ?? false
2626
}
2727
}

Sources/Kommunicate/Classes/Kommunicate.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ open class Kommunicate: NSObject, Localizable {
745745
showListOnBack: Bool = false,
746746
completionHandler: @escaping (Bool) -> Void
747747
) {
748-
let alChannelService = ALChannelService()
748+
let alChannelService = KMCoreChannelService()
749749
alChannelService.getChannelInformation(nil, orClientChannelKey: clientGroupId) { channel in
750750
guard let channel = channel, let key = channel.key else {
751751
completionHandler(false)
@@ -806,7 +806,7 @@ open class Kommunicate: NSObject, Localizable {
806806
showListOnBack: Bool = false,
807807
completionHandler: @escaping (Bool) -> Void
808808
) {
809-
let alChannelService = ALChannelService()
809+
let alChannelService = KMCoreChannelService()
810810
alChannelService.getChannelInformation(nil, orClientChannelKey: clientGroupId) { channel in
811811
guard let channel = channel, let key = channel.key else {
812812
completionHandler(false)
@@ -904,7 +904,7 @@ open class Kommunicate: NSObject, Localizable {
904904
// Update group id so that messages can be fetched & stored locally
905905
zendeskHandler.setGroupId(existingZendeskConversationId.stringValue)
906906

907-
guard let channel = ALChannelService().getChannelByKey(existingZendeskConversationId) else {
907+
guard let channel = KMCoreChannelService().getChannelByKey(existingZendeskConversationId) else {
908908
completion(.conversationNotPresent)
909909
return
910910
}
@@ -999,7 +999,7 @@ open class Kommunicate: NSObject, Localizable {
999999
}
10001000

10011001
let defaultMetaData = NSMutableDictionary(
1002-
dictionary: ALChannelService().metadataToHideActionMessagesAndTurnOffNotifications())
1002+
dictionary: KMCoreChannelService().metadataToHideActionMessagesAndTurnOffNotifications())
10031003

10041004
if let conversationMetaDict = conversation.conversationMetadata as NSDictionary? as! [String: Any]? {
10051005
let jsonObject = try? JSONSerialization.data(withJSONObject: conversationMetaDict, options: [])
@@ -1084,7 +1084,7 @@ open class Kommunicate: NSObject, Localizable {
10841084
completion(emptyConversationId)
10851085
return
10861086
}
1087-
let alChannelService = ALChannelService()
1087+
let alChannelService = KMCoreChannelService()
10881088
alChannelService.getChannelInformation(nil, orClientChannelKey: message.conversationId) { channel in
10891089
guard let channel = channel, let key = channel.key else {
10901090
let noConversationError = NSError(domain: "No conversation found", code: 0, userInfo: nil)

0 commit comments

Comments
 (0)