🐛 Bug fixes
This commit is contained in:
		@@ -194,9 +194,11 @@ class ChatMessageController extends ChangeNotifier {
 | 
			
		||||
          channelId: channel!.id,
 | 
			
		||||
          createdAt: Value(message.createdAt),
 | 
			
		||||
        ),
 | 
			
		||||
        onConflict: DoUpdate((_) => SnLocalChatMessageCompanion.custom(
 | 
			
		||||
              content: Constant(jsonEncode(message.toJson())),
 | 
			
		||||
            )),
 | 
			
		||||
        onConflict: DoUpdate(
 | 
			
		||||
          (_) => SnLocalChatMessageCompanion.custom(
 | 
			
		||||
            content: Constant(jsonEncode(message.toJson())),
 | 
			
		||||
          ),
 | 
			
		||||
        ),
 | 
			
		||||
      );
 | 
			
		||||
    } else {
 | 
			
		||||
      incomeStrandedQueue.add(message);
 | 
			
		||||
@@ -218,15 +220,15 @@ class ChatMessageController extends ChangeNotifier {
 | 
			
		||||
              body: newBody,
 | 
			
		||||
              updatedAt: message.updatedAt,
 | 
			
		||||
            );
 | 
			
		||||
            if (message.relatedEventId != null) {
 | 
			
		||||
              await (_dt.db.snLocalChatMessage.update()
 | 
			
		||||
                    ..where((e) => e.id.equals(message.relatedEventId!)))
 | 
			
		||||
                  .write(
 | 
			
		||||
                SnLocalChatMessageCompanion.custom(
 | 
			
		||||
                  content: Constant(jsonEncode(messages[idx].toJson())),
 | 
			
		||||
                ),
 | 
			
		||||
              );
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
          if (message.relatedEventId != null) {
 | 
			
		||||
            await (_dt.db.snLocalChatMessage.update()
 | 
			
		||||
                  ..where((e) => e.id.equals(message.relatedEventId!)))
 | 
			
		||||
                .write(
 | 
			
		||||
              SnLocalChatMessageCompanion.custom(
 | 
			
		||||
                content: Constant(jsonEncode(messages[idx].toJson())),
 | 
			
		||||
              ),
 | 
			
		||||
            );
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      case 'messages.delete':
 | 
			
		||||
 
 | 
			
		||||
@@ -88,7 +88,8 @@ class NotificationProvider extends ChangeNotifier {
 | 
			
		||||
        final doHaptic = _cfg.prefs.getBool(kAppNotifyWithHaptic) ?? true;
 | 
			
		||||
        if (doHaptic) HapticFeedback.mediumImpact();
 | 
			
		||||
 | 
			
		||||
        if (notification.topic == 'messaging.message') {
 | 
			
		||||
        if (notification.topic == 'messaging.message' &&
 | 
			
		||||
            skippableNotifyChannel != null) {
 | 
			
		||||
          if (notification.metadata['channel_id'] != null &&
 | 
			
		||||
              notification.metadata['channel_id'] == skippableNotifyChannel) {
 | 
			
		||||
            return;
 | 
			
		||||
 
 | 
			
		||||
@@ -41,7 +41,8 @@ class SnAttachmentProvider {
 | 
			
		||||
    return out;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Future<List<SnAttachment?>> getMultiple(List<String> rids, {noCache = false}) async {
 | 
			
		||||
  Future<List<SnAttachment?>> getMultiple(List<String> rids,
 | 
			
		||||
      {noCache = false}) async {
 | 
			
		||||
    final result = List<SnAttachment?>.filled(rids.length, null);
 | 
			
		||||
    final Map<String, int> randomMapping = {};
 | 
			
		||||
    for (int i = 0; i < rids.length; i++) {
 | 
			
		||||
@@ -62,8 +63,10 @@ class SnAttachmentProvider {
 | 
			
		||||
          'id': pendingFetch.join(','),
 | 
			
		||||
        },
 | 
			
		||||
      );
 | 
			
		||||
      final List<SnAttachment?> out =
 | 
			
		||||
          resp.data['data'].map((e) => e['id'] == 0 ? null : SnAttachment.fromJson(e)).cast<SnAttachment?>().toList();
 | 
			
		||||
      final List<SnAttachment?> out = resp.data['data']
 | 
			
		||||
          .map((e) => e['id'] == 0 ? null : SnAttachment.fromJson(e))
 | 
			
		||||
          .cast<SnAttachment?>()
 | 
			
		||||
          .toList();
 | 
			
		||||
 | 
			
		||||
      for (final item in out) {
 | 
			
		||||
        if (item == null) continue;
 | 
			
		||||
@@ -77,7 +80,13 @@ class SnAttachmentProvider {
 | 
			
		||||
    return result;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  static Map<String, String> mimetypeOverrides = {'mov': 'video/quicktime', 'mp4': 'video/mp4'};
 | 
			
		||||
  static Map<String, String> mimetypeOverrides = {
 | 
			
		||||
    'mov': 'video/quicktime',
 | 
			
		||||
    'mp4': 'video/mp4',
 | 
			
		||||
    'm4a': 'audio/mp4',
 | 
			
		||||
    'apng': 'image/apng',
 | 
			
		||||
    'webp': 'image/webp',
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  Future<SnAttachment> directUploadOne(
 | 
			
		||||
    Uint8List data,
 | 
			
		||||
@@ -89,8 +98,11 @@ class SnAttachmentProvider {
 | 
			
		||||
    bool analyzeNow = false,
 | 
			
		||||
  }) async {
 | 
			
		||||
    final filePayload = MultipartFile.fromBytes(data, filename: filename);
 | 
			
		||||
    final fileAlt = filename.contains('.') ? filename.substring(0, filename.lastIndexOf('.')) : filename;
 | 
			
		||||
    final fileExt = filename.substring(filename.lastIndexOf('.') + 1).toLowerCase();
 | 
			
		||||
    final fileAlt = filename.contains('.')
 | 
			
		||||
        ? filename.substring(0, filename.lastIndexOf('.'))
 | 
			
		||||
        : filename;
 | 
			
		||||
    final fileExt =
 | 
			
		||||
        filename.substring(filename.lastIndexOf('.') + 1).toLowerCase();
 | 
			
		||||
 | 
			
		||||
    String? mimetypeOverride;
 | 
			
		||||
    if (mimetype != null) {
 | 
			
		||||
@@ -127,8 +139,11 @@ class SnAttachmentProvider {
 | 
			
		||||
    Map<String, dynamic>? metadata, {
 | 
			
		||||
    String? mimetype,
 | 
			
		||||
  }) async {
 | 
			
		||||
    final fileAlt = filename.contains('.') ? filename.substring(0, filename.lastIndexOf('.')) : filename;
 | 
			
		||||
    final fileExt = filename.substring(filename.lastIndexOf('.') + 1).toLowerCase();
 | 
			
		||||
    final fileAlt = filename.contains('.')
 | 
			
		||||
        ? filename.substring(0, filename.lastIndexOf('.'))
 | 
			
		||||
        : filename;
 | 
			
		||||
    final fileExt =
 | 
			
		||||
        filename.substring(filename.lastIndexOf('.') + 1).toLowerCase();
 | 
			
		||||
 | 
			
		||||
    String? mimetypeOverride;
 | 
			
		||||
    if (mimetype == null && mimetypeOverrides.keys.contains(fileExt)) {
 | 
			
		||||
@@ -146,7 +161,10 @@ class SnAttachmentProvider {
 | 
			
		||||
      if (mimetypeOverride != null) 'mimetype': mimetypeOverride,
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    return (SnAttachmentFragment.fromJson(resp.data['meta']), resp.data['chunk_size'] as int);
 | 
			
		||||
    return (
 | 
			
		||||
      SnAttachmentFragment.fromJson(resp.data['meta']),
 | 
			
		||||
      resp.data['chunk_size'] as int
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Future<dynamic> _chunkedUploadOnePart(
 | 
			
		||||
@@ -197,7 +215,10 @@ class SnAttachmentProvider {
 | 
			
		||||
          (entry.value + 1) * chunkSize,
 | 
			
		||||
          await file.length(),
 | 
			
		||||
        );
 | 
			
		||||
        final data = Uint8List.fromList(await file.openRead(beginCursor, endCursor).expand((chunk) => chunk).toList());
 | 
			
		||||
        final data = Uint8List.fromList(await file
 | 
			
		||||
            .openRead(beginCursor, endCursor)
 | 
			
		||||
            .expand((chunk) => chunk)
 | 
			
		||||
            .toList());
 | 
			
		||||
 | 
			
		||||
        final result = await _chunkedUploadOnePart(
 | 
			
		||||
          data,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user