Fehlerkorrekturen und Erweiterungen

This commit is contained in:
Sven committed 2025-01-29 11:07:37 +01:00
1 parent 584f7dc8f7
commit 81133905de
38 files changed
+1003 -222

No files matched your search

+21 -36
View File
@@ -22,6 +22,7 @@ import 'package:stadtbote/tools/messages/job_deleted_message.dart';
import 'package:stadtbote/tools/messages/job_received_message.dart';
import 'package:stadtbote/tools/messages/refresh_badges_message.dart';
import 'package:stadtbote/tools/messages/remove_job_message.dart';
import 'package:stadtbote/tools/messages/remove_state_0_job_from_map.dart';
import 'package:stadtbote/tools/mqtt_core.dart';
import 'content_views/main_page.dart';
@@ -53,6 +54,7 @@ Future<void> main() async {
MQClient.instance.declareQueue(Constants.messageTopicJobReceived);
MQClient.instance.declareQueue(Constants.messageTopicMessageReceived);
MQClient.instance.declareQueue(Constants.messageTopicUpdateBadges);
MQClient.instance.declareQueue(Constants.messageTopicRemoveState0JobFromMap);
final dir = await getApplicationDocumentsDirectory();
MyApp.isarInstance = await Isar.open([
@@ -190,7 +192,7 @@ class _MainState extends State<Main> with SingleTickerProviderStateMixin, Produc
final ValueNotifier<bool> _connectionLostValueNotifier = ValueNotifier<bool>(true);
late AnimationController _animationController;
late AnimationController? _animationController = null;
late Animation<double> _animation;
Timer? _checkForNewState0JobsJobsTimer;
@@ -199,13 +201,20 @@ class _MainState extends State<Main> with SingleTickerProviderStateMixin, Produc
late SharedMap<int, Job>? _jobMap;
@override
void dispose() {
_animationController?.dispose();
super.dispose();
}
@override
void initState() {
super.initState();
_animationController = AnimationController(vsync: this, duration: const Duration(milliseconds: 1000));
_animationController.repeat(reverse: true);
_animation = Tween<double>(begin: 0.5, end: 1.0).animate(_animationController);
_animationController!.repeat(reverse: true);
_animation = Tween<double>(begin: 0.5, end: 1.0).animate(_animationController!);
WidgetsBinding.instance.addPostFrameCallback((_) async {
var store1 = SharedStore('jobs');
@@ -308,9 +317,6 @@ class _MainState extends State<Main> with SingleTickerProviderStateMixin, Produc
_pushContentView(widget);
},
);
/*MessageService().subscribe<ContentViewWidget>(Constants.messageTopicPushContentView, this, (ContentViewWidget widget) {
_pushContentView(widget);
});*/
subscribe(
queueId: Constants.messageTopicPopContentView,
@@ -319,9 +325,6 @@ class _MainState extends State<Main> with SingleTickerProviderStateMixin, Produc
_popContentView(popContentViewMessage.count);
},
);
/*MessageService().subscribe<PopContentViewMessage>(Constants.messageTopicPopContentView, this, (PopContentViewMessage message) {
_popContentView(message.count);
});*/
subscribe(
queueId: Constants.messageTopicReplaceContentView,
@@ -330,9 +333,6 @@ class _MainState extends State<Main> with SingleTickerProviderStateMixin, Produc
_replaceContentView(widget);
},
);
/*MessageService().subscribe<ContentViewWidget>(Constants.messageTopicReplaceContentView, this, (ContentViewWidget widget) {
_replaceContentView(widget);
});*/
subscribe(
queueId: Constants.messageTopicConnectionStatusChanged,
@@ -341,9 +341,6 @@ class _MainState extends State<Main> with SingleTickerProviderStateMixin, Produc
_connectionStatusChanged(connectionStatus);
},
);
/*MessageService().subscribe<ConnectionStatus>(Constants.messageTopicConnectionStatusChanged, this, (ConnectionStatus connectionStatus) {
_connectionStatusChanged(connectionStatus);
});*/
subscribe(
queueId: Constants.messageTopicRemoveJob,
@@ -354,30 +351,17 @@ class _MainState extends State<Main> with SingleTickerProviderStateMixin, Produc
await MyApp.isarInstance.jobs.where().filter().idEqualTo(removeJobMessage.id).deleteAll();
});
// TODO MESSAGING
sendMessage(
routingKey: Constants.messageTopicJobDeleted,
payload: JobDeletedMessage(id: removeJobMessage.id),
);
//await MessageService().publish<JobDeletedMessage>(Constants.messageTopicJobDeleted, arguments: JobDeletedMessage(id: job.id));
// TODO MESSAGING
sendMessage(
routingKey: Constants.messageTopicUpdateBadges,
payload: RefreshBadgesMessage,
);
//await MessageService().publish<RefreshBadgesMessage>(Constants.messageTopicUpdateBadges, arguments: RefreshBadgesMessage());
},
);
/*MessageService().subscribe<RemoveJobMessage>(Constants.messageTopicRemoveJob, this, (RemoveJobMessage job) async {
await MyApp.isarInstance.writeTxn(() async {
await MyApp.isarInstance.jobs.where().filter().idEqualTo(job.id).deleteAll();
});
await MessageService().publish<JobDeletedMessage>(Constants.messageTopicJobDeleted, arguments: JobDeletedMessage(id: job.id));
await MessageService().publish<RefreshBadgesMessage>(Constants.messageTopicUpdateBadges, arguments: RefreshBadgesMessage());
});*/
subscribe(
queueId: Constants.messageTopicJobReceived,
@@ -388,11 +372,6 @@ class _MainState extends State<Main> with SingleTickerProviderStateMixin, Produc
}
},
);
/*MessageService().subscribe<JobReceivedMessage>(Constants.messageTopicJobReceived, this, (JobReceivedMessage jobReceivedMessage) async {
if (jobReceivedMessage.job.state == 0) {
await _jobMap!.put(jobReceivedMessage.job.id, jobReceivedMessage.job);
}
});*/
subscribe(
queueId: Constants.messageTopicJobDeleted,
@@ -401,9 +380,15 @@ class _MainState extends State<Main> with SingleTickerProviderStateMixin, Produc
await _jobMap!.remove(jobDeleted.id);
},
);
/*MessageService().subscribe<JobDeletedMessage>(Constants.messageTopicJobDeleted, this, (JobDeletedMessage jobDeletedMessage) async {
await _jobMap!.remove(jobDeletedMessage.id);
});*/
subscribe(
queueId: Constants.messageTopicRemoveState0JobFromMap,
callback: (message) async {
var removeState0JobFromMap = message.payload as RemoveState0JobFromMapMessage;
await _jobMap!.remove(removeState0JobFromMap.jobId);
},
);
}
void _replaceContentView(ContentViewWidget widget) async {