Skip to content

Instantly share code, notes, and snippets.

@Jimeux
Last active December 24, 2021 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jimeux/832b845be100a4456b9bdba6a1ca1f2c to your computer and use it in GitHub Desktop.
Save Jimeux/832b845be100a4456b9bdba6a1ca1f2c to your computer and use it in GitHub Desktop.
<script lang="ts">
import { computed, defineComponent, PropType } from "vue"
import { useStore } from "@/store/store"
import { User } from "@/store/data"
export default defineComponent({
name: "UserItem",
props: {
user: {
type: Object as PropType<User>,
required: true,
},
},
setup(props) {
const store = useStore()
const unreadClass = computed(() => {
const u = store.state.unread
return u.has(props.user.connectionId) ? "" : "inactive"
})
const separatorClass = computed(() =>
store.state.currentRecipient?.connectionId === props.user.connectionId
? "active"
: ""
)
const containerClass = computed(() => {
const r = store.state.currentRecipient
return r?.connectionId === props.user.connectionId ? "active" : ""
})
function setRecipient() {
store.setRecipient(props.user)
}
return {
separatorClass,
unreadClass,
klass,
setRecipient,
}
},
})
</script>
<script setup lang="ts">
import {computed, PropType} from "vue"
import {useStore} from "../store/store"
import {User} from "../store/data"
const props = defineProps({
user: {
type: Object as PropType<User>,
required: true,
},
})
const store = useStore()
const unreadClass = computed(() => {
const u = store.state.unread
return u.has(props.user.connectionId) ? "" : "inactive"
})
const separatorClass = computed(() =>
store.state.currentRecipient?.connectionId === props.user.connectionId
? "active"
: ""
)
const containerClass = computed(() => {
const r = store.state.currentRecipient
return r?.connectionId === props.user.connectionId ? "active" : ""
})
function setRecipient() {
store.setRecipient(props.user)
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment