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

✨ [Feature] Add status to get friends #227

Merged
merged 5 commits into from
May 9, 2023

Conversation

jis-kim
Copy link
Contributor

@jis-kim jis-kim commented May 9, 2023

Summary

  • 친구의 접속 상태 표시를 위해 GET /friend API 수정

Describe your changes

  • RepositoryModuleAppModule 에 등록 및 FriendModule 에서 import 하여 사용합니다.
  • ts-node 로 컴파일하면 패키지 로딩 때 require 가 사용되는데, nanoid@4.0.0 부터는 import 만 허용되고 require 는 허용하지 않는 이슈가 있어 3.3.4 로 버전을 다운그레이드 하였습니다. 참고

Issue number and link

@jis-kim jis-kim requested review from anso33 and Kimhan-nah and removed request for anso33 May 9, 2023 06:18
@jis-kim jis-kim self-assigned this May 9, 2023
@jis-kim jis-kim requested a review from anso33 May 9, 2023 06:18
@jis-kim jis-kim added enhancement New feature or request backend issue for backend labels May 9, 2023
@jis-kim jis-kim added this to the Sprint6 milestone May 9, 2023
// messgeView 가 없으면 (find() 가 undefined 이면) null
const lastViewTime = messageView.find((view) => view.user.id === userId)?.lastViewTime || null;
const friend = sender.id === userId ? receiver : sender;
const status = this.userStatusRepository.find(friend.id)?.status || 'offline';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위에서 찾은 friendiduserStatusRepositorykey 가 있는 지 체크해서 있으면 status, 없으면 offline 을 보냅니다.

Copy link
Member

@Kimhan-nah Kimhan-nah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

질문 남겼습니다아

@@ -9,7 +9,7 @@ import { Repository } from './repository.interface';
*/
@Injectable()
export class UserStatusRepository implements Repository<number, UserStatus> {
private readonly userStatusList: Map<number, UserStatus>;
private readonly userStatusList: Map<number, UserStatus> = new Map<number, UserStatus>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

생각해보니까 아래에서 userStatusList에 대해 set과 같이 update가 필요한데 readonly가 있어도 괜찮나요??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

userStatusList 라는 Map 객체에 대한 readonly 라서 element 를 수정하는 것에는 지장이 없습니다!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aha! 감사합니당~~~

// messgeView 가 없으면 (find() 가 undefined 이면) null
const lastViewTime = messageView.find((view) => view.user.id === userId)?.lastViewTime || null;
const friend = sender.id === userId ? receiver : sender;
const status = this.userStatusRepository.find(friend.id)?.status || 'offline';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

|| 'offline'은 언제인가요??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

윗 댓글에 어떤 상황에서 offline 이 되는 지 적어놓았습니다. 참고해주세요!

위에서 찾은 friendiduserStatusRepositorykey 가 있는 지 체크해서 있으면 status, 없으면 offline 을 보냅니다.

Copy link
Member

@Kimhan-nah Kimhan-nah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

당신은 배겐드 달인! 감삼다~

Copy link
Member

@anso33 anso33 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, LGTM, LGTM, (LEFT) || (RIGHT) RGTM, RGTM, RGTM

@jis-kim jis-kim merged commit 2cc01ff into main May 9, 2023
@jis-kim jis-kim deleted the feature/back/add-status-to-get-friends branch May 9, 2023 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend issue for backend enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨ [Feature] 친구 리스트 GET API 에 접속 상태 저장하도록 수정
3 participants