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