calculate server progress based on last message, nowtime, and message flow; display progress on group contact and remote server #340
|
@ -26,7 +26,6 @@ class ContactInfoState extends ChangeNotifier {
|
|||
// todo: a nicer way to model contacts, groups and other "entities"
|
||||
late bool _isGroup;
|
||||
String? _server;
|
||||
double _serverSyncProgress = 0.0;
|
||||
late bool _archived;
|
||||
|
||||
String? _acnCircuit;
|
||||
|
@ -177,12 +176,6 @@ class ContactInfoState extends ChangeNotifier {
|
|||
// we only allow callers to fetch the server
|
||||
get server => this._server;
|
||||
|
||||
double get serverSyncProgress => this._serverSyncProgress;
|
||||
set serverSyncProgress(double newProgress) {
|
||||
_serverSyncProgress = newProgress;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool isOnline() {
|
||||
if (this.isGroup == true) {
|
||||
// We now have an out of sync warning so we will mark these as online...
|
||||
|
|
|
@ -42,11 +42,12 @@ class RemoteServerInfoState extends ChangeNotifier {
|
|||
notifyListeners();
|
||||
}
|
||||
|
||||
// updateSyncProgressFor point takes a message's time, and updates the server sync progress,
|
||||
// based on that point in time between the precalculated lastPreSyncMessagTime and Now
|
||||
void updateSyncProgressFor(DateTime point) {
|
||||
var range = lastPreSyncMessagTime.difference(DateTime.now());
|
||||
var pointFromStart = lastPreSyncMessagTime.difference(point);
|
||||
dan marked this conversation as resolved
|
||||
syncProgress = pointFromStart.inSeconds / range.inSeconds * 100;
|
||||
groups.forEach((g) { g.serverSyncProgress = syncProgress;});
|
||||
syncProgress = pointFromStart.inSeconds / range.inSeconds;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'package:cwtch/models/appstate.dart';
|
|||
import 'package:cwtch/models/contact.dart';
|
||||
import 'package:cwtch/models/contactlist.dart';
|
||||
import 'package:cwtch/models/profile.dart';
|
||||
import 'package:cwtch/models/profilelist.dart';
|
||||
import 'package:cwtch/views/profileserversview.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cwtch/widgets/contactrow.dart';
|
||||
|
@ -154,8 +155,15 @@ class _ContactsViewState extends State<ContactsView> {
|
|||
|
||||
Widget _buildContactList() {
|
||||
final tiles = Provider.of<ContactListState>(context).filteredList().map((ContactInfoState contact) {
|
||||
return ChangeNotifierProvider<ContactInfoState>.value(key: ValueKey(contact.profileOnion + "" + contact.onion), value: contact, builder: (_, __) => RepaintBoundary(child: ContactRow()));
|
||||
return MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider.value(value: contact),
|
||||
ChangeNotifierProvider.value(value: Provider.of<ProfileInfoState>(context).serverList),
|
||||
],
|
||||
builder: (context, child) => RepaintBoundary(child: ContactRow()),
|
||||
);
|
||||
});
|
||||
|
||||
final divided = ListTile.divideTiles(
|
||||
context: context,
|
||||
tiles: tiles,
|
||||
|
|
|
@ -67,7 +67,7 @@ class _ContactRowState extends State<ContactRow> {
|
|||
visible: contact.isGroup && contact.status == "Authenticated",
|
||||
child: LinearProgressIndicator(
|
||||
color: Provider.of<Settings>(context).theme.defaultButtonActiveColor,
|
||||
value: contact.serverSyncProgress,
|
||||
value: Provider.of<ProfileInfoState>(context).serverList.getServer(contact.server)?.syncProgress,
|
||||
)),
|
||||
Visibility(
|
||||
visible: !Provider.of<Settings>(context).streamerMode,
|
||||
|
|
|
@ -91,7 +91,7 @@ class _ProfileRowState extends State<ProfileRow> {
|
|||
return MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider<ProfileInfoState>.value(value: profile),
|
||||
ChangeNotifierProvider<ContactListState>.value(value: profile.contactList),
|
||||
ChangeNotifierProvider<ContactListState>.value(value: profile.contactList)
|
||||
],
|
||||
builder: (innercontext, widget) {
|
||||
var appState = Provider.of<AppState>(context);
|
||||
|
|
Loading…
Reference in New Issue
As above, forcing contacts to have a field to track sync progress isn't great - considering they already have an optional server handle. Groups shouldn't store this information, servers should.