Skip to content

Commit

Permalink
remove duped onVideoCallChanged() in ChatView.vue in favor of App.vue
Browse files Browse the repository at this point in the history
aa
  • Loading branch information
nkonev committed Dec 24, 2024
1 parent 5aac458 commit 2d015aa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
12 changes: 9 additions & 3 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -749,11 +749,17 @@ export default {
this.showNotificationBadge = this.chatStore.notificationsCount != 0 && !this.chatStore.showDrawer
},
updateVideoBadge() {
this.showVideoBadge = !!this.chatStore.videoChatUsersCount
this.showVideoBadge = !!parseInt(this.chatStore.videoChatUsersCount)
},
// needed to update video badge after /api/video/${chatId}/users was called by FOCUS event
onVideoCallChanged() {
this.updateVideoBadge();
onVideoCallChanged(dto) {
if (dto.chatId == this.chatId) {
this.chatStore.videoChatUsersCount = dto.usersCount;
this.$nextTick(()=>{
console.debug("For", dto, "updating updateVideoBadge with", this.chatStore.videoChatUsersCount);
this.updateVideoBadge();
})
}
},
onNotificationCountChanged() {
this.updateNotificationBadge();
Expand Down
8 changes: 0 additions & 8 deletions frontend/src/ChatView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ export default {
})
.then(response => response.data)
.then(data => {
this.chatStore.videoChatUsersCount = data.usersCount;
bus.emit(VIDEO_CALL_USER_COUNT_CHANGED, data);
})
return Promise.resolve();
Expand Down Expand Up @@ -571,11 +570,6 @@ export default {
// after the joining all user 2 want to see chat of blog at the left
return this.chatStore.currentUser && this.initialLoaded
},
onVideoCallChanged(dto) {
if (dto.chatId == this.chatId) {
this.chatStore.videoChatUsersCount = dto.usersCount;
}
},
onWsRestoredRefresh() {
this.getInfo(this.chatId)
},
Expand Down Expand Up @@ -835,7 +829,6 @@ export default {
bus.on(MESSAGE_BROADCAST, this.onUserBroadcast);
bus.on(CHAT_EDITED, this.onChatChange);
bus.on(CHAT_DELETED, this.onChatDelete);
bus.on(VIDEO_CALL_USER_COUNT_CHANGED, this.onVideoCallChanged);
bus.on(REFRESH_ON_WEBSOCKET_RESTORED, this.onWsRestoredRefresh);
bus.on(VIDEO_DIAL_STATUS_CHANGED, this.onChatDialStatusChange);
bus.on(PARTICIPANT_DELETED, this.onParticipantDeleted);
Expand Down Expand Up @@ -865,7 +858,6 @@ export default {
bus.off(MESSAGE_BROADCAST, this.onUserBroadcast);
bus.off(CHAT_EDITED, this.onChatChange);
bus.off(CHAT_DELETED, this.onChatDelete);
bus.off(VIDEO_CALL_USER_COUNT_CHANGED, this.onVideoCallChanged);
bus.off(REFRESH_ON_WEBSOCKET_RESTORED, this.onWsRestoredRefresh);
bus.off(VIDEO_DIAL_STATUS_CHANGED, this.onChatDialStatusChange);
bus.off(PARTICIPANT_DELETED, this.onParticipantDeleted);
Expand Down
8 changes: 2 additions & 6 deletions video/handlers/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http"
"nkonev.name/video/auth"
"nkonev.name/video/client"
"nkonev.name/video/dto"
. "nkonev.name/video/logger"
"nkonev.name/video/services"
"nkonev.name/video/utils"
Expand All @@ -24,11 +25,6 @@ func NewUserHandler(chatClient *client.RestClient, userService *services.UserSer
return &UserHandler{chatClient: chatClient, userService: userService, livekitRoomClient: livekitRoomClient, lgr: lgr}
}

type CountUsersResponse struct {
UsersCount int64 `json:"usersCount"`
ChatId int64 `json:"chatId"`
}

func (h *UserHandler) GetVideoUsers(c echo.Context) error {
var userPrincipalDto, ok = c.Get(utils.USER_PRINCIPAL_DTO).(*auth.AuthResult)
if !ok {
Expand All @@ -52,7 +48,7 @@ func (h *UserHandler) GetVideoUsers(c echo.Context) error {
return c.NoContent(http.StatusInternalServerError)
}

return c.JSON(http.StatusOK, CountUsersResponse{UsersCount: usersCount, ChatId: chatId})
return c.JSON(http.StatusOK, dto.VideoCallUserCountChangedDto{UsersCount: usersCount, ChatId: chatId})
}

func (h *UserHandler) Kick(c echo.Context) error {
Expand Down

0 comments on commit 2d015aa

Please sign in to comment.