-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
// 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'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
위에서 찾은 friend
의 id
로 userStatusRepository
의 key
가 있는 지 체크해서 있으면 status
, 없으면 offline
을 보냅니다.
There was a problem hiding this 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>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
생각해보니까 아래에서 userStatusList
에 대해 set
과 같이 update가 필요한데 readonly
가 있어도 괜찮나요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
userStatusList
라는 Map
객체에 대한 readonly
라서 element 를 수정하는 것에는 지장이 없습니다!
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|| 'offline'
은 언제인가요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
윗 댓글에 어떤 상황에서 offline
이 되는 지 적어놓았습니다. 참고해주세요!
위에서 찾은
friend
의id
로userStatusRepository
의key
가 있는 지 체크해서 있으면status
, 없으면offline
을 보냅니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
당신은 배겐드 달인! 감삼다~
There was a problem hiding this 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
Summary
GET /friend
API 수정Describe your changes
RepositoryModule
을AppModule
에 등록 및FriendModule
에서 import 하여 사용합니다.ts-node
로 컴파일하면 패키지 로딩 때require
가 사용되는데,nanoid@4.0.0
부터는import
만 허용되고require
는 허용하지 않는 이슈가 있어3.3.4
로 버전을 다운그레이드 하였습니다. 참고Issue number and link