Skip to content

Commit 8e2dc71

Browse files
Release 0.3.0
- AI Answer Assist Feature updated to 2.0.0 - AI Translate Feature updated to 2.0.0 - AI Rephrase Feature updated to 2.0.0 - some tweaks and improvements
2 parents 7ed29e3 + fc5e7a7 commit 8e2dc71

File tree

105 files changed

+3750
-2593
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+3750
-2593
lines changed

Package.resolved

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ let package = Package(
1717
],
1818
dependencies: [
1919
.package(url: "https://github.com/QuickBlox/ios-quickblox-sdk", .upToNextMajor(from: "2.19.0")),
20-
.package(url: "https://github.com/QuickBlox/ios-ai-answer-assistant.git", .upToNextMajor(from: "1.0.0")),
21-
.package(url: "https://github.com/QuickBlox/ios-ai-translate.git", .upToNextMajor(from: "1.0.0")),
22-
.package(url: "https://github.com/QuickBlox/ios-ai-rephrase", .upToNextMajor(from: "1.0.0"))
20+
.package(url: "https://github.com/QuickBlox/ios-ai-answer-assistant.git", .upToNextMajor(from: "2.0.0")),
21+
.package(url: "https://github.com/QuickBlox/ios-ai-translate.git", .upToNextMajor(from: "2.0.0")),
22+
.package(url: "https://github.com/QuickBlox/ios-ai-rephrase.git", .upToNextMajor(from: "2.0.0"))
2323
],
2424
targets: [
2525
.target(

Sources/QuickBloxData/Event/RemoteEvent.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public enum RemoteEvent {
1111
case create(_ dialogId: String, byUser: Bool, message: RemoteMessageDTO)
1212
case update(_ dialogId: String)
1313
case leave(_ dialogId: String, byUser: Bool)
14-
case removed(_ dialogId: String)
14+
case removed(_ dialogId: String, byUser: Bool)
1515
case newMessage(_ message: RemoteMessageDTO)
1616
case history(_ messages: RemoteMessagesDTO)
1717
case read( _ messageID: String, dialogID: String)
@@ -34,7 +34,11 @@ public enum RemoteEvent {
3434
self = .leave(message.dialogId, byUser: message.isOwnedByCurrentUser)
3535
}
3636
case .removed:
37-
self = .removed(message.dialogId)
37+
if message.isOwnedByCurrentUser {
38+
self = .update(message.dialogId)
39+
} else {
40+
self = .removed(message.dialogId, byUser: message.isOwnedByCurrentUser)
41+
}
3842
case .message:
3943
self = .newMessage(message)
4044
case .read:

Sources/QuickBloxData/Exception/RemoteDataSourceException.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public enum RemoteDataSourceException: Error, Equatable {
1515
case unauthorised(_ description: String = "")
1616

1717
/// Would be thrown when sending the wrong format of data, missing required fields, or providing incorrect values.
18-
case incorrectData(description: String = "")
18+
case incorrectData(_ description: String = "")
1919

2020
/// Would be thrown when there are no necessary permissions to access the requested resource.
2121
case restrictedAccess(description: String = "")

Sources/QuickBloxData/Mapper/Error+RepositoryException.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ extension Error {
4040
case .unauthorised( let info):
4141
return RepositoryException.unauthorised( info)
4242
case .incorrectData(description: let info):
43-
return RepositoryException.incorrectData(description: info)
43+
return RepositoryException.incorrectData(info)
4444
case .restrictedAccess(description: let info):
4545
return RepositoryException.restrictedAccess(description: info)
4646
case .connectionFailed(description: let info):
@@ -53,7 +53,7 @@ extension Error {
5353
case .unexpected(let info):
5454
return RepositoryException.unexpected(info)
5555
case .incorrectData(description: let info):
56-
return RepositoryException.incorrectData(description: info)
56+
return RepositoryException.incorrectData(info)
5757
}
5858
}
5959
}

Sources/QuickBloxData/Repository/DialogsRepository.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ extension DialogsRepository: DialogsRepositoryProtocol {
3333
case .update(withDialogId: let dialogId): return .update(dialogId)
3434
case .leave( let dialogId, let isCurrentUser):
3535
return .leave(dialogId, byUser: isCurrentUser)
36-
case .removed(let dialogId):
37-
return .removed(dialogId)
36+
case .removed(let dialogId, let isCurrentUser):
37+
return .removed(dialogId, byUser: isCurrentUser)
3838
case .newMessage(let message):
3939
return .newMessage(Message(message))
4040
case .history(let dto):
@@ -65,6 +65,13 @@ extension DialogsRepository: DialogsRepositoryProtocol {
6565
}
6666
}
6767

68+
public var localDialogUpdatePublisher: AnyPublisher<String, Never> {
69+
get async {
70+
await local.dialogUpdatePublisher
71+
.eraseToAnyPublisher()
72+
}
73+
}
74+
6875
public func create(dialogInRemote entity: Dialog) async throws -> Dialog {
6976
do {
7077
let data = try await remote.create(dialog: RemoteDialogDTO(entity))
@@ -227,6 +234,8 @@ private extension RemoteDialogDTO {
227234
lastMessageUserId = value.lastMessage.userId
228235
unreadMessagesCount = value.unreadMessagesCount
229236
isOwnedByCurrentUser = value.isOwnedByCurrentUser
237+
toAddIds = value.pushIDs
238+
toDeleteIds = value.pullIDs
230239
}
231240
}
232241

Sources/QuickBloxData/Source/Entity/Dialog.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ public struct Dialog: DialogEntity {
3131
public var unreadMessagesCount: Int
3232
public var decrementCounter: Bool = false
3333

34+
public var pushIDs: [String] = []
35+
public var pullIDs: [String] = []
36+
3437
public init(id: String = "",
3538
type: DialogType,
3639
name: String = "",

Sources/QuickBloxData/Source/Entity/Message.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public struct Message: MessageEntity {
2323
/// > Note: Returns an empty string by default
2424
public var text: String = ""
2525
public var translatedText: String = ""
26-
2726
public var userId: String = ""
2827
public var isOwnedByCurrentUser = false
2928
public var isRead: Bool = false

Sources/QuickBloxData/Source/Local/LocalDataSource.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,20 @@ import QuickBloxLog
1717
actor LocalDataSource: LocalDataSourceProtocol {
1818
//MARK: Properties
1919
private var dialogs = CurrentValueSubject<[LocalDialogDTO], Never>([])
20+
private var updatedDialog = CurrentValueSubject<String, Never>("")
2021
private var users: [String: LocalUserDTO] = [:]
2122

2223
var dialogsPublisher: AnyPublisher<[LocalDialogDTO], Never> {
2324
get async {
2425
dialogs.eraseToAnyPublisher()
2526
}
2627
}
28+
29+
var dialogUpdatePublisher: AnyPublisher<String, Never> {
30+
get async {
31+
updatedDialog.eraseToAnyPublisher()
32+
}
33+
}
2734
}
2835

2936
//MARK: Clear
@@ -44,6 +51,7 @@ extension LocalDataSource {
4451
var value = dialogs.value
4552
value.insertElement(dto, withSorting: .orderedDescending)
4653
dialogs.value = value
54+
updatedDialog.value = dto.id
4755
}
4856

4957
func get(dialog dto: LocalDialogDTO) async throws -> LocalDialogDTO {
@@ -141,6 +149,8 @@ extension LocalDataSource {
141149
} else {
142150
dialogs.value[index] = dialog
143151
}
152+
153+
updatedDialog.value = dto.id
144154
}
145155

146156
func getAllDialogs() async throws -> LocalDialogsDTO {

Sources/QuickBloxData/Source/Local/LocalDataSourceProtocol.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Combine
1313
public protocol LocalDataSourceProtocol: ClearLocalDataSourceProtocol {
1414
//MARK: Dialogs
1515
var dialogsPublisher: AnyPublisher<[LocalDialogDTO], Never> { get async }
16+
var dialogUpdatePublisher: AnyPublisher<String, Never> { get async }
1617

1718
/// Store a dialog session or conversation to a local storage.
1819
///

0 commit comments

Comments
 (0)