Add iOS media placeholders
This commit is contained in:
@@ -199,6 +199,41 @@ public actor UniFfiSessionBridge: SessionBridge {
|
||||
Reaction(emoji: reaction.emoji, count: reaction.count, isChosen: reaction.isChosen)
|
||||
}
|
||||
|
||||
private static func mapDownloadState(_ state: IosDownloadState) -> MediaDownloadState {
|
||||
switch state {
|
||||
case .notDownloaded:
|
||||
.notDownloaded
|
||||
case .downloading:
|
||||
.downloading
|
||||
case let .downloaded(path):
|
||||
.downloaded(path: path)
|
||||
case let .error(message):
|
||||
.error(message)
|
||||
}
|
||||
}
|
||||
|
||||
private static func mapMedia(_ media: IosMedia) -> MessageMedia? {
|
||||
switch media.kind {
|
||||
case "photo":
|
||||
.photo(PhotoMedia(
|
||||
fileId: media.fileId,
|
||||
width: media.width ?? 0,
|
||||
height: media.height ?? 0,
|
||||
downloadState: mapDownloadState(media.downloadState)
|
||||
))
|
||||
case "voice":
|
||||
.voice(VoiceMedia(
|
||||
fileId: media.fileId,
|
||||
duration: media.duration ?? 0,
|
||||
mimeType: media.mimeType,
|
||||
waveform: media.waveform,
|
||||
downloadState: mapDownloadState(media.downloadState)
|
||||
))
|
||||
default:
|
||||
nil
|
||||
}
|
||||
}
|
||||
|
||||
private static func mapMessage(_ message: IosMessage, chatId: Int64) -> Message {
|
||||
Message(
|
||||
id: message.id,
|
||||
@@ -206,6 +241,8 @@ public actor UniFfiSessionBridge: SessionBridge {
|
||||
senderName: message.senderName,
|
||||
text: message.text,
|
||||
date: message.date,
|
||||
mediaAlbumId: message.mediaAlbumId,
|
||||
media: message.media.flatMap(mapMedia),
|
||||
isOutgoing: message.isOutgoing,
|
||||
isRead: message.isRead,
|
||||
editDate: message.editDate,
|
||||
|
||||
Reference in New Issue
Block a user