ObjectBox

This commit is contained in:
Sven committed 2025-10-23 11:28:03 +02:00
1 parent e548f62bde
commit f8317be627
60 files changed
+2367 -15049

No files matched your search

+27 -17
View File
@@ -1,8 +1,8 @@
import 'package:dart_mq/dart_mq.dart';
import 'package:flutter/material.dart';
import 'package:isar/isar.dart';
import 'package:stadtbote/content_views/accepted_jobs_page.dart';
import 'package:stadtbote/content_views/approach_area_page.dart';
import 'package:stadtbote/objectbox.g.dart';
import 'package:stadtbote/content_views/assigned_jobs_page.dart';
import 'package:stadtbote/content_views/finished_jobs_page.dart';
import 'package:stadtbote/content_views/messages_page.dart';
@@ -322,14 +322,19 @@ class _MainPageState extends State<MainPage> with ConsumerMixin, ProducerMixin {
}
void _refreshBadges() async {
_assignedJobsValueNotifier.value =
await MyApp.isarInstance.jobs.filter().stateEqualTo(0).count();
_acceptedJobsValueNotifier.value =
await MyApp.isarInstance.jobs.filter().stateEqualTo(1).count();
_messagesValueNotifier.value = await MyApp.isarInstance.chatMessages
.filter()
.readEqualTo(false)
.count();
final jobBox = MyApp.objectBoxStore.box<Job>();
final assignedQuery = jobBox.query(Job_.state.equals(0)).build();
_assignedJobsValueNotifier.value = assignedQuery.count();
assignedQuery.close();
final acceptedQuery = jobBox.query(Job_.state.equals(1)).build();
_acceptedJobsValueNotifier.value = acceptedQuery.count();
acceptedQuery.close();
final messageBox = MyApp.objectBoxStore.box<ChatMessage>();
final messageQuery = messageBox.query(ChatMessage_.read.equals(false)).build();
_messagesValueNotifier.value = messageQuery.count();
messageQuery.close();
}
void _jobReceived(Job job) {
@@ -512,10 +517,9 @@ class _HeaderWidgetState extends State<_HeaderWidget> with ConsumerMixin {
child: FittedBox(
child: GestureDetector(
onTap: () async {
var sessionStatus = await MyApp
.isarInstance.sessionStatus
.where()
.findFirst();
final box = MyApp.objectBoxStore.box<SessionStatus>();
final sessions = box.getAll();
var sessionStatus = sessions.isNotEmpty ? sessions.first : null;
showInfosPopup(sessionStatus);
},
@@ -643,9 +647,13 @@ class _HeaderWidgetState extends State<_HeaderWidget> with ConsumerMixin {
}
_updateHeader() async {
var status = await MyApp.isarInstance.locationStatus.where().findFirst();
var sessionStatus =
await MyApp.isarInstance.sessionStatus.where().findFirst();
final locationBox = MyApp.objectBoxStore.box<LocationStatus>();
final locations = locationBox.getAll();
var status = locations.isNotEmpty ? locations.first : null;
final sessionBox = MyApp.objectBoxStore.box<SessionStatus>();
final sessions = sessionBox.getAll();
var sessionStatus = sessions.isNotEmpty ? sessions.first : null;
if (status != null) {
_zipValueNotifier.value = status.zip;
@@ -664,7 +672,9 @@ class _HeaderWidgetState extends State<_HeaderWidget> with ConsumerMixin {
/*
rightButtonImage: Util.fetchFutureIcon(const Icon(Icons.info_outline, size: 20.0, color: Colors.white)),
rightButtonOnPressed: () async {
showInfosPopup(await MyApp.isarInstance.sessionStatus.where().findFirst());
final box = MyApp.objectBoxStore.box<SessionStatus>();
final sessions = box.getAll();
showInfosPopup(sessions.isNotEmpty ? sessions.first : null);
});
*/
}