Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
analyzer:
errors:
experimental_member_use: ignore
include: package:flutter_lints/flutter.yaml

linter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,10 +786,12 @@ class DirectMessageRepositoryImpl implements DirectMessageRepository {
_notifyMessagesChanged(recipientPubkey);
_notifyConversationsChanged();

log(
'DM: Message ${relayConfirmed ? 'sent successfully' : 'failed - no relay confirmation'}',
);
if (!relayConfirmed) {
log('DM: Message failed - no relay confirmation');
throw Exception('No relay confirmation');
}

log('DM: Message sent successfully');
return finalMessage;
} catch (e) {
log('DM: Error sending message: $e');
Expand Down
99 changes: 51 additions & 48 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:window_manager/window_manager.dart';
import 'package:flutter_mentions/flutter_mentions.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:ndk/ndk.dart';
import 'package:toastification/toastification.dart';
import 'domain_layer/entities/stored_account.dart';
import 'l10n/app_localizations.dart';
//import 'package:device_preview/device_preview.dart';
Expand Down Expand Up @@ -183,57 +184,59 @@ class MyApp extends ConsumerWidget {
themeColor: themeState.color,
);

return Portal(
child: MaterialApp.router(
routerConfig: router,
scrollBehavior: const MaterialScrollBehavior().copyWith(
scrollbars: false,
dragDevices: {
PointerDeviceKind.touch,
PointerDeviceKind.mouse,
PointerDeviceKind.trackpad,
},
),
debugShowCheckedModeBanner: false,
title: 'camelus',
locale: currentLocale,
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
theme: themeVariants.lightTheme,
darkTheme: themeVariants.darkTheme,
themeMode: themeState.mode,
builder: (context, child) {
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
return DragToResizeArea(
child: Stack(
children: [
child!,
Positioned(
top: 0,
left: 0,
right: 0,
child: SizedBox(
height: 32,
child: Row(
children: [
Expanded(child: DragToMoveArea(child: Container())),
SizedBox(
width: 154,
child: WindowCaption(
brightness: Theme.of(context).brightness,
backgroundColor: Colors.transparent,
return ToastificationWrapper(
child: Portal(
child: MaterialApp.router(
routerConfig: router,
scrollBehavior: const MaterialScrollBehavior().copyWith(
scrollbars: false,
dragDevices: {
PointerDeviceKind.touch,
PointerDeviceKind.mouse,
PointerDeviceKind.trackpad,
},
),
debugShowCheckedModeBanner: false,
title: 'camelus',
locale: currentLocale,
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
theme: themeVariants.lightTheme,
darkTheme: themeVariants.darkTheme,
themeMode: themeState.mode,
builder: (context, child) {
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
return DragToResizeArea(
child: Stack(
children: [
child!,
Positioned(
top: 0,
left: 0,
right: 0,
child: SizedBox(
height: 32,
child: Row(
children: [
Expanded(child: DragToMoveArea(child: Container())),
SizedBox(
width: 154,
child: WindowCaption(
brightness: Theme.of(context).brightness,
backgroundColor: Colors.transparent,
),
),
),
],
],
),
),
),
),
],
),
);
}
return child!;
},
],
),
);
}
return child!;
},
),
),
);
}
Expand Down
29 changes: 23 additions & 6 deletions lib/presentation_layer/routes/messages/dm_thread_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:ndk/shared/nips/nip19/nip19.dart';
import 'package:phosphor_flutter/phosphor_flutter.dart';
import 'package:toastification/toastification.dart';

import '../../../domain_layer/entities/direct_message.dart';
import '../../atoms/my_profile_picture.dart';
Expand Down Expand Up @@ -220,9 +221,13 @@ class _DmThreadPageState extends ConsumerState<DmThreadPage> {
onDelete: (messageId) => ref
.read(dmThreadProvider(_peerPubkey).notifier)
.deleteMessage(messageId),
onRetry: (messageId) => ref
.read(dmThreadProvider(_peerPubkey).notifier)
.retrySendMessage(messageId),
onRetry: (messageId) async {
final success = await ref
.read(dmThreadProvider(_peerPubkey).notifier)
.retrySendMessage(messageId);
if (!success && mounted) _showSendErrorToast();
return success;
},
onRemoveFailedMessage: (messageId) => ref
.read(dmThreadProvider(_peerPubkey).notifier)
.removeFailedMessage(messageId),
Expand Down Expand Up @@ -467,14 +472,26 @@ class _DmThreadPageState extends ConsumerState<DmThreadPage> {
);
}

void _showSendErrorToast() {
toastification.show(
context: context,
type: ToastificationType.error,
title: Text(AppLocalizations.of(context)!.failedToSendMessage),
autoCloseDuration: const Duration(seconds: 10),
showProgressBar: true,
);
}

Future<void> _sendMessage() async {
final content = _messageController.text.trim();
if (content.isEmpty) return;

_messageController.clear();

// Message is added optimistically, no need to wait for result
// or show error snackbar - error will be shown in the message bubble
ref.read(dmThreadProvider(_peerPubkey).notifier).sendMessage(content);
final success = await ref
.read(dmThreadProvider(_peerPubkey).notifier)
.sendMessage(content);

if (!success && mounted) _showSendErrorToast();
}
}
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1856,7 +1856,7 @@ packages:
source: hosted
version: "0.10.1"
toastification:
dependency: transitive
dependency: "direct main"
description:
name: toastification
sha256: "69db2bff425b484007409650d8bcd5ed1ce2e9666293ece74dcd917dacf23112"
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ dependencies:
phosphor_flutter: ^2.1.0

# ndk imports
ndk: ^0.7.1-dev.14
ndk: ^0.7.1-dev.17
ndk_rust_verifier: ^0.5.0
ndk_amber: ^0.4.0-dev.15
ndk_objectbox: ^0.2.8-dev.14
Expand Down Expand Up @@ -106,6 +106,7 @@ dependencies:
sdk: flutter
system_theme: ^3.1.2
ndk_flutter: ^0.0.2-dev.8
toastification: ^3.0.3



Expand Down