Skip to content
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
3 changes: 0 additions & 3 deletions lib/core/services/socket_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ class SocketService {
void _connect() {
if (isConnected || USE_MOCK_DATA) return;
debugPrint('*** Entered the connect method');
debugPrint(_serverUrl);
debugPrint(_userId);
debugPrint(_sessionId);

_socket = io(_serverUrl, <String, dynamic>{
// 'autoConnect': false,
Expand Down
44 changes: 44 additions & 0 deletions lib/core/view/widget/highlight_text_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class HighlightTextWidget extends StatelessWidget {
final TextStyle normalStyle;
final TextStyle highlightStyle;
final TextStyle linkStyle;
final TextStyle mentionStyle;
final TextOverflow overFlow;
final int? maxLines;

Expand All @@ -33,6 +34,11 @@ class HighlightTextWidget extends StatelessWidget {
caseSensitive: false,
);

final RegExp _mentionRegExp = RegExp(
r'@\[(.*?)\]\((.*?)\)',
caseSensitive: false,
);

HighlightTextWidget({
super.key,
required this.text,
Expand All @@ -43,6 +49,11 @@ class HighlightTextWidget extends StatelessWidget {
color: Palette.accent,
decoration: TextDecoration.underline,
),
this.mentionStyle = const TextStyle(
color: Color.fromARGB(255, 43, 121, 255),
fontWeight: FontWeight.bold,
decoration: TextDecoration.underline,
),
this.overFlow = TextOverflow.clip,
this.maxLines,
});
Expand All @@ -64,9 +75,14 @@ class HighlightTextWidget extends StatelessWidget {

// Find all links in the text
final List<RegExpMatch> linkMatches = _linkRegExp.allMatches(text).toList();
final List<RegExpMatch> mantionMatches =
_mentionRegExp.allMatches(text).toList();
final List<MapEntry<int, int>> linkRanges = linkMatches
.map((match) => MapEntry(match.start, match.end - match.start))
.toList();
final List<MapEntry<int, int>> mentionRanges = mantionMatches
.map((match) => MapEntry(match.start, match.end - match.start))
.toList();

final List<MapEntry<int, String>> highlightRanges =
List.generate(text.length, (index) => MapEntry(index, 'normal'));
Expand All @@ -88,6 +104,22 @@ class HighlightTextWidget extends StatelessWidget {
continue;
}

lowerBoundIndex = lowerBound<MapEntry<int, int>>(
mentionRanges,
MapEntry(i, 0), // Create a temporary MapEntry with the target value
compare: (a, b) => a.key.compareTo(b.key), // Compare by the key
);
if (lowerBoundIndex != 0) {
lowerBoundIndex = (lowerBoundIndex < mentionRanges.length &&
mentionRanges[lowerBoundIndex].key == i)
? lowerBoundIndex
: lowerBoundIndex - 1;
}
if (isHighlight(i, lowerBoundIndex, mentionRanges)) {
highlightRanges[i] = MapEntry(i, 'mention');
continue;
}

lowerBoundIndex = lowerBound<MapEntry<int, int>>(
linkRanges,
MapEntry(i, 0), // Create a temporary MapEntry with the target value
Expand Down Expand Up @@ -158,6 +190,18 @@ class HighlightTextWidget extends StatelessWidget {
),
);
break;
case 'mention':
textSpans.add(
TextSpan(
text: '@${(text.substring(index, index + length)).splitMapJoin(
_mentionRegExp,
onMatch: (m) => m.group(1)!,
onNonMatch: (m) => m,
)}',
style: mentionStyle,
),
);
break;
}
}

Expand Down
1 change: 0 additions & 1 deletion lib/features/auth/repository/auth_remote_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ class AuthRemoteRepository {
final message = response.data['message'];
return Left(AppError(message));
}
debugPrint('=========================================');
debugPrint('Get me was successful');
UserModel user = await UserModel.fromMap(response.data['data']['user']);
List<UserModel> blockedUsers = await _handleGetBlockedUsers(sessionId);
Expand Down
3 changes: 0 additions & 3 deletions lib/features/chat/repository/chat_local_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@ class ChatLocalRepository {
/////////////////////////////////////
// set chats
Future<bool> setChats(List<ChatModel> list, String userId) async {
debugPrint('!!! set chats locally called');
try {
await _chatsBox.put(_chatsBoxKey+userId, updateMessagesFilePath(list));
debugPrint('@@@ did put chats use key: ${_chatsBoxKey+userId} and length of: ${list.length}');
return true;
} catch (e) {
debugPrint('!!! exception on saving the chats list');
debugPrint(e.toString());
return false;
}
Expand Down
1 change: 0 additions & 1 deletion lib/features/chat/view/screens/chat_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ class _ChatScreen extends ConsumerState<ChatScreen>

@override
Widget build(BuildContext context) {
debugPrint('&*&**&**& rebuild chat screen');
final chats = ref.watch(chatsViewModelProvider);
final index = chats.indexWhere((chat) => chat.id == widget.chatId);
final ChatModel? chat =
Expand Down
8 changes: 8 additions & 0 deletions lib/features/chat/view_model/chats_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ class ChatsViewModel extends _$ChatsViewModel {
.toList();
}

UserModel getLocalUser(String id) {
if (id == ref.read(userProvider)!.id) {
// debugPrint('!!!** returning the current user');
return ref.read(userProvider)!;
}
return _otherUsers[id]!;
}

Future<UserModel?> getUser(String id) async {
// debugPrint('!!!** called');
if (id == ref.read(userProvider)!.id) {
Expand Down
6 changes: 0 additions & 6 deletions lib/features/chat/view_model/event_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ class EventHandler {
if (_isProcessing || USE_MOCK_DATA) return; // Avoid multiple loops

_isProcessing = true;
debugPrint('()()() called Processing Queue');
debugPrint('()()() ${_queue.length}');
debugPrint('()()() $_stopRequested');

int failingCounter = 0;

Expand Down Expand Up @@ -128,7 +125,6 @@ class EventHandler {

void _onSocketConnect() {
final Signaling signaling = Signaling.instance;
debugPrint('!!! connected successfully');
// receive a message
_socket.on(EventType.receiveMessage.event, (response) async {
print('### got a message: $response');
Expand Down Expand Up @@ -313,7 +309,6 @@ class EventHandler {
// get a call ended
_socket.on(EventType.receiveCallEnded.event, (response) async {
try {
debugPrint('### got a call ended: $response');
signaling.onReceiveEndCall?.call(response);
} on Exception catch (e) {
debugPrint('!!! Error in receiving a call ended:\n${e.toString()}');
Expand All @@ -323,7 +318,6 @@ class EventHandler {
// get updated draft
_socket.on(EventType.receiveUpdatedDraft.event, (response) async {
try {
debugPrint('### got a draft: $response');
_chattingController.receiveUpdatedDraft(response['chatId'], response['draft']);
} on Exception catch (e) {
debugPrint('!!! Error in receiving a draft:\n${e.toString()}');
Expand Down
1 change: 0 additions & 1 deletion lib/features/stories/view/widget/chats_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class ChatsList extends ConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
final chatsList = ref.watch(chatsViewModelProvider);
ChatKeys.resetChatTilePrefixSubvalue();
debugPrint('^*^*^*^*^* chat list rebuilding');

return SliverList(
key: ChatKeys.chatsListKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class ColapsedStorySection extends ConsumerWidget {
},
);

debugPrint('Building ColapsedStorySection...');
return Row(
children: [
Expanded(child: StackedOverlappedImages(users: reorderedUsers)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class ExpandedStoriesSection extends ConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
ref.read(usersViewModelProvider.notifier).fetchContacts();
final isLoading = ref.watch(usersViewModelProvider.select((state) => state.isLoading));
debugPrint('Building ExpandedStoriesSection...');

return LayoutBuilder(
builder: (context, constraints) {
Expand Down