Skip to content

Commit 3860348

Browse files
fix(media): fix send and media. (#121)
* fix(media): fix send and media. * fix(media): fix send and media.
1 parent 162da6f commit 3860348

File tree

7 files changed

+42
-24
lines changed

7 files changed

+42
-24
lines changed

lib/core/routes/routes.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,14 @@ class Routes {
275275
print(state.extra.runtimeType);
276276
if (state.extra is List) {
277277
final chat = (state.extra as List)[0] as ChatModel;
278-
final forwardedMessages = (state.extra as List)[1] as List<MessageModel>;
278+
final forwardedMessages = (state.extra != null &&
279+
(state.extra as List).length > 1 &&
280+
(state.extra as List)[1] is List)
281+
? (state.extra as List)[1] as List<MessageModel>?
282+
: null;
279283
return ChatScreen(
280284
chatModel: chat,
281-
forwardedMessages:
282-
forwardedMessages,
285+
forwardedMessages: forwardedMessages,
283286
);
284287
}
285288
final String chatId = state.extra as String;
@@ -377,7 +380,6 @@ class Routes {
377380
},
378381
),
379382
GoRoute(
380-
381383
path: Routes.createChannel,
382384
builder: (context, state) => CreateChannelScreen(),
383385
),
@@ -419,7 +421,6 @@ class Routes {
419421
);
420422
},
421423
),
422-
423424
GoRoute(
424425
path: Routes.dataAndStorageScreen,
425426
builder: (context, state) => const DataAndStorageScreen(),
@@ -428,7 +429,6 @@ class Routes {
428429
path: Routes.wifiMediaScreen,
429430
builder: (context, state) => const WifiMediaScreen(),
430431
)
431-
432432
],
433433
);
434434

lib/features/auth/repository/auth_remote_repository.dart

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,23 @@ class AuthRemoteRepository {
240240
if (dioException.response != null) {
241241
code = dioException.response!.statusCode;
242242
debugPrint('^&^ get me error with status: $code');
243-
if ((code ?? 500) >= 500) {
244-
return AppError('Something went wrong. Please, try again later', code: code ?? 500);
245-
}
246-
243+
247244
message =
248245
dioException.response!.data?['message'] ?? 'Unexpected server Error';
249246
debugPrint(message);
247+
248+
if ((code ?? 500) >= 500) {
249+
return AppError('Something went wrong. Please, try again later',
250+
emailError: dioException.response?.data?['error']?['errors']
251+
?['email']?['message'],
252+
phoneNumberError: dioException.response?.data?['error']?['errors']
253+
?['phoneNumber']?['message'],
254+
passwordError: dioException.response?.data?['error']?['errors']
255+
?['password']?['message'],
256+
confirmPasswordError: dioException.response?.data?['error']
257+
?['errors']?['passwordConfirm']?['message'],
258+
code: code ?? 500);
259+
}
250260
} else if (dioException.type == DioExceptionType.connectionTimeout ||
251261
dioException.type == DioExceptionType.connectionError ||
252262
dioException.type == DioExceptionType.unknown) {

lib/features/chat/repository/chat_remote_repository.dart

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ class ChatRemoteRepository {
160160
unreadMessagesMap[chatID]?['unreadMessagesCount'] ?? 0,
161161
isMentioned: unreadMessagesMap[chatID]?['isMentioned'] ?? false,
162162
isFiltered: chat['chat']['type'] != 'private'
163-
? chat['chat']['isFilterd']
164-
: false,
163+
? chat['chat']['isFilterd']
164+
: false,
165165
);
166166

167167
chats.add(chatModel);
@@ -315,12 +315,11 @@ class ChatRemoteRepository {
315315
contentType: contentType,
316316
text: text,
317317
fileName: message['fileName'],
318-
mediaUrl: message['mediaUrl'],
318+
mediaUrl: message['media'],
319319
);
320320

321-
final threadMessages = (message['threadMessages'] as List)
322-
.map((e) => e as String)
323-
.toList();
321+
final threadMessages =
322+
(message['threadMessages'] as List).map((e) => e as String).toList();
324323

325324
// the connumicationType attribute is extra
326325
return MessageModel(
@@ -374,7 +373,7 @@ class ChatRemoteRepository {
374373
encryptionKey: encryptionKey,
375374
initializationVector: initializationVector,
376375
chatType: chatType,
377-
isFiltered: isFiltered,
376+
isFiltered: isFiltered,
378377
),
379378
)
380379
.toList();
@@ -435,7 +434,6 @@ class ChatRemoteRepository {
435434
Future<({AppError? appError, ChatModel? chat})> getChat(
436435
String sessionID, String chatID) async {
437436
try {
438-
439437
return (appError: null, chat: null);
440438
} catch (e) {
441439
debugPrint('!!! Failed to get other user data, ${e.toString()}');

lib/features/chat/view/screens/create_chat_screen.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,11 @@ class _CreateChatScreen extends ConsumerState<CreateChatScreen>
8888
{"options": <Map<String, dynamic>>[]}
8989
];
9090
WidgetsBinding.instance.addPostFrameCallback((_) {
91-
setState(() {
92-
_usersFuture = ref.read(userViewModelProvider.notifier).fetchUsers();
93-
});
91+
if (isAdmin) {
92+
setState(() {
93+
_usersFuture = ref.read(userViewModelProvider.notifier).fetchUsers();
94+
});
95+
}
9496
});
9597
}
9698

lib/features/home/repository/home_local_repository.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class HomeLocalRepository {
6666
searchResultsChatMessagesMatches.add(matches);
6767
if (chatTitleMatches.isNotEmpty) {
6868
searchResultsChatTitleMatches.add(chatTitleMatches);
69+
} else {
70+
searchResultsChatTitleMatches.add([]);
6971
}
7072
}
7173
}

lib/features/user/view/screens/blocked_users.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class _BlockedUsersScreen extends ConsumerState<BlockedUsersScreen> {
140140
}
141141
return {
142142
"text": displayName,
143-
"imagePath": photo,
143+
"imagePath": null,
144144
"subtext": user.phone,
145145
"userId": user.id,
146146
"iconKey": GlobalKeyCategoryManager.addKey('unblockUserMenuIcon'),

lib/main.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Future<void> init() async {
5151
Hive.registerAdapter(StickerContentAdapter());
5252
Hive.registerAdapter(EmojiContentAdapter());
5353
Hive.registerAdapter(GIFContentAdapter());
54+
Hive.registerAdapter(MessageContentAdapter());
5455

5556
await Hive.initFlutter();
5657
await Hive.openBox<ContactModel>('contacts');
@@ -88,10 +89,15 @@ class _TelWareState extends ConsumerState<TelWare> {
8889
ref.listen<CallState>(callStateProvider, (previous, next) {
8990
debugPrint('*** CallState: $next');
9091
// Check for the conditions: voiceCallId is not null and isCaller is false
91-
if (previous?.voiceCallId == null && next.voiceCallId != null && !next.isCaller) {
92+
if (previous?.voiceCallId == null &&
93+
next.voiceCallId != null &&
94+
!next.isCaller) {
9295
debugPrint('*** The call is not from the caller');
9396
// Get the sender from his id
94-
router.push(Routes.callScreen, extra: {"voiceCallId": next.voiceCallId, "user": next.callee}).then((_) {
97+
router.push(Routes.callScreen, extra: {
98+
"voiceCallId": next.voiceCallId,
99+
"user": next.callee
100+
}).then((_) {
95101
debugPrint('*** Navigation to call screen completed');
96102
});
97103
}

0 commit comments

Comments
 (0)