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 {
|
Future<String?> getContactIdForJid(String jid) async {
|
||||||
final prefs = await GetIt.I.get<PreferencesService>().getPreferences();
|
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;
|
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];
|
return (await _getContactIds())[jid];
|
||||||
}
|
}
|
||||||
@ -104,6 +110,8 @@ class ContactsService {
|
|||||||
conversation: newConv,
|
conversation: newConv,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
_log.finest('Found no conversation with jid ${contact.jid}');
|
||||||
}
|
}
|
||||||
|
|
||||||
final r = await rs.getRosterItemByJid(contact.jid);
|
final r = await rs.getRosterItemByJid(contact.jid);
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import 'dart:io';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||||
@ -108,17 +107,6 @@ class ConversationsPageState extends State<ConversationsPage> with TickerProvide
|
|||||||
super.dispose();
|
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) {
|
Widget _listWrapper(BuildContext context, ConversationsState state) {
|
||||||
final maxTextWidth = MediaQuery.of(context).size.width * 0.6;
|
final maxTextWidth = MediaQuery.of(context).size.width * 0.6;
|
||||||
|
|
||||||
@ -131,9 +119,7 @@ class ConversationsPageState extends State<ConversationsPage> with TickerProvide
|
|||||||
maxTextWidth,
|
maxTextWidth,
|
||||||
item,
|
item,
|
||||||
true,
|
true,
|
||||||
avatarOnTap: item.avatarUrl.isNotEmpty ?
|
enableAvatarOnTap: true,
|
||||||
() => _showAvatarFullsize(context, item.avatarUrl) :
|
|
||||||
null,
|
|
||||||
key: ValueKey('conversationRow;${item.jid}'),
|
key: ValueKey('conversationRow;${item.jid}'),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:io';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'package:badges/badges.dart';
|
import 'package:badges/badges.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -24,7 +25,7 @@ class ConversationsListRow extends StatefulWidget {
|
|||||||
this.showTimestamp = true,
|
this.showTimestamp = true,
|
||||||
this.showLock = false,
|
this.showLock = false,
|
||||||
this.extra,
|
this.extra,
|
||||||
this.avatarOnTap,
|
this.enableAvatarOnTap = false,
|
||||||
this.avatarWidget,
|
this.avatarWidget,
|
||||||
super.key,
|
super.key,
|
||||||
}
|
}
|
||||||
@ -34,7 +35,7 @@ class ConversationsListRow extends StatefulWidget {
|
|||||||
final bool update; // Should a timer run to update the timestamp
|
final bool update; // Should a timer run to update the timestamp
|
||||||
final bool showLock;
|
final bool showLock;
|
||||||
final bool showTimestamp;
|
final bool showTimestamp;
|
||||||
final void Function()? avatarOnTap;
|
final bool enableAvatarOnTap;
|
||||||
final Widget? avatarWidget;
|
final Widget? avatarWidget;
|
||||||
final Widget? extra;
|
final Widget? extra;
|
||||||
|
|
||||||
@ -100,9 +101,19 @@ class ConversationsListRowState extends State<ConversationsListRow> {
|
|||||||
altText: widget.conversation.title,
|
altText: widget.conversation.title,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (widget.avatarOnTap != null) {
|
if (widget.enableAvatarOnTap &&
|
||||||
return InkWell(
|
(data != null || widget.conversation.avatarUrl.isNotEmpty)) {
|
||||||
onTap: widget.avatarOnTap,
|
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,
|
child: avatar,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -307,15 +318,21 @@ class ConversationsListRowState extends State<ConversationsListRow> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
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?>(
|
return FutureBuilder<Contact?>(
|
||||||
future: FlutterContacts.getContact(widget.conversation.contactId!),
|
future: FlutterContacts.getContact(
|
||||||
|
widget.conversation.contactId!,
|
||||||
|
withPhoto: false,
|
||||||
|
withProperties: false,
|
||||||
|
),
|
||||||
builder: (_, snapshot) {
|
builder: (_, snapshot) {
|
||||||
final hasData = snapshot.hasData && snapshot.data != null;
|
final hasData = snapshot.hasData && snapshot.data != null;
|
||||||
|
|
||||||
if (hasData) {
|
if (hasData) {
|
||||||
return _build(
|
return _build(
|
||||||
'${snapshot.data!.name.first} ${snapshot.data!.name.last}',
|
snapshot.data!.displayName,
|
||||||
snapshot.data!.thumbnail,
|
snapshot.data!.thumbnail,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user