Skip to content

Commit

Permalink
fixing uiStates - removing disabled - moving the own user check to th…
Browse files Browse the repository at this point in the history
…e last
  • Loading branch information
negue committed Jan 13, 2025
1 parent 033d114 commit 70cf860
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions website/client/src/pages/private-messages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,6 @@ const UI_STATES = Object.freeze({
NO_CONVERSATIONS_SELECTED: 'NO_CONVERSATIONS_SELECTED',
START_NEW_CONVERSATION: 'START_NEW_CONVERSATION',
CONVERSATION_SELECTED: 'CONVERSATION_SELECTED',
DISABLED: 'DISABLED',
});
export default defineComponent({
Expand Down Expand Up @@ -752,9 +751,7 @@ export default defineComponent({
description: this.$t('PMPlaceholderDescription'),
};
},
/**
* Any value return, switches the uiState to DISABLED
*/
disabledTexts () {
if (this.user.flags.chatRevoked) {
return {
Expand All @@ -765,15 +762,6 @@ export default defineComponent({
};
}
if (this.user.inbox.optOut) {
return {
enableInput: true,
showBottomInfo: false,
title: this.$t('PMDisabledCaptionTitle'),
description: this.$t('PMDisabledCaptionText'),
};
}
if (this.selectedConversation?.key) {
if (this.user.inbox.blocks.includes(this.selectedConversation.key)) {
return {
Expand All @@ -794,6 +782,15 @@ export default defineComponent({
}
}
if (this.user.inbox.optOut) {
return {
enableInput: true,
showBottomInfo: false,
title: this.$t('PMDisabledCaptionTitle'),
description: this.$t('PMDisabledCaptionText'),
};
}
return null;
},
optTextSet () {
Expand All @@ -815,13 +812,12 @@ export default defineComponent({
return '';
},
newMessageDisabled () {
if (this.uiState === UI_STATES.DISABLED) {
if (this.disabledTexts) {
return !this.disabledTexts.enableInput;
}
return [
UI_STATES.NO_CONVERSATIONS_SELECTED,
UI_STATES.DISABLED,
UI_STATES.NO_CONVERSATIONS,
UI_STATES.LOADING,
].includes(this.uiState);
Expand All @@ -831,10 +827,6 @@ export default defineComponent({
return UI_STATES.LOADING;
}
if (this.disabledTexts) {
return UI_STATES.DISABLED;
}
if (this.loadedConversations.length === 0) {
return UI_STATES.NO_CONVERSATIONS;
}
Expand All @@ -857,8 +849,7 @@ export default defineComponent({
switch (currentUiState) {
case UI_STATES.CONVERSATION_SELECTED:
case UI_STATES.START_NEW_CONVERSATION:
case UI_STATES.DISABLED: {
case UI_STATES.START_NEW_CONVERSATION: {
return true;
}
Expand Down

0 comments on commit 70cf860

Please sign in to comment.