diff --git a/frontend/lib/main.dart b/frontend/lib/main.dart index d6db56c40c..d0575deb17 100644 --- a/frontend/lib/main.dart +++ b/frontend/lib/main.dart @@ -146,11 +146,16 @@ class _MyHomePageState extends State { // 로그인된 상태이면 - 유저 목록 post, sub 요청 if (userToken != null) { // http post 요청 - getAllUsers(userToken!, cafeList).then((value) { + getAllUsers(userToken!, cafeList, userProfile.userId!).then((value) { allUsers.setAllUsers(value); // 주변 모든 카페에 sub 요청 - subCafeList(stompClient, cafeList, allUsers); + subCafeList( + stompClient: stompClient, + cafeList: cafeList, + allUsers: allUsers, + userId: userProfile.userId!, + ); }); } } diff --git a/frontend/lib/model/all_users_model.dart b/frontend/lib/model/all_users_model.dart index 50f9c3c12f..e9aaab7a16 100644 --- a/frontend/lib/model/all_users_model.dart +++ b/frontend/lib/model/all_users_model.dart @@ -16,7 +16,10 @@ class AllUsersModel extends ChangeNotifier { } void addUser(String cafeId, UserModel user) { - allUsers[cafeId]!.add(user); + // 중복 체크 후 추가 + if (allUsers[cafeId]!.contains(user) == false) { + allUsers[cafeId]!.add(user); + } notifyListeners(); } diff --git a/frontend/lib/screen/cafe_details.dart b/frontend/lib/screen/cafe_details.dart index fff9a3ba85..0e222dc111 100644 --- a/frontend/lib/screen/cafe_details.dart +++ b/frontend/lib/screen/cafe_details.dart @@ -83,7 +83,6 @@ class _CafeDetailsState extends State String photoUrl = ''; late AutoOfflineService autoOfflineService; - late UserProfileModel userProfile; late List userList; late MyCafeModel myCafe; late MatchingInfoModel matchingInfo; @@ -153,7 +152,6 @@ class _CafeDetailsState extends State autoOfflineService = Provider.of(context, listen: false); stompClient = Provider.of(context); - userProfile = Provider.of(context); userList = Provider.of(context).getUserList(widget.cafeId); myCafe = Provider.of(context); matchingInfo = Provider.of(context); @@ -230,20 +228,18 @@ class _CafeDetailsState extends State ListView.builder( itemCount: userList.length, itemBuilder: (context, index) { - return (userList[index].userId == userProfile.userId) - ? Container() - : UserItem( - type: "cafeUser", - userId: userList[index].userId, - nickname: userList[index].nickname, - company: userList[index].company, - position: userList[index].position, - introduction: userList[index].introduction, - rating: userList[index].rating, - matchId: '', // 안 쓰는 값이기에 초기값 넣어줌 - logoUrl: '', - requestTypeId: 0, // 안 쓰는 값이기에 초기값 넣어줌 - ); + return UserItem( + type: "cafeUser", + userId: userList[index].userId, + nickname: userList[index].nickname, + company: userList[index].company, + position: userList[index].position, + introduction: userList[index].introduction, + rating: userList[index].rating, + matchId: '', // 안 쓰는 값이기에 초기값 넣어줌 + logoUrl: '', + requestTypeId: 0, // 안 쓰는 값이기에 초기값 넣어줌 + ); }, ), (myCafe.cafeId != null) @@ -272,8 +268,8 @@ class _CafeDetailsState extends State builder: (context) { bool setOrChange = myCafe.cafeId == null ? true : false; String content = setOrChange - ? "${widget.cafeName}을(를) 내 위치로 표시하겠습니까?" - : "${widget.cafeName}을(를) 내 위치로 표시하도록 변경하겠습니까?"; + ? "${widget.cafeName}을(를) \n내 위치로 표시하시겠습니까?" + : "${widget.cafeName}을(를) 내 위치로 \n표시하도록 변경하시겠습니까?"; return YesOrNoDialog( content: content, diff --git a/frontend/lib/screen/coffeechat_req_list.dart b/frontend/lib/screen/coffeechat_req_list.dart index baefb426d4..decd84703f 100644 --- a/frontend/lib/screen/coffeechat_req_list.dart +++ b/frontend/lib/screen/coffeechat_req_list.dart @@ -228,20 +228,15 @@ class _SentReqState extends State { showDialog( context: context, builder: (context) { - return AlertDialog( + return OneButtonDialog( content: - const Text('제한 시간이 완료되었습니다.\n다시 매칭 요청을 진행해주세요.'), - actions: [ - TextButton( - onPressed: () { - Navigator.of(context).pop(); - setState(() { - _sendinfoFuture = sendinfo(); - }); - }, - child: const Text('확인'), - ), - ], + '10분이 지나 요청이 자동으로 취소되었어요!\n다시 커피챗 요청을 진행해주세요.', + onFirstButtonClick: () { + Navigator.of(context).pop(); + setState(() { + _sendinfoFuture = sendinfo(); + }); + }, ); }, ); diff --git a/frontend/lib/service/api_service.dart b/frontend/lib/service/api_service.dart index a4de640faa..b21c84ad82 100644 --- a/frontend/lib/service/api_service.dart +++ b/frontend/lib/service/api_service.dart @@ -11,7 +11,7 @@ const storage = FlutterSecureStorage(); // 주변 카페에 있는 모든 유저 목록 받아오기 - http post 요청 Future>> getAllUsers( - String userToken, List cafeList) async { + String userToken, List cafeList, int userId) async { try { final url = Uri.parse("$baseUrl/cafe/get-users"); final response = await http.post( @@ -32,8 +32,10 @@ Future>> getAllUsers( jsonResult.forEach((cafe, userList) { List> userMapList = userList.cast>(); - allUsers[cafe] = - userMapList.map((user) => UserModel.fromJson(user)).toList(); + allUsers[cafe] = userMapList + .where((user) => user["userId"] != userId) + .map((user) => UserModel.fromJson(user)) + .toList(); }); return allUsers; diff --git a/frontend/lib/service/stomp_service.dart b/frontend/lib/service/stomp_service.dart index 0014b9bf3a..b116fcbcb0 100644 --- a/frontend/lib/service/stomp_service.dart +++ b/frontend/lib/service/stomp_service.dart @@ -7,8 +7,12 @@ import 'package:frontend/widgets/dialog/one_button_dialog.dart'; import 'package:stomp_dart_client/stomp.dart'; // cafe list의 각 cafe에 sub 요청 -void subCafeList( - StompClient stompClient, List cafeList, AllUsersModel allUsers) { +void subCafeList({ + required StompClient stompClient, + required List cafeList, + required AllUsersModel allUsers, + required int userId, +}) { if (!stompClient.connected) { throw Exception("stompClient is not connected !!"); } @@ -20,6 +24,11 @@ void subCafeList( // sub 응답 처리 Map result = jsonDecode(frame.body!); + // 자기 자신에 대한 sub은 무시 + if (result["userId"] == userId) { + return; + } + // 카페에 사용자 add if (result["type"] == "add") { print("add user in cafe $cafeId"); diff --git a/frontend/lib/widgets/dialog/yn_dialog.dart b/frontend/lib/widgets/dialog/yn_dialog.dart index f83a1eef0d..e83951dafb 100644 --- a/frontend/lib/widgets/dialog/yn_dialog.dart +++ b/frontend/lib/widgets/dialog/yn_dialog.dart @@ -10,6 +10,7 @@ class YesOrNoDialog extends StatelessWidget { final Function()? handleSecondClick; const YesOrNoDialog({ + super.key, this.content = '', this.firstButton, this.secondButton, @@ -25,9 +26,11 @@ class YesOrNoDialog extends StatelessWidget { borderRadius: BorderRadius.circular(20), ), child: Container( + constraints: const BoxConstraints(minHeight: 200), padding: const EdgeInsets.all(20), child: Column( mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ const SizedBox( height: 15,