Skip to content

Commit

Permalink
fix: Hide guest options for guest conversations (#2728)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregor Herdmann committed Mar 8, 2018
1 parent aa1e56f commit 142e9da
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/script/conversation/ConversationStateHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ z.conversation.ConversationStateHandler = class ConversationStateHandler {
}

changeAccessState(conversationEntity, accessState) {
const isTeamConversation = conversationEntity && conversationEntity.team_id;
if (isTeamConversation) {
const isConversationInTeam = conversationEntity && conversationEntity.inTeam();
if (isConversationInTeam) {
const isStateChange = conversationEntity.accessState() !== accessState;

if (isStateChange) {
Expand Down
1 change: 1 addition & 0 deletions app/script/entity/Conversation.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ z.entity.Conversation = class Conversation {
this.is_guest = ko.observable(false);
this.is_managed = false;

this.inTeam = ko.pureComputed(() => this.team_id && !this.is_guest());
this.isGuestRoom = ko.pureComputed(() => this.accessState() === z.conversation.ACCESS_STATE.TEAM.GUEST_ROOM);
this.isTeamOnly = ko.pureComputed(() => this.accessState() === z.conversation.ACCESS_STATE.TEAM.TEAM_ONLY);

Expand Down
2 changes: 1 addition & 1 deletion app/script/view_model/list/StartUIViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ z.viewModel.list.StartUIViewModel = class StartUIViewModel {
const normalizedQuery = z.search.SearchRepository.normalizeQuery(query);
const conversationsForServices = this.conversationRepository
.get_groups_by_name(normalizedQuery, false)
.filter(conversationEntity => conversationEntity.team_id);
.filter(conversationEntity => conversationEntity.inTeam());
this.serviceConversations(conversationsForServices);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ z.viewModel.panel.ConversationDetailsViewModel = class ConversationDetailsViewMo
return userEntity.is_connected() || userEntity.is_team_member();
}
});
this.showActionGuestOptions = ko.pureComputed(() => this.conversationEntity().team_id);
this.showActionGuestOptions = ko.pureComputed(() => this.conversationEntity().inTeam());
this.showActionLeave = ko.pureComputed(() => {
return this.conversationEntity().is_group() && !this.conversationEntity().removed_from_conversation();
});
Expand Down
2 changes: 1 addition & 1 deletion app/script/view_model/panel/GuestOptionsViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ z.viewModel.panel.GuestOptionsViewModel = class GuestOptionsViewModel {

toggleAccessState() {
const conversationEntity = this.conversationEntity();
if (conversationEntity.team_id) {
if (conversationEntity.inTeam()) {
const newAccessState = this.isTeamOnly()
? z.conversation.ACCESS_STATE.TEAM.GUEST_ROOM
: z.conversation.ACCESS_STATE.TEAM.TEAM_ONLY;
Expand Down

0 comments on commit 142e9da

Please sign in to comment.