Skip to content

Commit 5f717d9

Browse files
Merge pull request #9 from QuickBlox/Release-0.1.5
Release QuickBlox UIKit 0.1.5
2 parents d889190 + b781109 commit 5f717d9

File tree

68 files changed

+2308
-580
lines changed

Some content is hidden

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

68 files changed

+2308
-580
lines changed

Package.resolved

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

Package.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ 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"))
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"))
2122
],
2223
targets: [
2324
.target(
@@ -35,7 +36,9 @@ let package = Package(
3536
.product(name: "Quickblox",
3637
package: "ios-quickblox-sdk"),
3738
.product(name: "QBAIAnswerAssistant",
38-
package: "ios-ai-answer-assistant")]),
39+
package: "ios-ai-answer-assistant"),
40+
.product(name: "QBAITranslate",
41+
package: "ios-ai-translate")]),
3942
.target(
4043
name: "QuickBloxLog",
4144
dependencies: []),

README.md

Lines changed: 241 additions & 81 deletions
Large diffs are not rendered by default.

Sources/QuickBloxData/DTO/Dialog/LocalDialogDTO.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,11 @@ public struct LocalDialogDTO: Equatable, Identifiable, Hashable {
2929
var lastMessageDateSent = Date(timeIntervalSince1970: 0.0)
3030
var lastMessageUserId: String = ""
3131
var unreadMessagesCount: Int = 0
32+
var decrementCounter: Bool = false
3233
}
3334

3435
extension LocalDialogDTO: Dated {
3536
var date: Date {
3637
return updatedAt
3738
}
38-
39-
4039
}

Sources/QuickBloxData/Event/RemoteEvent.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
public enum RemoteEvent {
11-
case create(_ dialogId: String)
11+
case create(_ dialogId: String, byUser: Bool, message: RemoteMessageDTO)
1212
case update(_ dialogId: String)
1313
case leave(_ dialogId: String, byUser: Bool)
1414
case removed(_ dialogId: String)
@@ -23,7 +23,7 @@ public enum RemoteEvent {
2323
if message.type == .event {
2424
switch message.eventType {
2525
case .create:
26-
self = .create(message.dialogId)
26+
self = .create(message.dialogId, byUser: message.isOwnedByCurrentUser, message: message)
2727
case .update:
2828
self = .update(message.dialogId)
2929
case .leave:

Sources/QuickBloxData/RepositoriesFabric.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class RepositoriesFabric {
1313
static let remote = RemoteDataSource()
1414
static let local = LocalDataSource()
1515
static let localFiles = LocalFilesDataSource()
16+
static let permissions = PermissionsSource()
1617
}
1718

1819
static public var dialogs: DialogsRepository {
@@ -38,4 +39,8 @@ public class RepositoriesFabric {
3839
static public var connection: ConnectionRepository {
3940
ConnectionRepository(remote: Service.remote)
4041
}
42+
43+
static public var permissions: PermissionsRepository {
44+
PermissionsRepository(repo: Service.permissions)
45+
}
4146
}

Sources/QuickBloxData/Repository/DialogsRepository.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ extension DialogsRepository: DialogsRepositoryProtocol {
2929
await remote.eventPublisher
3030
.compactMap { event in
3131
switch event {
32-
case .create(withId: let dialogId): return .create(dialogId)
33-
case .update(witthDialogId: let dialogId): return .update(dialogId)
34-
case .leave( let dialogId, let isCurrentUser ):
32+
case .create(let dialogId, let isCurrent, let message): return .create(dialogId, byUser: isCurrent, message: Message(message))
33+
case .update(withDialogId: let dialogId): return .update(dialogId)
34+
case .leave( let dialogId, let isCurrentUser):
3535
return .leave(dialogId, byUser: isCurrentUser)
3636
case .removed(let dialogId):
3737
return .removed(dialogId)
@@ -247,6 +247,7 @@ private extension LocalDialogDTO {
247247
lastMessageUserId = value.lastMessage.userId
248248

249249
unreadMessagesCount = value.unreadMessagesCount
250+
decrementCounter = value.decrementCounter
250251
isOwnedByCurrentUser = value.isOwnedByCurrentUser
251252
}
252253
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// PermissionsRepository.swift
3+
// QuickBloxUIKit
4+
//
5+
// Created by Injoit on 25.08.2023.
6+
// Copyright © 2023 QuickBlox. All rights reserved.
7+
//
8+
9+
import QuickBloxDomain
10+
import AVFoundation
11+
12+
public class PermissionsRepository {
13+
private var repo: PermissionsRepositoryProtocol!
14+
15+
init(repo: PermissionsRepositoryProtocol) {
16+
self.repo = repo
17+
}
18+
19+
private init() { }
20+
}
21+
22+
extension PermissionsRepository: PermissionsRepositoryProtocol {
23+
public func openSettings() async throws {
24+
do {
25+
try await repo.openSettings()
26+
} catch {
27+
throw try error.repositoryException
28+
}
29+
}
30+
31+
public func get(permissionTo mediaType: AVMediaType) async throws -> Bool {
32+
do {
33+
return try await repo.get(permissionTo: mediaType)
34+
} catch {
35+
throw try error.repositoryException
36+
}
37+
}
38+
}

Sources/QuickBloxData/Source/Entity/Dialog.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public struct Dialog: DialogEntity {
2929
userId: "")
3030
public var messages: [Message] = []
3131
public var unreadMessagesCount: Int
32+
public var decrementCounter: Bool = false
3233

3334
public init(id: String = "",
3435
type: DialogType,
@@ -43,7 +44,8 @@ public struct Dialog: DialogEntity {
4344
text: "",
4445
userId: ""),
4546
messages: [Message] = [],
46-
unreadMessagesCount: Int = 0) {
47+
unreadMessagesCount: Int = 0,
48+
decrementCounter: Bool = false) {
4749
self.id = id
4850
self.type = type
4951
self.name = name
@@ -55,6 +57,7 @@ public struct Dialog: DialogEntity {
5557
self.lastMessage = lastMessage
5658
self.messages = messages
5759
self.unreadMessagesCount = unreadMessagesCount
60+
self.decrementCounter = decrementCounter
5861
}
5962
}
6063

Sources/QuickBloxData/Source/Entity/Message.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public struct Message: MessageEntity {
2222
///
2323
/// > Note: Returns an empty string by default
2424
public var text: String = ""
25+
public var translatedText: String = ""
2526

2627
public var userId: String = ""
2728
public var isOwnedByCurrentUser = false
@@ -49,6 +50,7 @@ public extension Message {
4950
self.init(id: value.id,
5051
dialogId: value.dialogId,
5152
text: value.text,
53+
translatedText: value.translatedText,
5254
userId: value.userId,
5355
date: value.date,
5456
isOwnedByCurrentUser: value.isOwnedByCurrentUser,

0 commit comments

Comments
 (0)