fix(ui): Fix contact info not being retrieved
This commit is contained in:
parent
d58f5f9a01
commit
8886c8e695
@ -63,10 +63,16 @@ class ContactsService {
|
||||
|
||||
Future<String?> getContactIdForJid(String jid) async {
|
||||
final prefs = await GetIt.I.get<PreferencesService>().getPreferences();
|
||||
if (!prefs.enableContactIntegration) return null;
|
||||
if (!prefs.enableContactIntegration) {
|
||||
_log.finest('getContactIdForJid: Returning null since enableContactIntegration is false');
|
||||
return null;
|
||||
}
|
||||
|
||||
final permission = await Permission.contacts.status;
|
||||
if (permission == PermissionStatus.denied) return null;
|
||||
if (permission == PermissionStatus.denied) {
|
||||
_log.finest("getContactIdForJid: Returning null since we don't have the contacts permission");
|
||||
return null;
|
||||
}
|
||||
|
||||
return (await _getContactIds())[jid];
|
||||
}
|
||||
@ -104,6 +110,8 @@ class ContactsService {
|
||||
conversation: newConv,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
_log.finest('Found no conversation with jid ${contact.jid}');
|
||||
}
|
||||
|
||||
final r = await rs.getRosterItemByJid(contact.jid);
|
||||
|
@ -1,4 +1,3 @@
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||
@ -108,17 +107,6 @@ class ConversationsPageState extends State<ConversationsPage> with TickerProvide
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _showAvatarFullsize(BuildContext context, String path) async {
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return IgnorePointer(
|
||||
child: Image.file(File(path)),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _listWrapper(BuildContext context, ConversationsState state) {
|
||||
final maxTextWidth = MediaQuery.of(context).size.width * 0.6;
|
||||
|
||||
@ -131,9 +119,7 @@ class ConversationsPageState extends State<ConversationsPage> with TickerProvide
|
||||
maxTextWidth,
|
||||
item,
|
||||
true,
|
||||
avatarOnTap: item.avatarUrl.isNotEmpty ?
|
||||
() => _showAvatarFullsize(context, item.avatarUrl) :
|
||||
null,
|
||||
enableAvatarOnTap: true,
|
||||
key: ValueKey('conversationRow;${item.jid}'),
|
||||
);
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
import 'package:badges/badges.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -24,7 +25,7 @@ class ConversationsListRow extends StatefulWidget {
|
||||
this.showTimestamp = true,
|
||||
this.showLock = false,
|
||||
this.extra,
|
||||
this.avatarOnTap,
|
||||
this.enableAvatarOnTap = false,
|
||||
this.avatarWidget,
|
||||
super.key,
|
||||
}
|
||||
@ -34,7 +35,7 @@ class ConversationsListRow extends StatefulWidget {
|
||||
final bool update; // Should a timer run to update the timestamp
|
||||
final bool showLock;
|
||||
final bool showTimestamp;
|
||||
final void Function()? avatarOnTap;
|
||||
final bool enableAvatarOnTap;
|
||||
final Widget? avatarWidget;
|
||||
final Widget? extra;
|
||||
|
||||
@ -100,9 +101,19 @@ class ConversationsListRowState extends State<ConversationsListRow> {
|
||||
altText: widget.conversation.title,
|
||||
);
|
||||
|
||||
if (widget.avatarOnTap != null) {
|
||||
return InkWell(
|
||||
onTap: widget.avatarOnTap,
|
||||
if (widget.enableAvatarOnTap &&
|
||||
(data != null || widget.conversation.avatarUrl.isNotEmpty)) {
|
||||
return InkWell(
|
||||
onTap: () => showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return IgnorePointer(
|
||||
child: data != null ?
|
||||
Image.memory(data) :
|
||||
Image.file(File(widget.conversation.avatarUrl)),
|
||||
);
|
||||
},
|
||||
),
|
||||
child: avatar,
|
||||
);
|
||||
}
|
||||
@ -307,15 +318,21 @@ class ConversationsListRowState extends State<ConversationsListRow> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.conversation.contactId != null && GetIt.I.get<PreferencesBloc>().state.enableContactIntegration) {
|
||||
if (widget.conversation.contactId != null &&
|
||||
GetIt.I.get<PreferencesBloc>().state.enableContactIntegration) {
|
||||
FlutterContacts.config.includeNonVisibleOnAndroid = true;
|
||||
return FutureBuilder<Contact?>(
|
||||
future: FlutterContacts.getContact(widget.conversation.contactId!),
|
||||
future: FlutterContacts.getContact(
|
||||
widget.conversation.contactId!,
|
||||
withPhoto: false,
|
||||
withProperties: false,
|
||||
),
|
||||
builder: (_, snapshot) {
|
||||
final hasData = snapshot.hasData && snapshot.data != null;
|
||||
|
||||
if (hasData) {
|
||||
return _build(
|
||||
'${snapshot.data!.name.first} ${snapshot.data!.name.last}',
|
||||
snapshot.data!.displayName,
|
||||
snapshot.data!.thumbnail,
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user