Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump version to v0.1.2 #87

Merged
merged 2 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.2 - 21/12/2024
## Added
- Listen when scan ticket error

## v0.1.1 - 18/12/2024
## Added
- Secure ticket's QR code
Expand Down
47 changes: 47 additions & 0 deletions lib/pages/ticket_details/ticket_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class TicketDetailsController extends State<TicketDetails>
_getTicketInfo();
_startQrTimer();
_listenRealtimeChanges();
_listenBroadcastError();
loggy.info('TicketDetailsController initialized');
}

Expand All @@ -92,6 +93,52 @@ class TicketDetailsController extends State<TicketDetails>
.subscribe();
}

void _listenBroadcastError() {
final key = selectedTicketId ?? ticket?.id;

if (key == null) {
return;
}

final channelName = 'error_$key';

Supabase.instance.client
.channel(
channelName,
opts: RealtimeChannelConfig(
key: key,
),
)
.onBroadcast(
event: 'scan_ticket_error',
callback: _handleBroadcastError,
)
.subscribe();
}

void _handleBroadcastError(Map<String, dynamic> payload) async {
loggy.info('Broadcast error: $payload');

await DialogUtils.show(
context: context,
title: 'Error',
description:
'Error occurred while scanning the ticket.\n If you did not scan the ticket, please contact the parking lot staff.',
svgImage: ImagePaths.imgDialogError,
actions: (context) {
return <Widget>[
ActionButton(
type: ActionButtonType.positive,
label: 'OK',
onPressed: () {
DialogUtils.hide(context);
},
),
];
},
);
}

void _handleRealtimeChanges(PostgresChangePayload payload) {
loggy.info('Realtime changes: $payload');
const table = TicketTable();
Expand Down
Loading