Skip to content

Commit a3facfc

Browse files
committed
Add a delay action
DelayAction waits a number of milliseconds before the next action runs. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VtH72Dg3rGsqwaEe62Sha4
1 parent 398978f commit a3facfc

25 files changed

Lines changed: 143 additions & 1 deletion

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Unreleased
22

3+
- `DelayAction` (`ActionType.delay`): waits `milliseconds` before the next
4+
action runs.
35
- `CanvasProperties.signInRedirectId`: a screen that needs a signed-in user
46
sends signed-out users to that canvas (`requiresSignIn`).
57
- `ListViewNode.statusVariable` and `GridViewNode.statusVariable`: a text

‎lib/src/api/models/action/action.dart‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ enum ActionType {
5555
showToast,
5656

5757
/// Ask the user to confirm, then branch on their answer.
58-
confirm;
58+
confirm,
59+
60+
/// Wait before running the next action.
61+
delay;
5962

6063
/// Displayable string representation of the [ActionType].
6164
String get prettify {
@@ -96,6 +99,8 @@ enum ActionType {
9699
return 'Show Toast';
97100
case ActionType.confirm:
98101
return 'Confirm Dialog';
102+
case ActionType.delay:
103+
return 'Delay';
99104
}
100105
}
101106
}
@@ -181,6 +186,8 @@ abstract class ActionModel with SerializableMixin {
181186
return ShowToastAction.fromJson(json);
182187
case ActionType.confirm:
183188
return ConfirmAction.fromJson(json);
189+
case ActionType.delay:
190+
return DelayAction.fromJson(json);
184191
}
185192
}
186193

‎lib/src/api/models/action/api_call_action.g.dart‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/src/api/models/action/auth_action.g.dart‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/src/api/models/action/call_function_action.g.dart‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/src/api/models/action/cloud_files_action.g.dart‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/src/api/models/action/conditional_action.g.dart‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/src/api/models/action/confirm_action.g.dart‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import 'package:equatable/equatable.dart';
2+
import 'package:json_annotation/json_annotation.dart';
3+
4+
import '../../mixins.dart';
5+
import '../models.dart';
6+
7+
part 'delay_action.g.dart';
8+
9+
/// Waits before the next action runs, e.g. to let a toast show before
10+
/// navigating away.
11+
@JsonSerializable()
12+
class DelayAction extends ActionModel with Equatable, SerializableMixin {
13+
/// How long to wait, in milliseconds.
14+
final int milliseconds;
15+
16+
/// Creates a [DelayAction].
17+
DelayAction({this.milliseconds = 500, super.nonBlocking, super.enabled})
18+
: super(type: ActionType.delay);
19+
20+
/// Duplicates this action with the given values replaced.
21+
DelayAction copyWith({int? milliseconds}) => DelayAction(
22+
milliseconds: milliseconds ?? this.milliseconds,
23+
nonBlocking: nonBlocking,
24+
enabled: enabled,
25+
);
26+
27+
@override
28+
List<Object?> get props => [milliseconds];
29+
30+
/// Creates an instance from a JSON object.
31+
factory DelayAction.fromJson(Map json) => _$DelayActionFromJson(json);
32+
33+
@override
34+
Map toJson() => _$DelayActionOmitDefaults(this, _$DelayActionToJson(this));
35+
36+
@override
37+
R? accept<R>(ActionVisitor<R> visitor) => visitor.visitDelayAction(this);
38+
}

‎lib/src/api/models/action/delay_action.g.dart‎

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)