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"],
numMessages: int.parse(data["numMessages"]),
numUnread: int.parse(data["unread"]),
isGroup: data["isGroup"] == true,
server: data["groupServer"],
archived: data["isArchived"] == true,
isGroup: false, // by definition
server: null,
archived: false,
lastMessageTime: DateTime.now(), //show at the top of the contact list even if no messages yet
));
break;
@ -220,7 +220,7 @@ class CwtchNotifier {
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);
} else {
// This is dealt with by IndexedAcknowledgment

View File

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

View File

@ -24,6 +24,18 @@ class _ContactRowState extends State<ContactRow> {
@override
Widget build(BuildContext 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(
clipBehavior: Clip.antiAlias,
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,
overflow: TextOverflow.visible,
),
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,
)),
syncStatus ?? Container(),
Visibility(
visible: !Provider.of<Settings>(context).streamerMode,
child: Text(contact.onion,
@ -128,7 +135,7 @@ class _ContactRowState extends State<ContactRow> {
Provider.of<ContactInfoState>(context, listen: false).blocked = true;
ContactInfoState contact = Provider.of<ContactInfoState>(context, listen: false);
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);
} else {
Provider.of<FlwtchState>(context, listen: false).cwtch.BlockContact(Provider.of<ContactInfoState>(context, listen: false).profileOnion, contact.identifier);