Merge pull request 'Fix contact.server NSE in contact list sync state' (#352) from fastercwtch into gherkin

Reviewed-on: #352
This commit is contained in:
Sarah Jamie Lewis 2022-02-03 17:18:52 +00:00
commit 42dedc76e4
3 changed files with 19 additions and 12 deletions

View File

@ -71,9 +71,9 @@ class CwtchNotifier {
savePeerHistory: data["saveConversationHistory"] == null ? "DeleteHistoryConfirmed" : data["saveConversationHistory"], savePeerHistory: data["saveConversationHistory"] == null ? "DeleteHistoryConfirmed" : data["saveConversationHistory"],
numMessages: int.parse(data["numMessages"]), numMessages: int.parse(data["numMessages"]),
numUnread: int.parse(data["unread"]), numUnread: int.parse(data["unread"]),
isGroup: data["isGroup"] == true, isGroup: false, // by definition
server: data["groupServer"], server: null,
archived: data["isArchived"] == true, archived: false,
lastMessageTime: DateTime.now(), //show at the top of the contact list even if no messages yet lastMessageTime: DateTime.now(), //show at the top of the contact list even if no messages yet
)); ));
break; break;
@ -220,7 +220,7 @@ class CwtchNotifier {
notificationManager.notify("New Message From Group!"); notificationManager.notify("New Message From Group!");
} }
RemoteServerInfoState? server = profileCN.getProfile(data["ProfileOnion"])?.serverList.getServer(contact.server); RemoteServerInfoState? server = profileCN.getProfile(data["ProfileOnion"])?.serverList.getServer(contact.server ?? "");
server?.updateSyncProgressFor(timestampSent); server?.updateSyncProgressFor(timestampSent);
} else { } else {
// This is dealt with by IndexedAcknowledgment // This is dealt with by IndexedAcknowledgment

View File

@ -174,7 +174,7 @@ class ContactInfoState extends ChangeNotifier {
} }
// we only allow callers to fetch the server // we only allow callers to fetch the server
get server => this._server; String? get server => this._server;
bool isOnline() { bool isOnline() {
if (this.isGroup == true) { if (this.isGroup == true) {

View File

@ -24,6 +24,18 @@ class _ContactRowState extends State<ContactRow> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var contact = Provider.of<ContactInfoState>(context); var contact = Provider.of<ContactInfoState>(context);
// Only groups have a sync status
Widget? syncStatus;
if (contact.isGroup) {
syncStatus = Visibility(
visible: contact.isGroup && contact.status == "Authenticated",
child: LinearProgressIndicator(
color: Provider.of<Settings>(context).theme.defaultButtonActiveColor,
value: Provider.of<ProfileInfoState>(context).serverList.getServer(contact.server ?? "")?.syncProgress,
));
}
return Card( return Card(
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
color: Provider.of<AppState>(context).selectedConversation == contact.identifier ? Provider.of<Settings>(context).theme.backgroundHilightElementColor : null, color: Provider.of<AppState>(context).selectedConversation == contact.identifier ? Provider.of<Settings>(context).theme.backgroundHilightElementColor : null,
@ -63,12 +75,7 @@ class _ContactRowState extends State<ContactRow> {
softWrap: true, softWrap: true,
overflow: TextOverflow.visible, overflow: TextOverflow.visible,
), ),
Visibility( syncStatus ?? Container(),
visible: contact.isGroup && contact.status == "Authenticated",
child: LinearProgressIndicator(
color: Provider.of<Settings>(context).theme.defaultButtonActiveColor,
value: Provider.of<ProfileInfoState>(context).serverList.getServer(contact.server)?.syncProgress,
)),
Visibility( Visibility(
visible: !Provider.of<Settings>(context).streamerMode, visible: !Provider.of<Settings>(context).streamerMode,
child: Text(contact.onion, child: Text(contact.onion,
@ -128,7 +135,7 @@ class _ContactRowState extends State<ContactRow> {
Provider.of<ContactInfoState>(context, listen: false).blocked = true; Provider.of<ContactInfoState>(context, listen: false).blocked = true;
ContactInfoState contact = Provider.of<ContactInfoState>(context, listen: false); ContactInfoState contact = Provider.of<ContactInfoState>(context, listen: false);
if (contact.isGroup == true) { if (contact.isGroup == true) {
// FIXME This flow is incrorect. Groups never just show up on the contact list anymore // FIXME This flow is incorrect. Groups never just show up on the contact list anymore
Provider.of<ProfileInfoState>(context, listen: false).removeContact(contact.onion); Provider.of<ProfileInfoState>(context, listen: false).removeContact(contact.onion);
} else { } else {
Provider.of<FlwtchState>(context, listen: false).cwtch.BlockContact(Provider.of<ContactInfoState>(context, listen: false).profileOnion, contact.identifier); Provider.of<FlwtchState>(context, listen: false).cwtch.BlockContact(Provider.of<ContactInfoState>(context, listen: false).profileOnion, contact.identifier);