Skip to content

Commit

Permalink
sign in to event refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
miakh committed Nov 16, 2023
1 parent 8641bee commit bddb9ce
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -313,25 +313,26 @@ void didChangeDependencies() {

_eventPressed(int id) {
Navigator.pushNamed(
context, EventPage.ROUTE, arguments: id).then((value) => loadData());
context, EventPage.ROUTE, arguments: id).then((value) => loadEventParticipants()).then((value) => loadData(false));
}

int _messageCount = 0;
bool showMessageCount() => _messageCount>0;
String messageCountString() => _messageCount<100?_messageCount.toString():"99";
Future<void> loadData() async {

Future<void> loadData([bool reloadEventParticipants = true]) async {
//get data from offline
try
{
var eventData = StorageHelper.Get("events");
if(eventData!=null && _events.isEmpty)
{
var offlineEventsData = json.decode(eventData);
_events.addAll(List<EventModel>.from(offlineEventsData.map((o)=>EventModel.fromJson(o))));
_dots.clear();
_dots.addAll(_events.map((e) => TimeLineItem.fromEventModel(e)));
setState((){});
setState((){
_events.addAll(List<EventModel>.from(offlineEventsData.map((o)=>EventModel.fromJson(o))));
_dots.clear();
_dots.addAll(_events.map((e) => TimeLineItem.fromEventModel(e)));
});
}
}
catch(e)
Expand All @@ -357,7 +358,10 @@ void didChangeDependencies() {
setState(() {
_messageCount = count;
});
})
.whenComplete(() async => await loadEventParticipants());
});
if(reloadEventParticipants)
{
loadEventParticipants();
}
}
}

0 comments on commit bddb9ce

Please sign in to comment.