feat: the archive picker offers only projects that hold archived sessions
- the archive page passes its project set to the shared picker, built from the archived sessions' directories (deduped and sorted by name), so the sheet no longer lists every server project - the restricted picker hides the add-project action: the archive page never archives anything, so adding a project there would be pointless - the picker gained an optional onlyProjects argument; chat archives remain reachable through the Chat row - version 0.6.2+602
This commit is contained in:
1 parent
83e09e8e25
commit
8ac36b1fb1
6 files changed
+56
-12
No files matched your search
@@ -5,6 +5,15 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## 0.6.2 归档选择器只列有归档的项目(分支 `flutter`)
|
||||||
|
|
||||||
|
| 项 | 结果 |
|
||||||
|
| --- | --- |
|
||||||
|
| 筛选范围 | 归档页打开的项目选择器只列出**实际有已归档会话**的项目(按名字排序),不再显示全部项目;同时隐藏「添加项目」按钮(归档页不会新增归档,添加项目在此无意义)。聊天归档仍通过「聊天」行进入 |
|
||||||
|
| 版本 | **0.6.2(code 602)** |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 0.6.1 归档筛选改用共享项目选择器(分支 `flutter`)
|
## 0.6.1 归档筛选改用共享项目选择器(分支 `flutter`)
|
||||||
|
|
||||||
| 项 | 结果 |
|
| 项 | 结果 |
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ Android first. This branch (`flutter`) is a framework evaluation: the same
|
|||||||
feature set as the earlier Asuka/Go and MyGo attempts, reimplemented in
|
feature set as the earlier Asuka/Go and MyGo attempts, reimplemented in
|
||||||
Flutter to compare mobile UI maturity.
|
Flutter to compare mobile UI maturity.
|
||||||
|
|
||||||
Status: 0.6.1 — servers (passwordless / password login, HTTP/HTTPS and
|
Status: 0.6.2 — servers (passwordless / password login, HTTP/HTTPS and
|
||||||
SOCKS5/socks5h proxy, self-signed certificates and pinning, or a pairing link
|
SOCKS5/socks5h proxy, self-signed certificates and pinning, or a pairing link
|
||||||
over the OpenChamber private relay with end-to-end encryption; the pairing
|
over the OpenChamber private relay with end-to-end encryption; the pairing
|
||||||
link is pasted or scanned with the camera), session list with search and live
|
link is pasted or scanned with the camera), session list with search and live
|
||||||
|
|||||||
@@ -76,12 +76,31 @@ class _ArchivedSessionsScreenState extends State<ArchivedSessionsScreen> {
|
|||||||
|
|
||||||
Future<void> _refresh() => _app.refreshArchived();
|
Future<void> _refresh() => _app.refreshArchived();
|
||||||
|
|
||||||
|
/// The projects the picker offers here: only checkouts that actually hold
|
||||||
|
/// archived sessions. This page never archives anything, so a project
|
||||||
|
/// without an archive would only get in the way.
|
||||||
|
List<ProjectInfo> _archiveProjects() {
|
||||||
|
final byPath = <String, ProjectInfo>{};
|
||||||
|
for (final session in _app.archivedSessions) {
|
||||||
|
final directory = session.directory;
|
||||||
|
if (directory.isEmpty || _app.isChatDirectory(directory)) continue;
|
||||||
|
final project = _app.projectFor(directory) ??
|
||||||
|
ProjectInfo(id: '', canonical: directory, name: pathLeaf(directory));
|
||||||
|
final key = slashPath(project.canonical).toLowerCase();
|
||||||
|
byPath.putIfAbsent(key, () => project);
|
||||||
|
}
|
||||||
|
final projects = byPath.values.toList()
|
||||||
|
..sort((a, b) => a.label.toLowerCase().compareTo(b.label.toLowerCase()));
|
||||||
|
return projects;
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _pickProject() async {
|
Future<void> _pickProject() async {
|
||||||
final choice = await showProjectPicker(
|
final choice = await showProjectPicker(
|
||||||
context,
|
context,
|
||||||
app: _app,
|
app: _app,
|
||||||
selected: _bucket ?? allProjectsTarget,
|
selected: _bucket ?? allProjectsTarget,
|
||||||
includeAll: true,
|
includeAll: true,
|
||||||
|
onlyProjects: _archiveProjects(),
|
||||||
);
|
);
|
||||||
if (choice == null || !mounted) return;
|
if (choice == null || !mounted) return;
|
||||||
setState(() => _bucket = choice.isAll ? null : choice.canonical);
|
setState(() => _bucket = choice.isAll ? null : choice.canonical);
|
||||||
|
|||||||
@@ -36,13 +36,16 @@ class ProjectChoice {
|
|||||||
|
|
||||||
/// Opens the project sheet and returns the chosen target, or null when the
|
/// Opens the project sheet and returns the chosen target, or null when the
|
||||||
/// person dismissed it. [selected] is a checkout path, or [AppState.chatTarget]
|
/// person dismissed it. [selected] is a checkout path, or [AppState.chatTarget]
|
||||||
/// for the Chat row.
|
/// for the Chat row. [onlyProjects] limits the list to exactly those projects
|
||||||
|
/// (the archive page offers only projects that hold archived sessions, since
|
||||||
|
/// it never archives anything itself); null lists every selectable checkout.
|
||||||
Future<ProjectChoice?> showProjectPicker(
|
Future<ProjectChoice?> showProjectPicker(
|
||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
required AppState app,
|
required AppState app,
|
||||||
required String selected,
|
required String selected,
|
||||||
bool includeAll = false,
|
bool includeAll = false,
|
||||||
bool includeChat = true,
|
bool includeChat = true,
|
||||||
|
List<ProjectInfo>? onlyProjects,
|
||||||
}) {
|
}) {
|
||||||
return showModalBottomSheet<ProjectChoice>(
|
return showModalBottomSheet<ProjectChoice>(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -56,6 +59,7 @@ Future<ProjectChoice?> showProjectPicker(
|
|||||||
selected: selected,
|
selected: selected,
|
||||||
includeAll: includeAll,
|
includeAll: includeAll,
|
||||||
includeChat: includeChat,
|
includeChat: includeChat,
|
||||||
|
projects: onlyProjects,
|
||||||
controller: controller,
|
controller: controller,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -84,6 +88,10 @@ class _ProjectPickerSheet extends StatefulWidget {
|
|||||||
final String selected;
|
final String selected;
|
||||||
final bool includeAll;
|
final bool includeAll;
|
||||||
final bool includeChat;
|
final bool includeChat;
|
||||||
|
|
||||||
|
/// Null offers every selectable checkout; a list limits the picker to it
|
||||||
|
/// (the archive page) and hides the add-project action.
|
||||||
|
final List<ProjectInfo>? projects;
|
||||||
final ScrollController controller;
|
final ScrollController controller;
|
||||||
|
|
||||||
const _ProjectPickerSheet({
|
const _ProjectPickerSheet({
|
||||||
@@ -91,6 +99,7 @@ class _ProjectPickerSheet extends StatefulWidget {
|
|||||||
required this.selected,
|
required this.selected,
|
||||||
required this.includeAll,
|
required this.includeAll,
|
||||||
required this.includeChat,
|
required this.includeChat,
|
||||||
|
required this.projects,
|
||||||
required this.controller,
|
required this.controller,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -140,7 +149,7 @@ class _ProjectPickerSheetState extends State<_ProjectPickerSheet> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final chat = widget.selected == AppState.chatTarget;
|
final chat = widget.selected == AppState.chatTarget;
|
||||||
// A cached list is shown at once; the refresh updates it in place.
|
// A cached list is shown at once; the refresh updates it in place.
|
||||||
final projects = selectableProjects(widget.app);
|
final projects = widget.projects ?? selectableProjects(widget.app);
|
||||||
final query = _filter.trim().toLowerCase();
|
final query = _filter.trim().toLowerCase();
|
||||||
final visible = query.isEmpty
|
final visible = query.isEmpty
|
||||||
? projects
|
? projects
|
||||||
@@ -162,14 +171,15 @@ class _ProjectPickerSheetState extends State<_ProjectPickerSheet> {
|
|||||||
style:
|
style:
|
||||||
TextStyle(fontSize: 17, fontWeight: FontWeight.w600)),
|
TextStyle(fontSize: 17, fontWeight: FontWeight.w600)),
|
||||||
),
|
),
|
||||||
TextButton.icon(
|
if (widget.projects == null)
|
||||||
onPressed: _addProject,
|
TextButton.icon(
|
||||||
style: TextButton.styleFrom(
|
onPressed: _addProject,
|
||||||
visualDensity: VisualDensity.compact,
|
style: TextButton.styleFrom(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8)),
|
visualDensity: VisualDensity.compact,
|
||||||
icon: const Icon(Icons.create_new_folder_outlined, size: 18),
|
padding: const EdgeInsets.symmetric(horizontal: 8)),
|
||||||
label: const AppText('Add project'),
|
icon: const Icon(Icons.create_new_folder_outlined, size: 18),
|
||||||
),
|
label: const AppText('Add project'),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ name: openchamber
|
|||||||
description: "A lightweight OpenChamber client for phones."
|
description: "A lightweight OpenChamber client for phones."
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
|
|
||||||
version: 0.6.1+601
|
version: 0.6.2+602
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.14.0
|
sdk: ^3.14.0
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ class _FakeTransport implements Transport {
|
|||||||
body = [
|
body = [
|
||||||
{'id': 'p1', 'canonical': '/home/me/alpha', 'vcs': 'git'},
|
{'id': 'p1', 'canonical': '/home/me/alpha', 'vcs': 'git'},
|
||||||
{'id': 'p2', 'canonical': '/home/me/beta', 'vcs': 'git'},
|
{'id': 'p2', 'canonical': '/home/me/beta', 'vcs': 'git'},
|
||||||
|
// A project with no archived sessions must not be offered.
|
||||||
|
{'id': 'p3', 'canonical': '/home/me/gamma', 'vcs': 'git'},
|
||||||
];
|
];
|
||||||
} else if (r.path == '/api/config/settings') {
|
} else if (r.path == '/api/config/settings') {
|
||||||
body = {'projects': <dynamic>[]};
|
body = {'projects': <dynamic>[]};
|
||||||
@@ -92,6 +94,9 @@ void main() {
|
|||||||
// back.
|
// back.
|
||||||
await tester.tap(find.text('All projects'));
|
await tester.tap(find.text('All projects'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
// Only projects with archived sessions are offered; no add-project here.
|
||||||
|
expect(find.text('Add project'), findsNothing);
|
||||||
|
expect(find.text('/home/me/gamma'), findsNothing);
|
||||||
await tester.tap(find.text('/home/me/alpha'));
|
await tester.tap(find.text('/home/me/alpha'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.text('Old alpha'), findsOneWidget);
|
expect(find.text('Old alpha'), findsOneWidget);
|
||||||
@@ -132,6 +137,7 @@ void main() {
|
|||||||
|
|
||||||
await tester.tap(find.text('All projects'));
|
await tester.tap(find.text('All projects'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text('/home/me/gamma'), findsNothing);
|
||||||
await tester.tap(find.text('/home/me/beta'));
|
await tester.tap(find.text('/home/me/beta'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.text('Old beta'), findsOneWidget);
|
expect(find.text('Old beta'), findsOneWidget);
|
||||||
|
|||||||
Reference in new issue
Block a user