wip
This commit is contained in:
parent
9d6f610b63
commit
ea333acb1a
|
@ -41,7 +41,7 @@ static const DDLogLevel ddLogLevel = LOG_LEVEL_STDOUT;
|
||||||
#else
|
#else
|
||||||
// fmodf: 19.11.24 - changed to actual another.im group
|
// fmodf: 19.11.24 - changed to actual another.im group
|
||||||
// #define kAppGroup @"group.monal"
|
// #define kAppGroup @"group.monal"
|
||||||
#define kAppGroup @"group.another.im.test"
|
#define kAppGroup @"group.im.narayana.anotherim"
|
||||||
#define kMonalOpenURL [NSURL URLWithString:@"monalOpen://"]
|
#define kMonalOpenURL [NSURL URLWithString:@"monalOpen://"]
|
||||||
#define kBackgroundProcessingTask @"im.monal.process"
|
#define kBackgroundProcessingTask @"im.monal.process"
|
||||||
#define kBackgroundRefreshingTask @"im.monal.refresh"
|
#define kBackgroundRefreshingTask @"im.monal.refresh"
|
||||||
|
|
|
@ -3706,7 +3706,7 @@
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
DEVELOPMENT_ASSET_PATHS = "";
|
DEVELOPMENT_ASSET_PATHS = "";
|
||||||
DEVELOPMENT_TEAM = U6CKGHL5VR;
|
DEVELOPMENT_TEAM = K78H7BT98L;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu17;
|
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||||
|
@ -3736,7 +3736,7 @@
|
||||||
MARKETING_VERSION = 1.0.0;
|
MARKETING_VERSION = 1.0.0;
|
||||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.mitrofanovegor.anotherim;
|
PRODUCT_BUNDLE_IDENTIFIER = im.narayana.anotherim.ios;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
||||||
|
@ -3792,7 +3792,7 @@
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
DEVELOPMENT_ASSET_PATHS = "";
|
DEVELOPMENT_ASSET_PATHS = "";
|
||||||
DEVELOPMENT_TEAM = U6CKGHL5VR;
|
DEVELOPMENT_TEAM = K78H7BT98L;
|
||||||
ENABLE_NS_ASSERTIONS = NO;
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
@ -3826,7 +3826,7 @@
|
||||||
MARKETING_VERSION = 1.0.0;
|
MARKETING_VERSION = 1.0.0;
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.mitrofanovegor.anotherim;
|
PRODUCT_BUNDLE_IDENTIFIER = im.narayana.anotherim.ios;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
|
@ -3884,7 +3884,7 @@
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
DEVELOPMENT_ASSET_PATHS = "";
|
DEVELOPMENT_ASSET_PATHS = "";
|
||||||
DEVELOPMENT_TEAM = U6CKGHL5VR;
|
DEVELOPMENT_TEAM = K78H7BT98L;
|
||||||
ENABLE_NS_ASSERTIONS = NO;
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
@ -3918,7 +3918,7 @@
|
||||||
MARKETING_VERSION = 1.0.0;
|
MARKETING_VERSION = 1.0.0;
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.mitrofanovegor.anotherim;
|
PRODUCT_BUNDLE_IDENTIFIER = im.narayana.anotherim.ios;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
|
@ -3976,7 +3976,7 @@
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
DEVELOPMENT_ASSET_PATHS = "";
|
DEVELOPMENT_ASSET_PATHS = "";
|
||||||
DEVELOPMENT_TEAM = U6CKGHL5VR;
|
DEVELOPMENT_TEAM = K78H7BT98L;
|
||||||
ENABLE_NS_ASSERTIONS = NO;
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
@ -4010,7 +4010,7 @@
|
||||||
MARKETING_VERSION = 1.0.0;
|
MARKETING_VERSION = 1.0.0;
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.mitrofanovegor.anotherim;
|
PRODUCT_BUNDLE_IDENTIFIER = im.narayana.anotherim.ios;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
|
@ -4068,7 +4068,7 @@
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
DEVELOPMENT_ASSET_PATHS = "";
|
DEVELOPMENT_ASSET_PATHS = "";
|
||||||
DEVELOPMENT_TEAM = U6CKGHL5VR;
|
DEVELOPMENT_TEAM = K78H7BT98L;
|
||||||
ENABLE_NS_ASSERTIONS = NO;
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
@ -4102,7 +4102,7 @@
|
||||||
MARKETING_VERSION = 1.0.0;
|
MARKETING_VERSION = 1.0.0;
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.mitrofanovegor.anotherim;
|
PRODUCT_BUNDLE_IDENTIFIER = im.narayana.anotherim.ios;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
|
@ -4160,7 +4160,7 @@
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
DEVELOPMENT_ASSET_PATHS = "";
|
DEVELOPMENT_ASSET_PATHS = "";
|
||||||
DEVELOPMENT_TEAM = U6CKGHL5VR;
|
DEVELOPMENT_TEAM = K78H7BT98L;
|
||||||
ENABLE_NS_ASSERTIONS = NO;
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
@ -4194,7 +4194,7 @@
|
||||||
MARKETING_VERSION = 1.0.0;
|
MARKETING_VERSION = 1.0.0;
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.mitrofanovegor.anotherim;
|
PRODUCT_BUNDLE_IDENTIFIER = im.narayana.anotherim.ios;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<dict>
|
<dict>
|
||||||
<key>com.apple.security.application-groups</key>
|
<key>com.apple.security.application-groups</key>
|
||||||
<array>
|
<array>
|
||||||
<string>group.another.im.test</string>
|
<string>group.im.narayana.anotherim</string>
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|
|
@ -3,7 +3,7 @@ import SwiftUI
|
||||||
|
|
||||||
struct ConversationMessageRow: View {
|
struct ConversationMessageRow: View {
|
||||||
// @EnvironmentObject var messages: MessagesStore
|
// @EnvironmentObject var messages: MessagesStore
|
||||||
// let message: Message
|
let message: Message
|
||||||
@State private var offset: CGSize = .zero
|
@State private var offset: CGSize = .zero
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
|
|
@ -4,10 +4,7 @@ import SwiftUI
|
||||||
|
|
||||||
struct ConversationScreen: View {
|
struct ConversationScreen: View {
|
||||||
@Environment(\.router) var router
|
@Environment(\.router) var router
|
||||||
@EnvironmentObject var chatModel: ChatModel
|
@EnvironmentObject var chatWrapper: MonalChatWrapper
|
||||||
// @StateObject var messagesStore: MessagesStore
|
|
||||||
// @StateObject var attachments: AttachmentsStore
|
|
||||||
// @StateObject var settings: ChatSettingsStore
|
|
||||||
|
|
||||||
@State private var autoScroll = true
|
@State private var autoScroll = true
|
||||||
@State private var firstIsVisible = true
|
@State private var firstIsVisible = true
|
||||||
|
@ -29,58 +26,58 @@ struct ConversationScreen: View {
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
centerText: .init(text: centerText()),
|
centerText: .init(text: centerText()),
|
||||||
rightButton: .init(
|
rightButton: nil
|
||||||
image: Image(systemName: "gear"),
|
// rightButton: .init(
|
||||||
action: {
|
// image: Image(systemName: "gear"),
|
||||||
router.showScreen(.push) { _ in
|
// action: {
|
||||||
ConversationSettingsScreen()
|
// router.showScreen(.push) { _ in
|
||||||
// .environmentObject(settings)
|
// ConversationSettingsScreen()
|
||||||
.navigationBarHidden(true)
|
// // .environmentObject(settings)
|
||||||
}
|
// .navigationBarHidden(true)
|
||||||
}
|
// }
|
||||||
)
|
// }
|
||||||
|
// )
|
||||||
)
|
)
|
||||||
|
|
||||||
// Msg list
|
// Msg list
|
||||||
// let messages = messagesStore.messages
|
if !chatWrapper.messages.isEmpty {
|
||||||
// if !messages.isEmpty {
|
ScrollViewReader { proxy in
|
||||||
// ScrollViewReader { proxy in
|
ScrollView {
|
||||||
// ScrollView {
|
LazyVStack(spacing: 0) {
|
||||||
// LazyVStack(spacing: 0) {
|
ForEach(chatWrapper.messages) { message in
|
||||||
// ForEach(messages) { message in
|
ConversationMessageRow(message: message)
|
||||||
// ConversationMessageRow(message: message)
|
.id(message.id)
|
||||||
// .id(message.id)
|
.flip()
|
||||||
// .flip()
|
.onAppear {
|
||||||
// .onAppear {
|
if message.id == chatWrapper.messages.first?.id {
|
||||||
// if message.id == messages.first?.id {
|
firstIsVisible = true
|
||||||
// firstIsVisible = true
|
autoScroll = true
|
||||||
// autoScroll = true
|
}
|
||||||
// }
|
// messagesStore.scrolledMessage(message.id)
|
||||||
// messagesStore.scrolledMessage(message.id)
|
}
|
||||||
// }
|
.onDisappear {
|
||||||
// .onDisappear {
|
if message.id == chatWrapper.messages.first?.id {
|
||||||
// if message.id == messages.first?.id {
|
firstIsVisible = false
|
||||||
// firstIsVisible = false
|
autoScroll = false
|
||||||
// autoScroll = false
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
.flip()
|
||||||
// .flip()
|
.scrollDismissesKeyboard(.immediately)
|
||||||
// .scrollDismissesKeyboard(.immediately)
|
.onChange(of: autoScroll) { new in
|
||||||
// .onChange(of: autoScroll) { new in
|
print(proxy)
|
||||||
// if new, !firstIsVisible {
|
if new, !firstIsVisible {
|
||||||
// withAnimation {
|
withAnimation {
|
||||||
// proxy.scrollTo(messages.first?.id, anchor: .top)
|
proxy.scrollTo(chatWrapper.messages.first?.id, anchor: .top)
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// } else {
|
} else {
|
||||||
// Spacer()
|
Spacer()
|
||||||
// }
|
}
|
||||||
Spacer()
|
|
||||||
}
|
}
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
|
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
|
||||||
|
@ -121,6 +118,6 @@ struct ConversationScreen: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func centerText() -> String {
|
private func centerText() -> String {
|
||||||
chatModel.contact.name ?? chatModel.contact.contactJid
|
chatWrapper.contact.name ?? chatWrapper.contact.contactJid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,29 +127,11 @@ private struct ContactsScreenRow: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func startChat() {
|
private func startChat() {
|
||||||
Task {
|
let model = wrapper.chat(with: contact)
|
||||||
router.showModal {
|
router.showScreen(.push) { _ in
|
||||||
LoadingScreen()
|
ConversationScreen()
|
||||||
}
|
.navigationBarHidden(true)
|
||||||
defer {
|
.environmentObject(model)
|
||||||
router.dismissModal()
|
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
|
||||||
// let (messages, attachments, settings) = try await clientsStore.conversationStores(for: roster)
|
|
||||||
// router.showScreen(.push) { _ in
|
|
||||||
// ConversationScreen(messagesStore: messages, attachments: attachments, settings: settings)
|
|
||||||
// .navigationBarHidden(true)
|
|
||||||
// }
|
|
||||||
} catch {
|
|
||||||
router.showAlert(
|
|
||||||
.alert,
|
|
||||||
title: L10n.Global.Error.title,
|
|
||||||
subtitle: L10n.Conversation.startError
|
|
||||||
) {
|
|
||||||
Button(L10n.Global.ok, role: .cancel) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,3 +80,25 @@ struct Chat: Identifiable {
|
||||||
participantName = obj.nickName
|
participantName = obj.nickName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: Message
|
||||||
|
struct Message: Identifiable {
|
||||||
|
let accountId: Int
|
||||||
|
let participantJid: String
|
||||||
|
let dbId: Int
|
||||||
|
let timestamp: Date
|
||||||
|
let body: String
|
||||||
|
|
||||||
|
var id: String {
|
||||||
|
"\(accountId)|\(dbId)"
|
||||||
|
}
|
||||||
|
|
||||||
|
init?(_ obj: MLMessage) {
|
||||||
|
guard let accId = obj.accountID as? Int, let dbId = obj.messageDBId as? Int else { return nil }
|
||||||
|
accountId = accId
|
||||||
|
participantJid = obj.participantJid
|
||||||
|
self.dbId = dbId
|
||||||
|
timestamp = obj.timestamp
|
||||||
|
body = obj.messageText
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -55,8 +55,8 @@ extension MonalXmppWrapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func chat(with: Contact) -> ChatModel {
|
func chat(with: Contact) -> MonalChatWrapper {
|
||||||
let chatModel = ChatModel(contact: with)
|
let chatModel = MonalChatWrapper(contact: with, db: db, xmpp: xmpp)
|
||||||
return chatModel
|
return chatModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,10 +167,24 @@ private extension MonalXmppWrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Chat object
|
// MARK: - Chat object
|
||||||
final class ChatModel: ObservableObject {
|
final class MonalChatWrapper: ObservableObject {
|
||||||
let contact: Contact
|
@Published private(set) var messages: [Message] = []
|
||||||
|
|
||||||
init(contact: Contact) {
|
let contact: Contact
|
||||||
|
private let xmpp: MLXMPPManager
|
||||||
|
private let db: DataLayer
|
||||||
|
|
||||||
|
init(contact: Contact, db: DataLayer, xmpp: MLXMPPManager) {
|
||||||
self.contact = contact
|
self.contact = contact
|
||||||
|
self.db = db
|
||||||
|
self.xmpp = xmpp
|
||||||
|
}
|
||||||
|
|
||||||
|
private func refreshMessages() {
|
||||||
|
messages = db.messages(forContact: contact.contactJid, forAccount: NSNumber(value: contact.ownerId))
|
||||||
|
.compactMap {
|
||||||
|
guard let message = $0 as? MLMessage else { return nil }
|
||||||
|
return Message(message)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue