fixing bugs

This commit is contained in:
Christien Rioux 2024-05-31 18:55:44 -04:00
parent fd63a0d5e0
commit f780a60d69
3 changed files with 7 additions and 2 deletions

View File

@ -143,7 +143,8 @@ class SingleContactMessagesCubit extends Cubit<SingleContactMessagesState> {
// Open reconciled chat record key // Open reconciled chat record key
Future<void> _initReconciledMessagesCubit() async { Future<void> _initReconciledMessagesCubit() async {
final tableName = _localConversationRecordKey.toString(); final tableName =
_localConversationRecordKey.toString().replaceAll(':', '_');
final crypto = await _makeLocalMessagesCrypto(); final crypto = await _makeLocalMessagesCrypto();

View File

@ -4,6 +4,7 @@ import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:veilid_support/veilid_support.dart'; import 'package:veilid_support/veilid_support.dart';
import '../../proto/proto.dart' as proto; import '../../proto/proto.dart' as proto;
import '../../proto/proto.dart' show messageFromJson, messageToJson;
part 'message_state.freezed.dart'; part 'message_state.freezed.dart';
part 'message_state.g.dart'; part 'message_state.g.dart';
@ -26,7 +27,7 @@ enum MessageSendState {
class MessageState with _$MessageState { class MessageState with _$MessageState {
const factory MessageState({ const factory MessageState({
// Content of the message // Content of the message
@JsonKey(fromJson: proto.messageFromJson, toJson: proto.messageToJson) @JsonKey(fromJson: messageFromJson, toJson: messageToJson)
required proto.Message content, required proto.Message content,
// Sent timestamp // Sent timestamp
required Timestamp sentTimestamp, required Timestamp sentTimestamp,

View File

@ -105,6 +105,9 @@ class TableDBArrayCubit<T> extends Cubit<TableDBArrayBusyState<T>>
) async { ) async {
try { try {
final length = _array.length; final length = _array.length;
if (length == 0) {
return AsyncValue.data(IList<T>.empty());
}
final end = ((tail - 1) % length) + 1; final end = ((tail - 1) % length) + 1;
final start = (count < end) ? end - count : 0; final start = (count < end) ? end - count : 0;
final allItems = final allItems =