feat: group the server's chats and use OpenChamber's project icons
Sessions under the server's managed chats root (chats/<date>/session-…) were grouped per directory, so each one appeared as its own session-xxxxx band. GET /api/fs/home now supplies the chats root plus its canonical and legacy aliases; every chat folder becomes the single 聊天 group. The new-session picker can target 聊天 too: the first send creates a fresh chat directory before creating the session, and a new session started from an existing chat gets a new one instead of sharing its folder. Projects merge their OpenChamber settings row (label, icon key, colour, iconBackground and uploaded/auto icon image) with /api/project. Group headers, the picker and the draft chip draw the chosen icon in its colour, and custom images are fetched through the client transport (SVG included) with a themed fallback to the glyph. The chat group uses a chat bubble rather than a folder. 0.4.8 (408).
This commit is contained in:
1 parent
91bf5e5b81
commit
79221e57d7
14 files changed
+599
-32
No files matched your search
@@ -6,6 +6,7 @@ import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
|
||||
import '../api/models.dart';
|
||||
import '../state.dart';
|
||||
import '../widgets/project_icon.dart';
|
||||
import 'servers_screen.dart';
|
||||
import 'settings_screen.dart';
|
||||
|
||||
@@ -248,19 +249,13 @@ class _SessionListPaneState extends State<SessionListPane> {
|
||||
|
||||
// --------------------------------------------------------------- groups
|
||||
|
||||
bool _isChatDirectory(String directory) =>
|
||||
directory.contains('/.config/openchamber/chats');
|
||||
|
||||
String _groupLabel(String key) =>
|
||||
key == '\u0000chats' ? '聊天' : _app.projectLabelFor(key);
|
||||
|
||||
List<_SessionGroup> _groups(List<Session> sessions) {
|
||||
final map = <String, List<Session>>{};
|
||||
for (final session in sessions) {
|
||||
// Group on a separator-normalised key so a Windows server's mix of
|
||||
// `\` and `/` does not split one project into two.
|
||||
final key = _isChatDirectory(session.directory)
|
||||
? '\u0000chats'
|
||||
final key = _app.isChatDirectory(session.directory)
|
||||
? AppState.chatTarget
|
||||
: slashPath(session.directory);
|
||||
map.putIfAbsent(key, () => []).add(session);
|
||||
}
|
||||
@@ -268,9 +263,13 @@ class _SessionListPaneState extends State<SessionListPane> {
|
||||
for (final entry in map.entries)
|
||||
_SessionGroup(
|
||||
key: entry.key,
|
||||
label: _groupLabel(entry.value.first.directory),
|
||||
label: entry.key == AppState.chatTarget
|
||||
? '聊天'
|
||||
: _app.projectLabelFor(entry.value.first.directory),
|
||||
// The first session's own path: the server knows that spelling.
|
||||
path: entry.key == '\u0000chats' ? '' : entry.value.first.directory,
|
||||
path: entry.key == AppState.chatTarget
|
||||
? ''
|
||||
: entry.value.first.directory,
|
||||
sessions: entry.value
|
||||
..sort((a, b) => b.updated.compareTo(a.updated)),
|
||||
),
|
||||
@@ -320,7 +319,14 @@ class _SessionListPaneState extends State<SessionListPane> {
|
||||
Icon(collapsed ? Icons.chevron_right : Icons.expand_more,
|
||||
size: 18, color: scheme.onSurfaceVariant),
|
||||
const SizedBox(width: 2),
|
||||
Icon(Icons.folder_outlined, size: 16, color: scheme.primary),
|
||||
ProjectIcon(
|
||||
app: _app,
|
||||
project: group.key == AppState.chatTarget
|
||||
? null
|
||||
: _app.projectFor(group.path),
|
||||
chat: group.key == AppState.chatTarget,
|
||||
size: 16,
|
||||
),
|
||||
],
|
||||
),
|
||||
title: Text(
|
||||
@@ -349,8 +355,11 @@ class _SessionListPaneState extends State<SessionListPane> {
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.add, size: 20),
|
||||
padding: EdgeInsets.zero,
|
||||
tooltip: '在此项目新会话',
|
||||
onPressed: () => _newSession(directory: group.path),
|
||||
tooltip: group.key == AppState.chatTarget ? '新建聊天' : '在此项目新会话',
|
||||
onPressed: () => _newSession(
|
||||
directory: group.key == AppState.chatTarget
|
||||
? AppState.chatTarget
|
||||
: group.path),
|
||||
),
|
||||
),
|
||||
onTap: () => setState(() {
|
||||
|
||||
Reference in new issue
Block a user