Files
simplex-chat/apps/ios/Shared/Model/ChatModel.swift
Evgeny Poberezkin b38d5f3465 started chat model (#221)
* started chat model

* refactor processing commands and UI events

* message chat event processing

* groups: delayed delivery of messages and introductions to announced members (#217)

* combine migrations, rename fields

* show all view messages vis ChatResponse type

* serialize chat response

* update C api

* remove unused extensions, fix typos

Co-authored-by: Efim Poberezkin <8711996+efim-poberezkin@users.noreply.github.com>
2022-01-24 16:07:17 +00:00

68 lines
1.2 KiB
Swift

//
// ChatModel.swift
// SimpleX
//
// Created by Evgeny Poberezkin on 22/01/2022.
// Copyright © 2022 SimpleX Chat. All rights reserved.
//
import Foundation
import Combine
import SwiftUI
final class ChatModel: ObservableObject {
@Published var currentUser: User?
@Published var channels: [ChatChannel] = []
}
struct User: Codable {
var userId: Int64
var userContactId: Int64
var localDisplayName: ContactName
var profile: Profile
var activeUser: Bool
}
typealias ContactName = String
typealias GroupName = String
struct Profile: Codable {
var displayName: String
var fullName: String
}
enum ChatChannel {
case contact(ContactInfo, [ChatMessage])
case group(GroupInfo, [ChatMessage])
}
struct ContactInfo: Codable {
var contactId: Int64
var localDisplayName: ContactName
var profile: Profile
var viaGroup: Int64?
}
struct GroupInfo: Codable {
var groupId: Int64
var localDisplayName: GroupName
var groupProfile: GroupProfile
}
struct GroupProfile: Codable {
var displayName: String
var fullName: String
}
struct ChatMessage {
var from: ContactInfo?
var ts: Date
var content: MsgContent
}
enum MsgContent {
case text(String)
case unknown
}