Skip to content

Commit

Permalink
chore: code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
vimercati-samir authored and stavares843 committed Jun 22, 2022
1 parent 2d6626a commit 9acd1ef
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 40 deletions.
17 changes: 6 additions & 11 deletions components/ui/User/State/State.less
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,13 @@
--circle-radius: 10px;
}

&.has-status {
.circle {
mask: radial-gradient(
circle calc(var(--circle-radius) + var(--border-width)) at 86% 86%,
#0000 98%,
#000
)
100% 100%/100% 100% no-repeat;
}
}

.circle {
mask: radial-gradient(
circle calc(var(--circle-radius) + var(--border-width)) at 86% 86%,
#0000 98%,
#000
)
100% 100%/100% 100% no-repeat;
overflow: hidden;
}

Expand Down
41 changes: 13 additions & 28 deletions components/ui/User/State/State.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class="user-state"
data-cy="user-state"
:style="`width:${size}px; height:${size}px`"
:class="{ 'is-large': size > 36, 'has-status': showStatus }"
:class="{ 'is-large': size > 36 }"
>
<UiCircle
data-cy="satellite-circle-profile"
Expand All @@ -13,25 +13,23 @@
:source="src"
@click="clickHandler"
/>
<div v-if="showStatus" class="container-status">
<div
v-if="user.state !== 'mobile' && !isTyping"
class="status"
:class="{ [`is-${user.state}`]: user.state }"
/>
<smartphone-icon
v-else-if="user.state === 'mobile'"
size="1x"
:class="`mobile-status is-${user.state}`"
/>
<UiChatTypingIndicator v-else />
</div>
<div
v-if="user.state !== 'mobile' && !isTyping"
class="status"
:class="{ [`is-${user.state}`]: user.state }"
/>
<smartphone-icon
v-else-if="user.state === 'mobile'"
size="1x"
:class="`mobile-status is-${user.state}`"
/>
<UiChatTypingIndicator v-else />
</div>
</template>

<script lang="ts">
import Vue, { PropType } from 'vue'
import { mapState, mapGetters } from 'vuex'
import { SmartphoneIcon } from 'satellite-lucide-icons'
import { User } from '~/types/ui/user'
Expand Down Expand Up @@ -61,19 +59,6 @@ export default Vue.extend({
default: () => {},
},
},
computed: {
...mapGetters('friends', ['friendExists']),
...mapState(['accounts']),
showStatus() {
return (
this.friendExists(this.$props.user.address) ||
this.$props.user.address === this.accounts.active
)
},
},
mounted() {
console.log(this.showStatus)
},
})
</script>

Expand Down
8 changes: 7 additions & 1 deletion components/views/friends/friend/Friend.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<div class="friend" data-cy="friend">
<UiUserState :user="friend" :src="src" />
<UiUserState v-if="showStatus" :user="friend" :src="src" />
<UiCircle
v-else
:type="src ? 'image' : 'random'"
:seed="friend.address"
:source="src"
/>
<div class="description">
<TypographySubtitle :size="6" :text="friend.name" data-cy="friend-name" />
<TypographyText :text="friend.status" />
Expand Down
10 changes: 10 additions & 0 deletions components/views/friends/friend/Friend.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
CircleIcon,
SmartphoneIcon,
} from 'satellite-lucide-icons'
import { mapState, mapGetters } from 'vuex'
import { ContextMenuItem } from '~/store/ui/types'
import { Friend } from '~/types/ui/friends'
import ContextMenu from '~/components/mixins/UI/ContextMenu'
Expand Down Expand Up @@ -55,6 +57,8 @@ export default Vue.extend({
}
},
computed: {
...mapGetters('friends', ['friendExists']),
...mapState(['accounts']),
src(): string {
const hash =
this.friend?.photoHash ||
Expand All @@ -65,6 +69,12 @@ export default Vue.extend({
contextMenuValues(): ContextMenuItem[] {
return [{ text: this.$t('context.remove'), func: this.removeFriend }]
},
showStatus(): boolean {
return (
this.friendExists(this.$props.friend.address) ||
this.$props.friend.address === this.accounts.active
)
},
},
beforeDestroy() {
this.$store.commit('ui/toggleContextMenu', false)
Expand Down

0 comments on commit 9acd1ef

Please sign in to comment.