fc7dbb0ac0
Server: drop ntfy publishing (stage hooks, run outbox, chat attention, chat tool notify, auto-switch and schedule notices), the chat push outbox (its table is dropped at startup), ntfy status/endpoints and PIPELINES_NTFY_*. The app_notifications stream, subscribe/clear and kinds are unchanged. Notification settings keep run_finished/chat_needs_you/chat_reply_finished; ntfy_enabled is accepted and ignored and its stored row is never read. Stage type=ntfy is rejected: "ntfy stages were removed; notifications go to the Pipelines apps — use the stage notify hook". The notify hook remains. Installer: no ntfy build, accounts, config or supervisor child; manifest gets top-level "mode" (legacy ntfy.mode still read). Reinstall retires an old ntfy (safe PID-file stop, deletes binary, config, data dir, token, log, with a note in logs/install.log); uninstall cleans leftovers. App: ntfy settings section replaced by "Notification events"; texts updated. Docs: docs/ntfy.md folded into docs/notifications.md; install, docker, cli, author skill references updated; security review M1 marked resolved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
147 lines
4.5 KiB
Dart
147 lines
4.5 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../../core/api_gateway.dart';
|
|
import 'notification_settings_controller.dart';
|
|
import 'settings_group.dart';
|
|
import 'settings_theme.dart';
|
|
|
|
/// The section title for the server's notification choices.
|
|
const notificationEventsTitle = 'Notification events';
|
|
|
|
/// One line explaining that these choices are shared.
|
|
const notificationEventsSubtitle =
|
|
'What the server notifies about. Stored on the server, so these apply to '
|
|
'every device signed in to it.';
|
|
|
|
/// Shown instead of loading while the shared connection is down.
|
|
const notificationEventsOfflineText = 'Connect to a server to change these.';
|
|
|
|
ValueKey<String> notificationSettingKey(String key) =>
|
|
ValueKey<String>('notification-setting-$key');
|
|
const notificationSettingsErrorKey = ValueKey<String>(
|
|
'notification-settings-error',
|
|
);
|
|
|
|
/// The server-side notification checkboxes in Settings: run finished, chat
|
|
/// needs you and chat reply finished. Values load from the server whenever
|
|
/// [connected] becomes true and every toggle is written at once; a refusal is
|
|
/// shown inline and the checkbox reverts.
|
|
class SettingsNotificationSettingsSection extends StatefulWidget {
|
|
const SettingsNotificationSettingsSection({
|
|
super.key,
|
|
required this.gateway,
|
|
required this.connected,
|
|
});
|
|
|
|
final ApiGateway gateway;
|
|
final bool connected;
|
|
|
|
@override
|
|
State<SettingsNotificationSettingsSection> createState() =>
|
|
_SettingsNotificationSettingsSectionState();
|
|
}
|
|
|
|
class _SettingsNotificationSettingsSectionState
|
|
extends State<SettingsNotificationSettingsSection> {
|
|
late NotificationSettingsController _controller =
|
|
NotificationSettingsController(widget.gateway);
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
if (widget.connected) unawaited(_controller.load());
|
|
}
|
|
|
|
@override
|
|
void didUpdateWidget(SettingsNotificationSettingsSection oldWidget) {
|
|
super.didUpdateWidget(oldWidget);
|
|
if (oldWidget.gateway != widget.gateway) {
|
|
_controller.dispose();
|
|
_controller = NotificationSettingsController(widget.gateway);
|
|
}
|
|
if (widget.connected &&
|
|
(!oldWidget.connected || oldWidget.gateway != widget.gateway)) {
|
|
unawaited(_controller.load());
|
|
}
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_controller.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) => ListenableBuilder(
|
|
listenable: _controller,
|
|
builder: (context, _) => _body(context),
|
|
);
|
|
|
|
Widget _body(BuildContext context) {
|
|
final values = _controller.values;
|
|
final enabled = widget.connected && _controller.enabled;
|
|
final status = !widget.connected
|
|
? notificationEventsOfflineText
|
|
: _controller.loading && values == null
|
|
? 'Loading…'
|
|
: '';
|
|
final tiles = <Widget>[
|
|
for (final setting in notificationSettings)
|
|
_tile(
|
|
setting,
|
|
values?[setting.key] ?? false,
|
|
enabled ? (value) => _controller.toggle(setting.key, value) : null,
|
|
),
|
|
];
|
|
// A failed refresh keeps the last values and offers Retry beside them.
|
|
final retry =
|
|
widget.connected &&
|
|
!_controller.loading &&
|
|
(values == null || _controller.loadFailed);
|
|
return SettingsGroup(
|
|
title: notificationEventsTitle,
|
|
footer: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: <Widget>[
|
|
const Text(notificationEventsSubtitle),
|
|
if (status.isNotEmpty) Text(status),
|
|
if (_controller.error.isNotEmpty)
|
|
Semantics(
|
|
liveRegion: true,
|
|
child: Text(
|
|
_controller.error,
|
|
key: notificationSettingsErrorKey,
|
|
style: TextStyle(color: settingsErrorColor(context)),
|
|
),
|
|
),
|
|
if (_controller.error.isNotEmpty && retry)
|
|
Align(
|
|
alignment: AlignmentDirectional.centerStart,
|
|
child: TextButton(
|
|
onPressed: _controller.load,
|
|
child: const Text('Retry'),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
children: tiles,
|
|
);
|
|
}
|
|
|
|
Widget _tile(
|
|
NotificationSetting setting,
|
|
bool value,
|
|
ValueChanged<bool>? onChanged,
|
|
) {
|
|
return CheckboxListTile(
|
|
key: notificationSettingKey(setting.key),
|
|
title: Text(setting.label),
|
|
subtitle: setting.subtitle == null ? null : Text(setting.subtitle!),
|
|
value: value,
|
|
onChanged: onChanged == null ? null : (next) => onChanged(next!),
|
|
);
|
|
}
|
|
}
|