various bugfixes
This commit is contained in:
parent
e178746e51
commit
a14a7dd5c5
6 changed files with 58 additions and 13 deletions
|
|
@ -5,7 +5,6 @@ import "package:nexus/controllers/rooms.dart";
|
|||
import "package:nexus/models/content/content.dart";
|
||||
import "package:nexus/models/content/message.dart";
|
||||
import "package:nexus/models/composer_params.dart";
|
||||
import "package:path/path.dart";
|
||||
|
||||
typedef AttachmentParams = ({ComposerParams composer, int? editingRowId});
|
||||
|
||||
|
|
@ -15,8 +14,7 @@ class AttachmentController(final AttachmentParams params)
|
|||
Null build() => null;
|
||||
|
||||
Future<void> add(XFile file) async {
|
||||
final filename = basename(file.path);
|
||||
state = (filename, null);
|
||||
state = (file.name, null);
|
||||
|
||||
final isEncrypted = ref.read(
|
||||
RoomsController.provider.select(
|
||||
|
|
@ -30,9 +28,11 @@ class AttachmentController(final AttachmentParams params)
|
|||
|
||||
final content = await ref
|
||||
.read(ClientController.provider.notifier)
|
||||
.uploadMedia(.new(path: file.path, encrypt: isEncrypted));
|
||||
.uploadMedia(
|
||||
.new(path: file.path, encrypt: isEncrypted, filename: file.name),
|
||||
);
|
||||
|
||||
state = (filename, content);
|
||||
state = (file.name, content);
|
||||
}
|
||||
|
||||
void set((String, MessageContent?)? attachment) => state = attachment;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@ class FileDialogHelper(final Ref ref) {
|
|||
.toList(),
|
||||
);
|
||||
|
||||
final filenameWithExtension = mimeType == null
|
||||
// Only add an extension if the filename doesn't already have a known one
|
||||
final filenameWithExtension =
|
||||
mimeType == null || lookupMimeType(filename) != null
|
||||
? filename
|
||||
: "$filename.${extensionFromMime(mimeType)}";
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,9 @@ class const EmojiPicker({
|
|||
const .empty();
|
||||
|
||||
return upstream.EmojiPicker(
|
||||
searchHint: "Search or send emoji...",
|
||||
searchHint: allowFreeText
|
||||
? "Search emoji or react with text..."
|
||||
: "Search emoji...",
|
||||
onSelection: (emoji) async {
|
||||
final image = switch (emoji.data) {
|
||||
final PackImage image => image,
|
||||
|
|
|
|||
|
|
@ -35,7 +35,11 @@ class const VideoPlayer(
|
|||
PlayerConfiguration(
|
||||
aspectRatio: aspectRatio,
|
||||
fit: .contain,
|
||||
autoDetectFullscreenDeviceOrientation: true,
|
||||
// Follow the system's rotation setting rather than locking to the
|
||||
// video's orientation, so users can rotate freely while watching
|
||||
autoDetectFullscreenAspectRatio: true,
|
||||
deviceOrientationsOnFullScreen: const [],
|
||||
deviceOrientationsAfterFullScreen: const [],
|
||||
routePageBuilder:
|
||||
(context, animation, secondaryAnimation, provider) => HookBuilder(
|
||||
builder: (context) {
|
||||
|
|
|
|||
|
|
@ -135,7 +135,10 @@ class const EventRenderer(
|
|||
(threadRoot == null || previousEvent?.eventId != threadRoot) &&
|
||||
(previousEvent?.isShownAsMessage ?? false) &&
|
||||
event.sender == previousEvent?.sender &&
|
||||
event.pmp?.id == previousEvent?.pmp?.id;
|
||||
event.pmp?.id == previousEvent?.pmp?.id &&
|
||||
// Start a new group after a pause, so it's clear when messages were sent
|
||||
event.timestamp.difference(previousEvent!.timestamp).abs() <
|
||||
const .new(minutes: 5);
|
||||
|
||||
// For what a state event changed, from and to
|
||||
final removedColor = colorScheme.error;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import "package:collection/collection.dart";
|
||||
import "package:material_ui/material_ui.dart";
|
||||
import "package:flutter_riverpod/flutter_riverpod.dart";
|
||||
import "package:flutter_hooks/flutter_hooks.dart";
|
||||
import "package:hooks_riverpod/hooks_riverpod.dart";
|
||||
import "package:linkify/linkify.dart";
|
||||
import "package:nexus/controllers/client_state.dart";
|
||||
import "package:nexus/controllers/event.dart";
|
||||
|
|
@ -39,7 +40,7 @@ class const MessageRenderer(
|
|||
final bool isGrouped = false,
|
||||
final int? maxLines,
|
||||
super.key,
|
||||
}) extends ConsumerWidget {
|
||||
}) extends HookConsumerWidget {
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = Theme.of(context);
|
||||
|
|
@ -53,6 +54,8 @@ class const MessageRenderer(
|
|||
fontStyle: event.content is EmoteMessageContent ? .italic : null,
|
||||
);
|
||||
|
||||
final hovered = useState(false);
|
||||
|
||||
final rendered = switch (event.content) {
|
||||
_ when event.redactedBy != null => Text(
|
||||
"Redacted event",
|
||||
|
|
@ -160,14 +163,37 @@ class const MessageRenderer(
|
|||
_ => throw Exception("This is impossible"),
|
||||
};
|
||||
|
||||
return Row(
|
||||
final row = Row(
|
||||
crossAxisAlignment: .start,
|
||||
mainAxisSize: .min,
|
||||
spacing: 6,
|
||||
children: [
|
||||
if (!textOnly)
|
||||
if (isGrouped)
|
||||
SizedBox(width: 40)
|
||||
// Shows when the message was sent on hover, as grouped messages
|
||||
// have no header
|
||||
SizedBox(
|
||||
width: 40,
|
||||
child: Visibility.maintain(
|
||||
visible: hovered.value,
|
||||
child: Padding(
|
||||
padding: .only(top: 14),
|
||||
child: Tooltip(
|
||||
message: event.timestamp.toString(),
|
||||
child: FittedBox(
|
||||
fit: .scaleDown,
|
||||
child: Text(
|
||||
TimeOfDay.fromDateTime(event.timestamp).format(context),
|
||||
maxLines: 1,
|
||||
style: theme.textTheme.labelSmall?.copyWith(
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
MessageAvatar(event, height: 40),
|
||||
Flexible(
|
||||
|
|
@ -253,5 +279,13 @@ class const MessageRenderer(
|
|||
),
|
||||
],
|
||||
);
|
||||
|
||||
return isGrouped && !textOnly
|
||||
? MouseRegion(
|
||||
onEnter: (_) => hovered.value = true,
|
||||
onExit: (_) => hovered.value = false,
|
||||
child: row,
|
||||
)
|
||||
: row;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue