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
d61fd62d7a
commit
b566167055
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_model::ChatTarget;
|
||||||
use voelin_store::PageQuery;
|
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;
|
||||||
use crate::vm::social::{ago, list_time, matches, plain, preview};
|
use crate::vm::social::{ago, list_time, matches, plain, preview};
|
||||||
|
|
||||||
@@ -500,18 +500,33 @@ impl App {
|
|||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
};
|
};
|
||||||
let files: Vec<SharedString> = tab
|
// The pictures that are here (newest first), and the other files.
|
||||||
.map(|t| {
|
let mut media = Vec::new();
|
||||||
t.messages
|
let mut files = Vec::new();
|
||||||
.iter()
|
for m in tab.iter().flat_map(|t| t.messages.iter().rev()) {
|
||||||
.flat_map(|m| m.message.message.file_refs())
|
let message = &m.message.message;
|
||||||
.map(|f| match f.size {
|
for f in message.file_refs() {
|
||||||
Some(size) => format!("{} · {}", f.name, vm::chat::size_text(size)).into(),
|
if let Some(image) = view.and_then(|v| crate::previews::image_of(v, &f)) {
|
||||||
None => f.name.into(),
|
media.push(image);
|
||||||
})
|
continue;
|
||||||
.collect()
|
}
|
||||||
})
|
let when = vm::chat::time_of(message.ts_ms);
|
||||||
.unwrap_or_default();
|
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 can_send = voice && here.is_some() && !blocked;
|
||||||
let offline =
|
let offline =
|
||||||
voice && here.is_none() && view.is_some_and(|v| v.capabilities.offline_messages);
|
voice && here.is_none() && view.is_some_and(|v| v.capabilities.offline_messages);
|
||||||
@@ -559,6 +574,8 @@ impl App {
|
|||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.into(),
|
.into(),
|
||||||
servers: crate::app::model(servers),
|
servers: crate::app::model(servers),
|
||||||
|
media: crate::app::model(media),
|
||||||
|
media_more: media_more as i32,
|
||||||
files: crate::app::model(files),
|
files: crate::app::model(files),
|
||||||
friend: contact.is_some_and(|c| c.relation == voelin_core::Relation::Friend),
|
friend: contact.is_some_and(|c| c.relation == voelin_core::Relation::Friend),
|
||||||
blocked,
|
blocked,
|
||||||
|
|||||||
@@ -508,8 +508,12 @@ export struct DmPeer {
|
|||||||
since: string,
|
since: string,
|
||||||
// Where they are now, or where they were last seen.
|
// Where they are now, or where they were last seen.
|
||||||
servers: [string],
|
servers: [string],
|
||||||
// Files linked in the conversation: "name · 2.4 MB".
|
// Pictures linked in the conversation that are downloaded, newest
|
||||||
files: [string],
|
// 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,
|
friend: bool,
|
||||||
blocked: bool,
|
blocked: bool,
|
||||||
volume: float,
|
volume: float,
|
||||||
|
|||||||
@@ -551,6 +551,62 @@ export component DmProfile inherits Rectangle {
|
|||||||
wrap: word-wrap;
|
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 { }
|
Divider { }
|
||||||
Text {
|
Text {
|
||||||
text: @tr("Shared Files — {}", Bridge.dm.files.length);
|
text: @tr("Shared Files — {}", Bridge.dm.files.length);
|
||||||
@@ -562,21 +618,31 @@ export component DmProfile inherits Rectangle {
|
|||||||
Rectangle {
|
Rectangle {
|
||||||
width: 34px;
|
width: 34px;
|
||||||
height: 34px;
|
height: 34px;
|
||||||
|
y: (parent.height - self.height) / 2;
|
||||||
border-radius: Theme.radius-md;
|
border-radius: Theme.radius-md;
|
||||||
background: Theme.danger-soft;
|
background: file.picture ? Theme.accent-soft : Theme.danger-soft;
|
||||||
Icon {
|
Icon {
|
||||||
source: Icons.file-text;
|
source: file.picture ? Icons.image : Icons.file-text;
|
||||||
size: Theme.icon-sm;
|
size: Theme.icon-sm;
|
||||||
tint: Theme.danger;
|
tint: file.picture ? Theme.accent-text : Theme.danger;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Text {
|
VerticalLayout {
|
||||||
text: file;
|
alignment: center;
|
||||||
color: Theme.text-secondary;
|
|
||||||
font-size: Theme.font-sm;
|
|
||||||
vertical-alignment: center;
|
|
||||||
horizontal-stretch: 1;
|
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 {
|
if Bridge.dm.files.length == 0: Text {
|
||||||
|
|||||||
Reference in new issue
Block a user