diff --git a/lib/pages/chat/events/audio_player.dart b/lib/pages/chat/events/audio_player.dart index 82a06ba79..8ab4d067a 100644 --- a/lib/pages/chat/events/audio_player.dart +++ b/lib/pages/chat/events/audio_player.dart @@ -298,7 +298,10 @@ class AudioPlayerState extends State { final statusText = this.statusText ??= _durationString ?? '00:00'; final audioPlayer = this.audioPlayer; return Padding( - padding: const EdgeInsets.all(12.0), + // #Pangea + // padding: const EdgeInsets.all(12.0), + padding: const EdgeInsets.all(5.0), + // Pangea# child: Row( mainAxisSize: MainAxisSize.min, children: [ @@ -332,7 +335,10 @@ class AudioPlayerState extends State { }, ), ), - const SizedBox(width: 8), + // #Pangea + // const SizedBox(width: 8), + const SizedBox(width: 5), + // Pangea# Row( mainAxisSize: MainAxisSize.min, children: [ @@ -368,7 +374,10 @@ class AudioPlayerState extends State { ), ], ), - const SizedBox(width: 8), + // #Pangea + // const SizedBox(width: 8), + const SizedBox(width: 5), + // Pangea# SizedBox( width: 36, child: Text( diff --git a/lib/pages/chat/events/video_player.dart b/lib/pages/chat/events/video_player.dart index 1b0983bd4..d76d49576 100644 --- a/lib/pages/chat/events/video_player.dart +++ b/lib/pages/chat/events/video_player.dart @@ -1,21 +1,20 @@ import 'dart:io'; +import 'package:chewie/chewie.dart'; +import 'package:fluffychat/config/app_config.dart'; +import 'package:fluffychat/pages/chat/events/image_bubble.dart'; +import 'package:fluffychat/utils/localized_exception_extension.dart'; +import 'package:fluffychat/utils/matrix_sdk_extensions/event_extension.dart'; +import 'package:fluffychat/utils/platform_infos.dart'; +import 'package:fluffychat/widgets/blur_hash.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; - -import 'package:chewie/chewie.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:matrix/matrix.dart'; import 'package:path_provider/path_provider.dart'; import 'package:universal_html/html.dart' as html; import 'package:video_player/video_player.dart'; -import 'package:fluffychat/config/app_config.dart'; -import 'package:fluffychat/pages/chat/events/image_bubble.dart'; -import 'package:fluffychat/utils/localized_exception_extension.dart'; -import 'package:fluffychat/utils/matrix_sdk_extensions/event_extension.dart'; -import 'package:fluffychat/utils/platform_infos.dart'; -import 'package:fluffychat/widgets/blur_hash.dart'; import '../../../utils/error_reporter.dart'; class EventVideoPlayer extends StatefulWidget { @@ -71,7 +70,7 @@ class EventVideoPlayerState extends State { autoInitialize: true, ); } - } on MatrixConnectionException catch (e) { + } on Exception catch (e) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text(e.toLocalizedString(context)), diff --git a/lib/pages/chat/input_bar.dart b/lib/pages/chat/input_bar.dart index 9337b488a..84a802e54 100644 --- a/lib/pages/chat/input_bar.dart +++ b/lib/pages/chat/input_bar.dart @@ -504,6 +504,9 @@ class InputBar extends StatelessWidget { onSubmitted!(text); }, // #Pangea + style: controller?.isMaxLength ?? false + ? const TextStyle(color: Colors.red) + : null, onTap: () { controller!.onInputTap( context, diff --git a/lib/pages/chat_list/space_view.dart b/lib/pages/chat_list/space_view.dart index d0ff8cdf5..ccc9aa9c4 100644 --- a/lib/pages/chat_list/space_view.dart +++ b/lib/pages/chat_list/space_view.dart @@ -53,6 +53,25 @@ class _SpaceViewState extends State { widget.controller.pangeaController.pStoreService.read(_chatCountsKey) ?? {}, ); + + /// Used to filter out sync updates with hierarchy updates for the active + /// space so that the view can be auto-reloaded in the room subscription + bool hasHierarchyUpdate(SyncUpdate update) { + final joinTimeline = + update.rooms?.join?[widget.controller.activeSpaceId]?.timeline; + final leaveTimeline = + update.rooms?.leave?[widget.controller.activeSpaceId]?.timeline; + if (joinTimeline == null && leaveTimeline == null) return false; + final bool hasJoinUpdate = joinTimeline?.events?.any( + (event) => event.type == EventTypes.SpaceChild, + ) ?? + false; + final bool hasLeaveUpdate = leaveTimeline?.events?.any( + (event) => event.type == EventTypes.SpaceChild, + ) ?? + false; + return hasJoinUpdate || hasLeaveUpdate; + } // Pangea# @override @@ -78,12 +97,9 @@ class _SpaceViewState extends State { // Listen for changes to the activeSpace's hierarchy, // and reload the hierarchy when they come through final client = Matrix.of(context).client; - _roomSubscription ??= client.onRoomState.stream.where((u) { - return u.state.type == EventTypes.SpaceChild && - u.roomId == widget.controller.activeSpaceId; - }).listen((update) { - loadHierarchy(hasUpdate: true); - }); + _roomSubscription ??= client.onSync.stream + .where(hasHierarchyUpdate) + .listen((update) => loadHierarchy(hasUpdate: true)); // Pangea# super.initState(); } diff --git a/lib/pangea/utils/p_store.dart b/lib/pangea/utils/p_store.dart index 0dfe0d5cd..233975fc5 100644 --- a/lib/pangea/utils/p_store.dart +++ b/lib/pangea/utils/p_store.dart @@ -1,5 +1,6 @@ import 'package:fluffychat/pangea/controllers/pangea_controller.dart'; import 'package:get_storage/get_storage.dart'; +import 'package:sentry_flutter/sentry_flutter.dart'; /// Utility to save and read data both in the matrix profile (this is the default /// behavior) and in the local storage (local needs to be specificied). An @@ -66,6 +67,9 @@ class PStore { /// Clears the storage by erasing all data in the box. void clearStorage() { + // this could potenitally be interfering with openning database + // at the start of the session, which is causing auto log outs on iOS + Sentry.addBreadcrumb(Breadcrumb(message: 'Clearing local storage')); _box.erase(); } } diff --git a/lib/pangea/widgets/chat/input_bar_wrapper.dart b/lib/pangea/widgets/chat/input_bar_wrapper.dart index 374f60a80..9441312bd 100644 --- a/lib/pangea/widgets/chat/input_bar_wrapper.dart +++ b/lib/pangea/widgets/chat/input_bar_wrapper.dart @@ -44,6 +44,7 @@ class InputBarWrapper extends StatefulWidget { class InputBarWrapperState extends State { StreamSubscription? _choreoSub; + String _currentText = ''; @override void initState() { @@ -61,6 +62,24 @@ class InputBarWrapperState extends State { super.dispose(); } + void refreshOnChange(String text) { + if (widget.onChanged != null) { + widget.onChanged!(text); + } + + final bool decreasedFromMaxLength = + _currentText.length >= PangeaTextController.maxLength && + text.length < PangeaTextController.maxLength; + final bool reachedMaxLength = + _currentText.length < PangeaTextController.maxLength && + text.length < PangeaTextController.maxLength; + + if (decreasedFromMaxLength || reachedMaxLength) { + setState(() {}); + } + _currentText = text; + } + @override Widget build(BuildContext context) { return InputBar( @@ -73,7 +92,7 @@ class InputBarWrapperState extends State { focusNode: widget.focusNode, controller: widget.controller, decoration: widget.decoration, - onChanged: widget.onChanged, + onChanged: refreshOnChange, autofocus: widget.autofocus, textInputAction: widget.textInputAction, readOnly: widget.readOnly, diff --git a/lib/pangea/widgets/igc/pangea_text_controller.dart b/lib/pangea/widgets/igc/pangea_text_controller.dart index b91186c22..8fc136edd 100644 --- a/lib/pangea/widgets/igc/pangea_text_controller.dart +++ b/lib/pangea/widgets/igc/pangea_text_controller.dart @@ -25,6 +25,10 @@ class PangeaTextController extends TextEditingController { text ??= ''; this.text = text; } + + static const int maxLength = 1000; + bool get isMaxLength => text.length == 1000; + bool forceKeepOpen = false; setSystemText(String text, EditType type) { diff --git a/lib/utils/localized_exception_extension.dart b/lib/utils/localized_exception_extension.dart index 65be02a1f..5b2df02fd 100644 --- a/lib/utils/localized_exception_extension.dart +++ b/lib/utils/localized_exception_extension.dart @@ -1,7 +1,6 @@ import 'dart:io'; import 'package:flutter/material.dart'; - import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:matrix/encryption.dart'; import 'package:matrix/matrix.dart'; @@ -67,9 +66,7 @@ extension LocalizedExceptionExtension on Object { supportedVersions, ); } - if (this is MatrixConnectionException || - this is SocketException || - this is SyncConnectionException) { + if (this is SocketException || this is SyncConnectionException) { return L10n.of(context)!.noConnectionToTheServer; } if (this is String) return toString(); diff --git a/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/builder.dart b/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/builder.dart index 655fea198..b5665c635 100644 --- a/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/builder.dart +++ b/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/builder.dart @@ -7,6 +7,7 @@ import 'package:flutter/foundation.dart'; import 'package:matrix/matrix.dart'; import 'package:path/path.dart'; import 'package:path_provider/path_provider.dart'; +import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:sqflite_common_ffi/sqflite_ffi.dart'; import 'package:universal_html/html.dart' as html; @@ -80,6 +81,9 @@ Future _constructDatabase(Client client) async { } final cipher = await getDatabaseCipher(); + // #Pangea + Sentry.addBreadcrumb(Breadcrumb(message: 'Database cipher: $cipher')); + // Pangea# Directory? fileStorageLocation; try { @@ -97,6 +101,9 @@ Future _constructDatabase(Client client) async { // import the SQLite / SQLCipher shared objects / dynamic libraries final factory = createDatabaseFactoryFfi(ffiInit: SQfLiteEncryptionHelper.ffiInit); + // #Pangea + Sentry.addBreadcrumb(Breadcrumb(message: 'Database path: $path')); + // Pangea# // migrate from potential previous SQLite database path to current one await _migrateLegacyLocation(path, client.clientName); @@ -113,6 +120,9 @@ Future _constructDatabase(Client client) async { path: path, cipher: cipher, ); + // #Pangea + Sentry.addBreadcrumb(Breadcrumb(message: 'Database cipher helper: $helper')); + // Pangea# // check whether the DB is already encrypted and otherwise do so await helper?.ensureDatabaseFileEncrypted(); diff --git a/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/cipher.dart b/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/cipher.dart index 612f74395..bfe1251dc 100644 --- a/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/cipher.dart +++ b/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/cipher.dart @@ -5,6 +5,7 @@ import 'package:fluffychat/config/setting_keys.dart'; import 'package:flutter/services.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:matrix/matrix.dart'; +import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:shared_preferences/shared_preferences.dart'; const _passwordStorageKey = 'database_password'; @@ -58,6 +59,12 @@ void _sendNoEncryptionWarning(Object exception) async { // l10n.noDatabaseEncryption, // exception.toString(), // ); + Sentry.addBreadcrumb( + Breadcrumb( + message: 'No database encryption', + data: {'exception': exception}, + ), + ); // Pangea# await store.setBool(SettingKeys.noEncryptionWarningShown, true); diff --git a/lib/utils/matrix_sdk_extensions/matrix_locals.dart b/lib/utils/matrix_sdk_extensions/matrix_locals.dart index 5714baa22..b4536b6db 100644 --- a/lib/utils/matrix_sdk_extensions/matrix_locals.dart +++ b/lib/utils/matrix_sdk_extensions/matrix_locals.dart @@ -344,4 +344,10 @@ class MatrixLocals extends MatrixLocalizations { @override String startedKeyVerification(String senderName) => l10n.startedKeyVerification(senderName); + + @override + String invitedBy(String senderName) { + // TODO: implement invitedBy + throw UnimplementedError(); + } } diff --git a/pubspec.lock b/pubspec.lock index 7a4059d66..ae95fb892 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1432,11 +1432,12 @@ packages: matrix: dependency: "direct main" description: - name: matrix - sha256: bb6de59d0f69e10bb6893130a967f1ffcbfa3d3ffed3864f0736ce3d968e669c - url: "https://pub.dev" - source: hosted - version: "0.29.12" + path: "." + ref: main + resolved-ref: "0a95cd8f3cfac8c9b0b59d6ee7fdbdb159949ca3" + url: "https://github.com/pangeachat/matrix-dart-sdk.git" + source: git + version: "0.30.0" meta: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index a24dfdff3..1e75fc4b5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -70,7 +70,10 @@ dependencies: keyboard_shortcuts: ^0.1.4 latlong2: ^0.9.1 linkify: ^5.0.0 - matrix: ^0.29.12 + matrix: + git: + url: https://github.com/pangeachat/matrix-dart-sdk.git # repo + ref: main # branch native_imaging: ^0.1.1 package_info_plus: ^6.0.0 pasteboard: ^0.2.0