mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2024-10-01 06:55:46 -04:00
log fix for ios and ability to delete orphaned chats
This commit is contained in:
parent
47287ba8d4
commit
22390f31ff
@ -233,6 +233,7 @@
|
|||||||
"password_does_not_match": "Password does not match"
|
"password_does_not_match": "Password does not match"
|
||||||
},
|
},
|
||||||
"chat_list": {
|
"chat_list": {
|
||||||
|
"deleted_contact": "Deleted Contact",
|
||||||
"search": "Search chats",
|
"search": "Search chats",
|
||||||
"start_a_conversation": "Start A Conversation",
|
"start_a_conversation": "Start A Conversation",
|
||||||
"chats": "Chats",
|
"chats": "Chats",
|
||||||
|
@ -18,10 +18,10 @@ class ChatListWidget extends StatelessWidget {
|
|||||||
Widget _itemBuilderDirect(
|
Widget _itemBuilderDirect(
|
||||||
proto.DirectChat direct, IMap<proto.TypedKey, proto.Contact> contactMap) {
|
proto.DirectChat direct, IMap<proto.TypedKey, proto.Contact> contactMap) {
|
||||||
final contact = contactMap[direct.localConversationRecordKey];
|
final contact = contactMap[direct.localConversationRecordKey];
|
||||||
if (contact == null) {
|
return ChatSingleContactItemWidget(
|
||||||
return const Text('...');
|
localConversationRecordKey:
|
||||||
}
|
direct.localConversationRecordKey.toVeilid(),
|
||||||
return ChatSingleContactItemWidget(contact: contact)
|
contact: contact)
|
||||||
.paddingLTRB(0, 4, 0, 0);
|
.paddingLTRB(0, 4, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ import 'package:async_tools/async_tools.dart';
|
|||||||
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_translate/flutter_translate.dart';
|
import 'package:flutter_translate/flutter_translate.dart';
|
||||||
|
import 'package:veilid_support/veilid_support.dart';
|
||||||
import '../../chat/cubits/active_chat_cubit.dart';
|
import '../../chat/cubits/active_chat_cubit.dart';
|
||||||
import '../../contacts/contacts.dart';
|
import '../../contacts/contacts.dart';
|
||||||
import '../../proto/proto.dart' as proto;
|
import '../../proto/proto.dart' as proto;
|
||||||
@ -10,13 +11,16 @@ import '../chat_list.dart';
|
|||||||
|
|
||||||
class ChatSingleContactItemWidget extends StatelessWidget {
|
class ChatSingleContactItemWidget extends StatelessWidget {
|
||||||
const ChatSingleContactItemWidget({
|
const ChatSingleContactItemWidget({
|
||||||
required proto.Contact contact,
|
required TypedKey localConversationRecordKey,
|
||||||
|
required proto.Contact? contact,
|
||||||
bool disabled = false,
|
bool disabled = false,
|
||||||
super.key,
|
super.key,
|
||||||
}) : _contact = contact,
|
}) : _localConversationRecordKey = localConversationRecordKey,
|
||||||
|
_contact = contact,
|
||||||
_disabled = disabled;
|
_disabled = disabled;
|
||||||
|
|
||||||
final proto.Contact _contact;
|
final TypedKey _localConversationRecordKey;
|
||||||
|
final proto.Contact? _contact;
|
||||||
final bool _disabled;
|
final bool _disabled;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -29,13 +33,16 @@ class ChatSingleContactItemWidget extends StatelessWidget {
|
|||||||
final scaleConfig = theme.extension<ScaleConfig>()!;
|
final scaleConfig = theme.extension<ScaleConfig>()!;
|
||||||
|
|
||||||
final activeChatCubit = context.watch<ActiveChatCubit>();
|
final activeChatCubit = context.watch<ActiveChatCubit>();
|
||||||
final localConversationRecordKey =
|
final selected = activeChatCubit.state == _localConversationRecordKey;
|
||||||
_contact.localConversationRecordKey.toVeilid();
|
|
||||||
final selected = activeChatCubit.state == localConversationRecordKey;
|
|
||||||
|
|
||||||
final name = _contact.nameOrNickname;
|
final name = _contact == null ? '?' : _contact.nameOrNickname;
|
||||||
final title = _contact.displayName;
|
final title = _contact == null
|
||||||
final subtitle = _contact.profile.status;
|
? translate('chat_list.deleted_contact')
|
||||||
|
: _contact.displayName;
|
||||||
|
final subtitle = _contact == null ? '' : _contact.profile.status;
|
||||||
|
final availability = _contact == null
|
||||||
|
? proto.Availability.AVAILABILITY_UNSPECIFIED
|
||||||
|
: _contact.profile.availability;
|
||||||
|
|
||||||
final avatar = AvatarWidget(
|
final avatar = AvatarWidget(
|
||||||
name: name,
|
name: name,
|
||||||
@ -53,17 +60,17 @@ class ChatSingleContactItemWidget extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return SliderTile(
|
return SliderTile(
|
||||||
key: ObjectKey(_contact),
|
key: ValueKey(_localConversationRecordKey),
|
||||||
disabled: _disabled,
|
disabled: _disabled,
|
||||||
selected: selected,
|
selected: selected,
|
||||||
tileScale: ScaleKind.secondary,
|
tileScale: ScaleKind.secondary,
|
||||||
title: title,
|
title: title,
|
||||||
subtitle: subtitle,
|
subtitle: subtitle,
|
||||||
leading: avatar,
|
leading: avatar,
|
||||||
trailing: AvailabilityWidget(availability: _contact.profile.availability),
|
trailing: AvailabilityWidget(availability: availability),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
singleFuture(activeChatCubit, () async {
|
singleFuture(activeChatCubit, () async {
|
||||||
activeChatCubit.setActiveChat(localConversationRecordKey);
|
activeChatCubit.setActiveChat(_localConversationRecordKey);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
endActions: [
|
endActions: [
|
||||||
@ -74,7 +81,7 @@ class ChatSingleContactItemWidget extends StatelessWidget {
|
|||||||
onPressed: (context) async {
|
onPressed: (context) async {
|
||||||
final chatListCubit = context.read<ChatListCubit>();
|
final chatListCubit = context.read<ChatListCubit>();
|
||||||
await chatListCubit.deleteChat(
|
await chatListCubit.deleteChat(
|
||||||
localConversationRecordKey: localConversationRecordKey);
|
localConversationRecordKey: _localConversationRecordKey);
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
@ -9,7 +9,6 @@ import 'package:loggy/loggy.dart';
|
|||||||
import 'package:veilid_support/veilid_support.dart';
|
import 'package:veilid_support/veilid_support.dart';
|
||||||
|
|
||||||
import '../veilid_processor/views/developer.dart';
|
import '../veilid_processor/views/developer.dart';
|
||||||
import '../theme/views/responsive.dart';
|
|
||||||
import 'state_logger.dart';
|
import 'state_logger.dart';
|
||||||
|
|
||||||
String wrapWithLogColor(LogLevel? level, String text) {
|
String wrapWithLogColor(LogLevel? level, String text) {
|
||||||
@ -112,13 +111,16 @@ class CallbackPrinter extends LoggyPrinter {
|
|||||||
@override
|
@override
|
||||||
void onLog(LogRecord record) {
|
void onLog(LogRecord record) {
|
||||||
final out = record.pretty();
|
final out = record.pretty();
|
||||||
//if (isDesktop) {
|
if (Platform.isAndroid) {
|
||||||
debugPrintSynchronously(out);
|
debugPrint(out);
|
||||||
//}
|
} else {
|
||||||
|
debugPrintSynchronously(out);
|
||||||
|
}
|
||||||
globalDebugTerminal.write('$out\n'.replaceAll('\n', '\r\n'));
|
globalDebugTerminal.write('$out\n'.replaceAll('\n', '\r\n'));
|
||||||
callback?.call(record);
|
callback?.call(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ignore: use_setters_to_change_properties
|
||||||
void setCallback(void Function(LogRecord)? cb) {
|
void setCallback(void Function(LogRecord)? cb) {
|
||||||
callback = cb;
|
callback = cb;
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,12 @@ import 'loggy.dart';
|
|||||||
|
|
||||||
const Map<String, LogLevel> _blocChangeLogLevels = {
|
const Map<String, LogLevel> _blocChangeLogLevels = {
|
||||||
'ConnectionStateCubit': LogLevel.off,
|
'ConnectionStateCubit': LogLevel.off,
|
||||||
//'ActiveSingleContactChatBlocMapCubit': LogLevel.off,
|
'ActiveSingleContactChatBlocMapCubit': LogLevel.off,
|
||||||
//'ActiveConversationsBlocMapCubit': LogLevel.off,
|
'ActiveConversationsBlocMapCubit': LogLevel.off,
|
||||||
'PersistentQueueCubit<Message>': LogLevel.off,
|
'PersistentQueueCubit<Message>': LogLevel.off,
|
||||||
'TableDBArrayProtobufCubit<ReconciledMessage>': LogLevel.off,
|
'TableDBArrayProtobufCubit<ReconciledMessage>': LogLevel.off,
|
||||||
'DHTLogCubit<Message>': LogLevel.off,
|
'DHTLogCubit<Message>': LogLevel.off,
|
||||||
//'SingleContactMessagesCubit': LogLevel.off,
|
'SingleContactMessagesCubit': LogLevel.off,
|
||||||
'ChatComponentCubit': LogLevel.off,
|
'ChatComponentCubit': LogLevel.off,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user