remove syncProgress from contact and wire contact row to search server's list
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Dan Ballard 2022-01-27 18:40:45 -05:00
parent a4ce168aec
commit f818d4f2f8
5 changed files with 14 additions and 12 deletions

View File

@ -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...

View File

@ -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);
syncProgress = pointFromStart.inSeconds / range.inSeconds * 100;
groups.forEach((g) { g.serverSyncProgress = syncProgress;});
syncProgress = pointFromStart.inSeconds / range.inSeconds;
notifyListeners();
}

View File

@ -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,

View File

@ -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,

View File

@ -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);