Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(media): fix send and media. #121

Merged
merged 2 commits into from
Dec 24, 2024
Merged
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
12 changes: 6 additions & 6 deletions lib/core/routes/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,14 @@ class Routes {
print(state.extra.runtimeType);
if (state.extra is List) {
final chat = (state.extra as List)[0] as ChatModel;
final forwardedMessages = (state.extra as List)[1] as List<MessageModel>;
final forwardedMessages = (state.extra != null &&
(state.extra as List).length > 1 &&
(state.extra as List)[1] is List)
? (state.extra as List)[1] as List<MessageModel>?
: null;
return ChatScreen(
chatModel: chat,
forwardedMessages:
forwardedMessages,
forwardedMessages: forwardedMessages,
);
}
final String chatId = state.extra as String;
Expand Down Expand Up @@ -377,7 +380,6 @@ class Routes {
},
),
GoRoute(

path: Routes.createChannel,
builder: (context, state) => CreateChannelScreen(),
),
Expand Down Expand Up @@ -419,7 +421,6 @@ class Routes {
);
},
),

GoRoute(
path: Routes.dataAndStorageScreen,
builder: (context, state) => const DataAndStorageScreen(),
Expand All @@ -428,7 +429,6 @@ class Routes {
path: Routes.wifiMediaScreen,
builder: (context, state) => const WifiMediaScreen(),
)

],
);

Expand Down
18 changes: 14 additions & 4 deletions lib/features/auth/repository/auth_remote_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,23 @@ class AuthRemoteRepository {
if (dioException.response != null) {
code = dioException.response!.statusCode;
debugPrint('^&^ get me error with status: $code');
if ((code ?? 500) >= 500) {
return AppError('Something went wrong. Please, try again later', code: code ?? 500);
}


message =
dioException.response!.data?['message'] ?? 'Unexpected server Error';
debugPrint(message);

if ((code ?? 500) >= 500) {
return AppError('Something went wrong. Please, try again later',
emailError: dioException.response?.data?['error']?['errors']
?['email']?['message'],
phoneNumberError: dioException.response?.data?['error']?['errors']
?['phoneNumber']?['message'],
passwordError: dioException.response?.data?['error']?['errors']
?['password']?['message'],
confirmPasswordError: dioException.response?.data?['error']
?['errors']?['passwordConfirm']?['message'],
code: code ?? 500);
}
} else if (dioException.type == DioExceptionType.connectionTimeout ||
dioException.type == DioExceptionType.connectionError ||
dioException.type == DioExceptionType.unknown) {
Expand Down
14 changes: 6 additions & 8 deletions lib/features/chat/repository/chat_remote_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ class ChatRemoteRepository {
unreadMessagesMap[chatID]?['unreadMessagesCount'] ?? 0,
isMentioned: unreadMessagesMap[chatID]?['isMentioned'] ?? false,
isFiltered: chat['chat']['type'] != 'private'
? chat['chat']['isFilterd']
: false,
? chat['chat']['isFilterd']
: false,
);

chats.add(chatModel);
Expand Down Expand Up @@ -315,12 +315,11 @@ class ChatRemoteRepository {
contentType: contentType,
text: text,
fileName: message['fileName'],
mediaUrl: message['mediaUrl'],
mediaUrl: message['media'],
);

final threadMessages = (message['threadMessages'] as List)
.map((e) => e as String)
.toList();
final threadMessages =
(message['threadMessages'] as List).map((e) => e as String).toList();

// the connumicationType attribute is extra
return MessageModel(
Expand Down Expand Up @@ -374,7 +373,7 @@ class ChatRemoteRepository {
encryptionKey: encryptionKey,
initializationVector: initializationVector,
chatType: chatType,
isFiltered: isFiltered,
isFiltered: isFiltered,
),
)
.toList();
Expand Down Expand Up @@ -435,7 +434,6 @@ class ChatRemoteRepository {
Future<({AppError? appError, ChatModel? chat})> getChat(
String sessionID, String chatID) async {
try {

return (appError: null, chat: null);
} catch (e) {
debugPrint('!!! Failed to get other user data, ${e.toString()}');
Expand Down
8 changes: 5 additions & 3 deletions lib/features/chat/view/screens/create_chat_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ class _CreateChatScreen extends ConsumerState<CreateChatScreen>
{"options": <Map<String, dynamic>>[]}
];
WidgetsBinding.instance.addPostFrameCallback((_) {
setState(() {
_usersFuture = ref.read(userViewModelProvider.notifier).fetchUsers();
});
if (isAdmin) {
setState(() {
_usersFuture = ref.read(userViewModelProvider.notifier).fetchUsers();
});
}
});
}

Expand Down
2 changes: 2 additions & 0 deletions lib/features/home/repository/home_local_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class HomeLocalRepository {
searchResultsChatMessagesMatches.add(matches);
if (chatTitleMatches.isNotEmpty) {
searchResultsChatTitleMatches.add(chatTitleMatches);
} else {
searchResultsChatTitleMatches.add([]);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/features/user/view/screens/blocked_users.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class _BlockedUsersScreen extends ConsumerState<BlockedUsersScreen> {
}
return {
"text": displayName,
"imagePath": photo,
"imagePath": null,
"subtext": user.phone,
"userId": user.id,
"iconKey": GlobalKeyCategoryManager.addKey('unblockUserMenuIcon'),
Expand Down
10 changes: 8 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Future<void> init() async {
Hive.registerAdapter(StickerContentAdapter());
Hive.registerAdapter(EmojiContentAdapter());
Hive.registerAdapter(GIFContentAdapter());
Hive.registerAdapter(MessageContentAdapter());

await Hive.initFlutter();
await Hive.openBox<ContactModel>('contacts');
Expand Down Expand Up @@ -88,10 +89,15 @@ class _TelWareState extends ConsumerState<TelWare> {
ref.listen<CallState>(callStateProvider, (previous, next) {
debugPrint('*** CallState: $next');
// Check for the conditions: voiceCallId is not null and isCaller is false
if (previous?.voiceCallId == null && next.voiceCallId != null && !next.isCaller) {
if (previous?.voiceCallId == null &&
next.voiceCallId != null &&
!next.isCaller) {
debugPrint('*** The call is not from the caller');
// Get the sender from his id
router.push(Routes.callScreen, extra: {"voiceCallId": next.voiceCallId, "user": next.callee}).then((_) {
router.push(Routes.callScreen, extra: {
"voiceCallId": next.voiceCallId,
"user": next.callee
}).then((_) {
debugPrint('*** Navigation to call screen completed');
});
}
Expand Down
Loading