Shared media and files in a conversation's profile panel
The panel next to a direct message listed the linked files as plain "name · size" strings, while the design shows the pictures of the conversation as a grid and the other files with their size and time. Pictures already downloaded (the inline previews) now fill a grid of three a row, newest first, the sixth cell counting the rest; a click opens one larger. The other files show their name, size and when they were sent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5770dc5da2
commit
0f716974f0
3 files changed
+111
-24
No files matched your search
@@ -16,7 +16,7 @@ use voelin_core::{Command, HistoryMessage, OfflineMessage, OfflineMessageInfo, V
|
||||
use voelin_model::ChatTarget;
|
||||
use voelin_store::PageQuery;
|
||||
|
||||
use crate::app::{App, Bridge, ConversationItem, DmPeer, Nav, OfflineForm, Page, later};
|
||||
use crate::app::{App, Bridge, ConversationItem, DmPeer, FileItem, Nav, OfflineForm, Page, later};
|
||||
use crate::vm;
|
||||
use crate::vm::social::{ago, list_time, matches, plain, preview};
|
||||
|
||||
@@ -500,18 +500,33 @@ impl App {
|
||||
})
|
||||
.collect()
|
||||
};
|
||||
let files: Vec<SharedString> = tab
|
||||
.map(|t| {
|
||||
t.messages
|
||||
.iter()
|
||||
.flat_map(|m| m.message.message.file_refs())
|
||||
.map(|f| match f.size {
|
||||
Some(size) => format!("{} · {}", f.name, vm::chat::size_text(size)).into(),
|
||||
None => f.name.into(),
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or_default();
|
||||
// The pictures that are here (newest first), and the other files.
|
||||
let mut media = Vec::new();
|
||||
let mut files = Vec::new();
|
||||
for m in tab.iter().flat_map(|t| t.messages.iter().rev()) {
|
||||
let message = &m.message.message;
|
||||
for f in message.file_refs() {
|
||||
if let Some(image) = view.and_then(|v| crate::previews::image_of(v, &f)) {
|
||||
media.push(image);
|
||||
continue;
|
||||
}
|
||||
let when = vm::chat::time_of(message.ts_ms);
|
||||
files.push(FileItem {
|
||||
picture: vm::chat::is_picture(&f.name),
|
||||
detail: match f.size {
|
||||
Some(size) => format!("{} · {when}", vm::chat::size_text(size)),
|
||||
None => when,
|
||||
}
|
||||
.into(),
|
||||
name: f.name.into(),
|
||||
..Default::default()
|
||||
});
|
||||
}
|
||||
}
|
||||
let media_more = if media.len() > 6 { media.len() - 5 } else { 0 };
|
||||
if media_more > 0 {
|
||||
media.truncate(5);
|
||||
}
|
||||
let can_send = voice && here.is_some() && !blocked;
|
||||
let offline =
|
||||
voice && here.is_none() && view.is_some_and(|v| v.capabilities.offline_messages);
|
||||
@@ -559,6 +574,8 @@ impl App {
|
||||
.unwrap_or_default()
|
||||
.into(),
|
||||
servers: crate::app::model(servers),
|
||||
media: crate::app::model(media),
|
||||
media_more: media_more as i32,
|
||||
files: crate::app::model(files),
|
||||
friend: contact.is_some_and(|c| c.relation == voelin_core::Relation::Friend),
|
||||
blocked,
|
||||
|
||||
@@ -508,8 +508,12 @@ export struct DmPeer {
|
||||
since: string,
|
||||
// Where they are now, or where they were last seen.
|
||||
servers: [string],
|
||||
// Files linked in the conversation: "name · 2.4 MB".
|
||||
files: [string],
|
||||
// Pictures linked in the conversation that are downloaded, newest
|
||||
// first (at most six; `media-more` counts the others), and the other
|
||||
// files: name, "2.4 MB · Today at 11:36", picture.
|
||||
media: [image],
|
||||
media-more: int,
|
||||
files: [FileItem],
|
||||
friend: bool,
|
||||
blocked: bool,
|
||||
volume: float,
|
||||
|
||||
@@ -551,6 +551,62 @@ export component DmProfile inherits Rectangle {
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
if Bridge.dm.media.length > 0: Divider { }
|
||||
if Bridge.dm.media.length > 0: Text {
|
||||
text: @tr("Shared Media — {}", Bridge.dm.media.length + Bridge.dm.media-more);
|
||||
color: Theme.text;
|
||||
font-weight: Theme.weight-semibold;
|
||||
}
|
||||
// Three pictures a row; the last cell counts the ones left out.
|
||||
if Bridge.dm.media.length > 0: grid := Rectangle {
|
||||
property <length> gap: Theme.space-2;
|
||||
property <length> cell-w: (self.width - 2 * self.gap) / 3;
|
||||
property <length> cell-h: self.cell-w * 0.75;
|
||||
property <int> cells: Bridge.dm.media.length + (Bridge.dm.media-more > 0 ? 1 : 0);
|
||||
height: ceil(self.cells / 3) * (self.cell-h + self.gap) - self.gap;
|
||||
for picture[i] in Bridge.dm.media: Rectangle {
|
||||
x: mod(i, 3) * (grid.cell-w + grid.gap);
|
||||
y: floor(i / 3) * (grid.cell-h + grid.gap);
|
||||
width: grid.cell-w;
|
||||
height: grid.cell-h;
|
||||
border-radius: Theme.radius-md;
|
||||
clip: true;
|
||||
background: Theme.surface-2;
|
||||
accessible-role: AccessibleRole.image;
|
||||
accessible-label: @tr("Picture {}", i + 1);
|
||||
accessible-action-default => {
|
||||
Nav.lightbox = picture;
|
||||
Nav.lightbox-open = true;
|
||||
}
|
||||
Image {
|
||||
width: parent.width;
|
||||
height: parent.height;
|
||||
source: picture;
|
||||
image-fit: cover;
|
||||
}
|
||||
TouchArea {
|
||||
mouse-cursor: MouseCursor.pointer;
|
||||
clicked => {
|
||||
Nav.lightbox = picture;
|
||||
Nav.lightbox-open = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if Bridge.dm.media-more > 0: Rectangle {
|
||||
x: mod(Bridge.dm.media.length, 3) * (grid.cell-w + grid.gap);
|
||||
y: floor(Bridge.dm.media.length / 3) * (grid.cell-h + grid.gap);
|
||||
width: grid.cell-w;
|
||||
height: grid.cell-h;
|
||||
border-radius: Theme.radius-md;
|
||||
background: Theme.surface-3;
|
||||
Text {
|
||||
text: "+" + Bridge.dm.media-more;
|
||||
color: Theme.text;
|
||||
font-size: Theme.font-lg;
|
||||
font-weight: Theme.weight-semibold;
|
||||
}
|
||||
}
|
||||
}
|
||||
Divider { }
|
||||
Text {
|
||||
text: @tr("Shared Files — {}", Bridge.dm.files.length);
|
||||
@@ -562,21 +618,31 @@ export component DmProfile inherits Rectangle {
|
||||
Rectangle {
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
y: (parent.height - self.height) / 2;
|
||||
border-radius: Theme.radius-md;
|
||||
background: Theme.danger-soft;
|
||||
background: file.picture ? Theme.accent-soft : Theme.danger-soft;
|
||||
Icon {
|
||||
source: Icons.file-text;
|
||||
source: file.picture ? Icons.image : Icons.file-text;
|
||||
size: Theme.icon-sm;
|
||||
tint: Theme.danger;
|
||||
tint: file.picture ? Theme.accent-text : Theme.danger;
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: file;
|
||||
color: Theme.text-secondary;
|
||||
font-size: Theme.font-sm;
|
||||
vertical-alignment: center;
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
horizontal-stretch: 1;
|
||||
overflow: elide;
|
||||
spacing: 1px;
|
||||
Text {
|
||||
text: file.name;
|
||||
color: Theme.text;
|
||||
font-size: Theme.font-sm;
|
||||
overflow: elide;
|
||||
}
|
||||
Text {
|
||||
text: file.detail;
|
||||
color: Theme.text-muted;
|
||||
font-size: Theme.font-xs;
|
||||
overflow: elide;
|
||||
}
|
||||
}
|
||||
}
|
||||
if Bridge.dm.files.length == 0: Text {
|
||||
|
||||
Reference in new issue
Block a user