Open the run's artifact from notifications
Phone and browser notifications that carry an artifact open it full screen in the artifact viewer, with an Open run action and the preview as expanded text; pipelines://artifact deep links route to the viewer.
This commit is contained in:
@@ -49,6 +49,7 @@ class NotificationController extends ChangeNotifier {
|
||||
|
||||
/// The tap seam: the manager sets this to open a run. Nothing here navigates.
|
||||
void Function(int runId)? onOpenRun;
|
||||
void Function(NotificationArtifact artifact)? onOpenArtifact;
|
||||
|
||||
NotificationLedger _ledger = const NotificationLedger();
|
||||
NotificationPermissionState _permission =
|
||||
@@ -208,17 +209,33 @@ class NotificationController extends ChangeNotifier {
|
||||
if (dismissed.contains(identity)) continue;
|
||||
if (!canNotify) continue;
|
||||
final open = onOpenRun;
|
||||
final rawArtifact = transition.entry.notificationArtifact;
|
||||
final parsedArtifact = NotificationArtifact.fromJson(rawArtifact);
|
||||
final artifact = parsedArtifact.isValid ? parsedArtifact : null;
|
||||
final message = NotificationMessage(
|
||||
runId: transition.runId,
|
||||
title: notificationAlertTitle(transition.kind),
|
||||
body: notificationAlertBody(transition.entry),
|
||||
tag: identity,
|
||||
artifact: artifact,
|
||||
preview: transition.entry.notificationPreview,
|
||||
runClick: artifact == null
|
||||
? null
|
||||
: 'pipelines://run/${transition.runId}',
|
||||
);
|
||||
var shown = false;
|
||||
try {
|
||||
shown = bridge.show(
|
||||
message,
|
||||
onTap: open == null ? null : () => open(transition.runId),
|
||||
onTap: open == null && onOpenArtifact == null
|
||||
? null
|
||||
: () {
|
||||
if (artifact != null && onOpenArtifact != null) {
|
||||
onOpenArtifact!(artifact);
|
||||
} else {
|
||||
open?.call(transition.runId);
|
||||
}
|
||||
},
|
||||
);
|
||||
} catch (_) {
|
||||
shown = false;
|
||||
|
||||
Reference in New Issue
Block a user