mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2024-12-24 23:29:32 -05:00
note to self
This commit is contained in:
parent
c63eee26fd
commit
f951acd79a
@ -1,11 +1,9 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_animate/flutter_animate.dart';
|
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||||
import 'package:flutter_translate/flutter_translate.dart';
|
import 'package:flutter_translate/flutter_translate.dart';
|
||||||
import '../../entities/proto.dart' as proto;
|
import '../../entities/proto.dart' as proto;
|
||||||
import '../pages/main_pager/main_pager.dart';
|
|
||||||
import '../providers/account.dart';
|
import '../providers/account.dart';
|
||||||
import '../providers/chat.dart';
|
import '../providers/chat.dart';
|
||||||
import '../tools/theme_service.dart';
|
import '../tools/theme_service.dart';
|
||||||
@ -19,7 +17,7 @@ class ChatSingleContactItemWidget extends ConsumerWidget {
|
|||||||
// ignore: prefer_expression_function_bodies
|
// ignore: prefer_expression_function_bodies
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
final textTheme = theme.textTheme;
|
//final textTheme = theme.textTheme;
|
||||||
final scale = theme.extension<ScaleScheme>()!;
|
final scale = theme.extension<ScaleScheme>()!;
|
||||||
|
|
||||||
final activeChat = ref.watch(activeChatStateProvider).asData?.value;
|
final activeChat = ref.watch(activeChatStateProvider).asData?.value;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import 'package:awesome_extensions/awesome_extensions.dart';
|
import 'package:awesome_extensions/awesome_extensions.dart';
|
||||||
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_translate/flutter_translate.dart';
|
import 'package:flutter_translate/flutter_translate.dart';
|
||||||
@ -9,9 +8,7 @@ import 'package:searchable_listview/searchable_listview.dart';
|
|||||||
import '../../entities/proto.dart' as proto;
|
import '../../entities/proto.dart' as proto;
|
||||||
import '../tools/tools.dart';
|
import '../tools/tools.dart';
|
||||||
import 'chat_single_contact_item_widget.dart';
|
import 'chat_single_contact_item_widget.dart';
|
||||||
import 'contact_item_widget.dart';
|
|
||||||
import 'empty_chat_list_widget.dart';
|
import 'empty_chat_list_widget.dart';
|
||||||
import 'empty_contact_list_widget.dart';
|
|
||||||
|
|
||||||
class ChatSingleContactListWidget extends ConsumerWidget {
|
class ChatSingleContactListWidget extends ConsumerWidget {
|
||||||
ChatSingleContactListWidget(
|
ChatSingleContactListWidget(
|
||||||
|
@ -20,7 +20,7 @@ class ContactItemWidget extends ConsumerWidget {
|
|||||||
// ignore: prefer_expression_function_bodies
|
// ignore: prefer_expression_function_bodies
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
final textTheme = theme.textTheme;
|
//final textTheme = theme.textTheme;
|
||||||
final scale = theme.extension<ScaleScheme>()!;
|
final scale = theme.extension<ScaleScheme>()!;
|
||||||
|
|
||||||
final remoteConversationKey =
|
final remoteConversationKey =
|
||||||
@ -78,7 +78,9 @@ class ContactItemWidget extends ConsumerWidget {
|
|||||||
await getOrCreateChatSingleContact(
|
await getOrCreateChatSingleContact(
|
||||||
activeAccountInfo: activeAccountInfo,
|
activeAccountInfo: activeAccountInfo,
|
||||||
remoteConversationRecordKey: remoteConversationKey);
|
remoteConversationRecordKey: remoteConversationKey);
|
||||||
|
ref
|
||||||
|
..invalidate(fetchContactListProvider)
|
||||||
|
..invalidate(fetchChatListProvider);
|
||||||
// Click over to chats
|
// Click over to chats
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
await MainPager.of(context)?.pageController.animateToPage(
|
await MainPager.of(context)?.pageController.animateToPage(
|
||||||
|
@ -5,7 +5,6 @@ import 'package:flutter/foundation.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_translate/flutter_translate.dart';
|
import 'package:flutter_translate/flutter_translate.dart';
|
||||||
import 'package:quickalert/quickalert.dart';
|
|
||||||
|
|
||||||
import '../entities/local_account.dart';
|
import '../entities/local_account.dart';
|
||||||
import '../providers/account.dart';
|
import '../providers/account.dart';
|
||||||
@ -61,15 +60,22 @@ class PasteInviteDialogState extends ConsumerState<PasteInviteDialog> {
|
|||||||
final acceptedContact =
|
final acceptedContact =
|
||||||
await acceptContactInvitation(activeAccountInfo, validInvitation);
|
await acceptContactInvitation(activeAccountInfo, validInvitation);
|
||||||
if (acceptedContact != null) {
|
if (acceptedContact != null) {
|
||||||
await createContact(
|
// initiator when accept is received will create
|
||||||
activeAccountInfo: activeAccountInfo,
|
// contact in the case of a 'note to self'
|
||||||
profile: acceptedContact.profile,
|
final isSelf =
|
||||||
remoteIdentity: acceptedContact.remoteIdentity,
|
activeAccountInfo.localAccount.identityMaster.identityPublicKey ==
|
||||||
remoteConversationRecordKey:
|
acceptedContact.remoteIdentity.identityPublicKey;
|
||||||
acceptedContact.remoteConversationRecordKey,
|
if (!isSelf) {
|
||||||
localConversationRecordKey:
|
await createContact(
|
||||||
acceptedContact.localConversationRecordKey,
|
activeAccountInfo: activeAccountInfo,
|
||||||
);
|
profile: acceptedContact.profile,
|
||||||
|
remoteIdentity: acceptedContact.remoteIdentity,
|
||||||
|
remoteConversationRecordKey:
|
||||||
|
acceptedContact.remoteConversationRecordKey,
|
||||||
|
localConversationRecordKey:
|
||||||
|
acceptedContact.localConversationRecordKey,
|
||||||
|
);
|
||||||
|
}
|
||||||
ref
|
ref
|
||||||
..invalidate(fetchContactInvitationRecordsProvider)
|
..invalidate(fetchContactInvitationRecordsProvider)
|
||||||
..invalidate(fetchContactListProvider);
|
..invalidate(fetchContactListProvider);
|
||||||
@ -154,6 +160,8 @@ class PasteInviteDialogState extends ConsumerState<PasteInviteDialog> {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
final contactInvitationRecords =
|
||||||
|
await ref.read(fetchContactInvitationRecordsProvider.future);
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_validatingPaste = true;
|
_validatingPaste = true;
|
||||||
@ -161,6 +169,7 @@ class PasteInviteDialogState extends ConsumerState<PasteInviteDialog> {
|
|||||||
});
|
});
|
||||||
final validatedContactInvitation = await validateContactInvitation(
|
final validatedContactInvitation = await validateContactInvitation(
|
||||||
activeAccountInfo: activeAccountInfo,
|
activeAccountInfo: activeAccountInfo,
|
||||||
|
contactInvitationRecords: contactInvitationRecords,
|
||||||
inviteData: inviteData,
|
inviteData: inviteData,
|
||||||
getEncryptionKeyCallback:
|
getEncryptionKeyCallback:
|
||||||
(cs, encryptionKeyType, encryptedSecret) async {
|
(cs, encryptionKeyType, encryptedSecret) async {
|
||||||
|
@ -2,8 +2,6 @@ import 'package:awesome_extensions/awesome_extensions.dart';
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_translate/flutter_translate.dart';
|
|
||||||
import 'package:go_router/go_router.dart';
|
|
||||||
|
|
||||||
import '../tools/tools.dart';
|
import '../tools/tools.dart';
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ Future<AcceptedOrRejectedContact?> checkAcceptRejectContact(
|
|||||||
activeAccountInfo: activeAccountInfo,
|
activeAccountInfo: activeAccountInfo,
|
||||||
contactInvitationRecord: contactInvitationRecord);
|
contactInvitationRecord: contactInvitationRecord);
|
||||||
|
|
||||||
return null;
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,6 +327,7 @@ typedef GetEncryptionKeyCallback = Future<SecretKey?> Function(
|
|||||||
|
|
||||||
Future<ValidContactInvitation?> validateContactInvitation(
|
Future<ValidContactInvitation?> validateContactInvitation(
|
||||||
{required ActiveAccountInfo activeAccountInfo,
|
{required ActiveAccountInfo activeAccountInfo,
|
||||||
|
required IList<ContactInvitationRecord>? contactInvitationRecords,
|
||||||
required Uint8List inviteData,
|
required Uint8List inviteData,
|
||||||
required GetEncryptionKeyCallback getEncryptionKeyCallback}) async {
|
required GetEncryptionKeyCallback getEncryptionKeyCallback}) async {
|
||||||
final accountRecordKey =
|
final accountRecordKey =
|
||||||
@ -349,10 +350,13 @@ Future<ValidContactInvitation?> validateContactInvitation(
|
|||||||
final cs = await pool.veilid.getCryptoSystem(contactRequestInboxKey.kind);
|
final cs = await pool.veilid.getCryptoSystem(contactRequestInboxKey.kind);
|
||||||
|
|
||||||
// See if we're chatting to ourselves, if so, don't delete it here
|
// See if we're chatting to ourselves, if so, don't delete it here
|
||||||
final ownKey = pool.getParentRecord(contactRequestInboxKey) != null;
|
final isSelf = contactInvitationRecords?.indexWhere((cir) =>
|
||||||
|
proto.TypedKeyProto.fromProto(cir.contactRequestInbox.recordKey) ==
|
||||||
|
contactRequestInboxKey) !=
|
||||||
|
-1;
|
||||||
|
|
||||||
await (await pool.openRead(contactRequestInboxKey, parent: accountRecordKey))
|
await (await pool.openRead(contactRequestInboxKey, parent: accountRecordKey))
|
||||||
.maybeDeleteScope(!ownKey, (contactRequestInbox) async {
|
.maybeDeleteScope(!isSelf, (contactRequestInbox) async {
|
||||||
//
|
//
|
||||||
final contactRequest =
|
final contactRequest =
|
||||||
await contactRequestInbox.getProtobuf(proto.ContactRequest.fromBuffer);
|
await contactRequestInbox.getProtobuf(proto.ContactRequest.fromBuffer);
|
||||||
@ -410,9 +414,9 @@ Future<AcceptedContact?> acceptContactInvitation(
|
|||||||
final pool = await DHTRecordPool.instance();
|
final pool = await DHTRecordPool.instance();
|
||||||
try {
|
try {
|
||||||
// Ensure we don't delete this if we're trying to chat to self
|
// Ensure we don't delete this if we're trying to chat to self
|
||||||
final ownKey =
|
final isSelf =
|
||||||
pool.getParentRecord(validContactInvitation.contactRequestInboxKey) !=
|
validContactInvitation.contactIdentityMaster.identityPublicKey ==
|
||||||
null;
|
activeAccountInfo.localAccount.identityMaster.identityPublicKey;
|
||||||
final accountRecordKey =
|
final accountRecordKey =
|
||||||
activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
|
activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
|
||||||
|
|
||||||
@ -420,7 +424,7 @@ Future<AcceptedContact?> acceptContactInvitation(
|
|||||||
validContactInvitation.writer,
|
validContactInvitation.writer,
|
||||||
parent: accountRecordKey))
|
parent: accountRecordKey))
|
||||||
// ignore: prefer_expression_function_bodies
|
// ignore: prefer_expression_function_bodies
|
||||||
.maybeDeleteScope(!ownKey, (contactRequestInbox) async {
|
.maybeDeleteScope(!isSelf, (contactRequestInbox) async {
|
||||||
// Create local conversation key for this
|
// Create local conversation key for this
|
||||||
// contact and send via contact response
|
// contact and send via contact response
|
||||||
return createConversation(
|
return createConversation(
|
||||||
@ -475,16 +479,16 @@ Future<bool> rejectContactInvitation(ActiveAccountInfo activeAccountInfo,
|
|||||||
final pool = await DHTRecordPool.instance();
|
final pool = await DHTRecordPool.instance();
|
||||||
|
|
||||||
// Ensure we don't delete this if we're trying to chat to self
|
// Ensure we don't delete this if we're trying to chat to self
|
||||||
final ownKey =
|
final isSelf =
|
||||||
pool.getParentRecord(validContactInvitation.contactRequestInboxKey) !=
|
validContactInvitation.contactIdentityMaster.identityPublicKey ==
|
||||||
null;
|
activeAccountInfo.localAccount.identityMaster.identityPublicKey;
|
||||||
final accountRecordKey =
|
final accountRecordKey =
|
||||||
activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
|
activeAccountInfo.userLogin.accountRecordInfo.accountRecord.recordKey;
|
||||||
|
|
||||||
return (await pool.openWrite(validContactInvitation.contactRequestInboxKey,
|
return (await pool.openWrite(validContactInvitation.contactRequestInboxKey,
|
||||||
validContactInvitation.writer,
|
validContactInvitation.writer,
|
||||||
parent: accountRecordKey))
|
parent: accountRecordKey))
|
||||||
.maybeDeleteScope(!ownKey, (contactRequestInbox) async {
|
.maybeDeleteScope(!isSelf, (contactRequestInbox) async {
|
||||||
final cs = await pool.veilid
|
final cs = await pool.veilid
|
||||||
.getCryptoSystem(validContactInvitation.contactRequestInboxKey.kind);
|
.getCryptoSystem(validContactInvitation.contactRequestInboxKey.kind);
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_chat_ui/flutter_chat_ui.dart';
|
|
||||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user