various bugfixes

This commit is contained in:
Henry Hiles 2026-12-04 16:45:47 -05:00
commit a14a7dd5c5
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
6 changed files with 58 additions and 13 deletions

View file

@ -5,7 +5,6 @@ import "package:nexus/controllers/rooms.dart";
import "package:nexus/models/content/content.dart"; import "package:nexus/models/content/content.dart";
import "package:nexus/models/content/message.dart"; import "package:nexus/models/content/message.dart";
import "package:nexus/models/composer_params.dart"; import "package:nexus/models/composer_params.dart";
import "package:path/path.dart";
typedef AttachmentParams = ({ComposerParams composer, int? editingRowId}); typedef AttachmentParams = ({ComposerParams composer, int? editingRowId});
@ -15,8 +14,7 @@ class AttachmentController(final AttachmentParams params)
Null build() => null; Null build() => null;
Future<void> add(XFile file) async { Future<void> add(XFile file) async {
final filename = basename(file.path); state = (file.name, null);
state = (filename, null);
final isEncrypted = ref.read( final isEncrypted = ref.read(
RoomsController.provider.select( RoomsController.provider.select(
@ -30,9 +28,11 @@ class AttachmentController(final AttachmentParams params)
final content = await ref final content = await ref
.read(ClientController.provider.notifier) .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; void set((String, MessageContent?)? attachment) => state = attachment;

View file

@ -18,7 +18,9 @@ class FileDialogHelper(final Ref ref) {
.toList(), .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
: "$filename.${extensionFromMime(mimeType)}"; : "$filename.${extensionFromMime(mimeType)}";

View file

@ -45,7 +45,9 @@ class const EmojiPicker({
const .empty(); const .empty();
return upstream.EmojiPicker( return upstream.EmojiPicker(
searchHint: "Search or send emoji...", searchHint: allowFreeText
? "Search emoji or react with text..."
: "Search emoji...",
onSelection: (emoji) async { onSelection: (emoji) async {
final image = switch (emoji.data) { final image = switch (emoji.data) {
final PackImage image => image, final PackImage image => image,

View file

@ -35,7 +35,11 @@ class const VideoPlayer(
PlayerConfiguration( PlayerConfiguration(
aspectRatio: aspectRatio, aspectRatio: aspectRatio,
fit: .contain, 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: routePageBuilder:
(context, animation, secondaryAnimation, provider) => HookBuilder( (context, animation, secondaryAnimation, provider) => HookBuilder(
builder: (context) { builder: (context) {

View file

@ -135,7 +135,10 @@ class const EventRenderer(
(threadRoot == null || previousEvent?.eventId != threadRoot) && (threadRoot == null || previousEvent?.eventId != threadRoot) &&
(previousEvent?.isShownAsMessage ?? false) && (previousEvent?.isShownAsMessage ?? false) &&
event.sender == previousEvent?.sender && 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 // For what a state event changed, from and to
final removedColor = colorScheme.error; final removedColor = colorScheme.error;

View file

@ -1,6 +1,7 @@
import "package:collection/collection.dart"; import "package:collection/collection.dart";
import "package:material_ui/material_ui.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:linkify/linkify.dart";
import "package:nexus/controllers/client_state.dart"; import "package:nexus/controllers/client_state.dart";
import "package:nexus/controllers/event.dart"; import "package:nexus/controllers/event.dart";
@ -39,7 +40,7 @@ class const MessageRenderer(
final bool isGrouped = false, final bool isGrouped = false,
final int? maxLines, final int? maxLines,
super.key, super.key,
}) extends ConsumerWidget { }) extends HookConsumerWidget {
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
final theme = Theme.of(context); final theme = Theme.of(context);
@ -53,6 +54,8 @@ class const MessageRenderer(
fontStyle: event.content is EmoteMessageContent ? .italic : null, fontStyle: event.content is EmoteMessageContent ? .italic : null,
); );
final hovered = useState(false);
final rendered = switch (event.content) { final rendered = switch (event.content) {
_ when event.redactedBy != null => Text( _ when event.redactedBy != null => Text(
"Redacted event", "Redacted event",
@ -160,14 +163,37 @@ class const MessageRenderer(
_ => throw Exception("This is impossible"), _ => throw Exception("This is impossible"),
}; };
return Row( final row = Row(
crossAxisAlignment: .start, crossAxisAlignment: .start,
mainAxisSize: .min, mainAxisSize: .min,
spacing: 6, spacing: 6,
children: [ children: [
if (!textOnly) if (!textOnly)
if (isGrouped) 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 else
MessageAvatar(event, height: 40), MessageAvatar(event, height: 40),
Flexible( Flexible(
@ -253,5 +279,13 @@ class const MessageRenderer(
), ),
], ],
); );
return isGrouped && !textOnly
? MouseRegion(
onEnter: (_) => hovered.value = true,
onExit: (_) => hovered.value = false,
child: row,
)
: row;
} }
} }