CI / go (Media) (push) Successful in 13m40s
CI / go (Server) (push) Failing after 23m20s
CI / go (Web-App) (push) Canceled after 0s
CI / frontend (push) Failing after 10m35s
Docs / build (push) Canceled after 0s
Docs / deploy (push) Canceled after 0s
CI / desktop (ubuntu-latest) (push) Failing after 3h4m42s
CI / desktop (macos-latest) (push) Canceled after 0s
CI / desktop (windows-latest) (push) Canceled after 0s
CI / mobile (push) Failing after 9m19s
CI / docker (push) Successful in 2h2m57s
- Columns: /columns puts 2 to 4 columns side by side, with widths dragged between them; they stack on phones. HTML export and import keep them (also Notion column lists and Confluence page layouts). - Suggesting mode: edits become suggested insertions and deletions that editors accept or reject one by one or all at once. Text only. - Verified pages: editors verify a page for a while or without end; the verifier is notified when it runs out (migration 1764700000). - Scanned PDFs attached to pages are read by AI for search where a workspace turns it on. - The server writes error messages, emails, digests and phone notifications in English, Polish, German, French and Spanish; the apps send their language with each request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
146 lines
4.6 KiB
Dart
146 lines
4.6 KiB
Dart
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
import 'package:flutter/material.dart' hide Notification, Page;
|
|
|
|
import '../api/docwell_api.dart';
|
|
import '../app.dart';
|
|
import 'page_screen.dart';
|
|
import 'widgets.dart';
|
|
import '../l10n.dart';
|
|
|
|
String notificationText(Notification n) {
|
|
final who = n.actor == null
|
|
? tr('someone')
|
|
: (n.actor!.name.isEmpty ? n.actor!.email : n.actor!.name);
|
|
return switch (n.type) {
|
|
NotificationType.comment => tr('notifComment', {'who': who}),
|
|
NotificationType.reply => tr('notifReply', {'who': who}),
|
|
NotificationType.mention => tr('notifMention', {'who': who}),
|
|
NotificationType.share => tr('notifShare', {'who': who}),
|
|
NotificationType.resolved => tr('notifResolved', {'who': who}),
|
|
NotificationType.reminder => tr('notifReminder'),
|
|
NotificationType.verifyExpired => tr('notifVerifyExpired'),
|
|
NotificationType.joinRequest => tr('notifJoinRequest', {'who': who}),
|
|
NotificationType.joinApproved => tr('notifJoinApproved'),
|
|
NotificationType.joinDeclined => tr('notifJoinDeclined'),
|
|
};
|
|
}
|
|
|
|
/// Workspace notifications have no page; their excerpt is the workspace's name.
|
|
bool isWorkspaceNotification(Notification n) =>
|
|
n.type == NotificationType.joinRequest ||
|
|
n.type == NotificationType.joinApproved ||
|
|
n.type == NotificationType.joinDeclined;
|
|
|
|
/// The inbox: mentions, replies, comments, shares and reminders, newest first.
|
|
class NotificationsScreen extends StatefulWidget {
|
|
const NotificationsScreen({super.key, required this.session});
|
|
|
|
final AppSession session;
|
|
|
|
@override
|
|
State<NotificationsScreen> createState() => _NotificationsScreenState();
|
|
}
|
|
|
|
class _NotificationsScreenState extends State<NotificationsScreen> {
|
|
DocwellApi get _api => widget.session.api;
|
|
NotificationList? _list;
|
|
String? _error;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_load();
|
|
}
|
|
|
|
Future<void> _load() async {
|
|
try {
|
|
final list = await _api.notifications();
|
|
if (mounted) {
|
|
setState(() {
|
|
_list = list;
|
|
_error = null;
|
|
});
|
|
}
|
|
} catch (e) {
|
|
if (mounted) setState(() => _error = describeError(e));
|
|
}
|
|
}
|
|
|
|
Future<void> _open(Notification n) async {
|
|
if (!n.read) await _api.markRead(ids: [n.id]).catchError((_) {});
|
|
final page = n.page;
|
|
if (page == null || !mounted) return;
|
|
await Navigator.of(context).push(
|
|
MaterialPageRoute<void>(
|
|
builder: (_) => PageScreen(
|
|
session: widget.session,
|
|
pageId: page.id,
|
|
openComment: n.comment.isEmpty ? null : n.comment,
|
|
),
|
|
),
|
|
);
|
|
_load();
|
|
}
|
|
|
|
Future<void> _readAll() async {
|
|
await _api.markRead(all: true).catchError((_) {});
|
|
_load();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final list = _list;
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text(tr('inbox')),
|
|
actions: [
|
|
if ((list?.unread ?? 0) > 0)
|
|
TextButton(onPressed: _readAll, child: Text(tr('markAllRead'))),
|
|
],
|
|
),
|
|
body: RefreshIndicator(
|
|
onRefresh: _load,
|
|
child: ListView(
|
|
children: [
|
|
if (_error != null)
|
|
ErrorTile(message: _error!, onRetry: _load)
|
|
else if (list == null)
|
|
const Padding(
|
|
padding: EdgeInsets.all(32),
|
|
child: Center(child: CircularProgressIndicator()),
|
|
)
|
|
else if (list.items.isEmpty)
|
|
ListTile(title: Text(tr('allCaughtUp'))),
|
|
for (final n in list?.items ?? <Notification>[])
|
|
ListTile(
|
|
key: Key('notification-${n.id}'),
|
|
leading: Icon(
|
|
n.read
|
|
? Icons.notifications_none
|
|
: Icons.notifications_active,
|
|
color: n.read ? null : Theme.of(context).colorScheme.primary,
|
|
),
|
|
title: Text(
|
|
isWorkspaceNotification(n)
|
|
? '${notificationText(n)} · ${n.excerpt}'
|
|
: '${notificationText(n)} · ${(n.page?.title ?? '').isNotEmpty ? n.page!.title : tr('untitled')}',
|
|
style: TextStyle(fontWeight: n.read ? null : FontWeight.w600),
|
|
),
|
|
subtitle: Text(
|
|
[
|
|
if (!isWorkspaceNotification(n)) n.excerpt,
|
|
shortDate(n.created),
|
|
].where((s) => s.isNotEmpty).join('\n'),
|
|
maxLines: 3,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
onTap: () => _open(n),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|