Social: Fix load message list

pull/4020/head^2
Angel Fernando Quiroz Campos 3 years ago
parent 4ba5f63b2e
commit 2e3dbb353f
  1. 18
      assets/vue/components/socialnetwork/PostList.vue
  2. 11
      assets/vue/views/socialnetwork/Layout.vue

@ -4,17 +4,20 @@
:key="message.id"
:message="message"
/>
<Loading :visible="isLoading" />
</template>
<script>
import {MESSAGE_TYPE_WALL} from "../message/msgType";
import SocialNetworkPost from "./Post";
import {useStore} from "vuex";
import {ref, watch} from "vue";
import {computed, ref, watch} from "vue";
import Loading from "../Loading";
export default {
name: "SocialNetworkPostList",
components: {SocialNetworkPost},
components: {Loading, SocialNetworkPost},
props: {
user: {
type: Object,
@ -22,21 +25,19 @@ export default {
}
},
setup(props) {
console.log(props.user, '<<<<<<');
const store = useStore();
let messageList = ref([]);
function listMessage(user) {
async function listMessage(user) {
store.state.message.resetList = true;
store.dispatch('message/fetchAll', {
await store.dispatch('message/fetchAll', {
msgType: MESSAGE_TYPE_WALL,
'receivers.receiver': user['@id'],
'order[sendDate]': 'desc',
}).then(() => {
messageList.value = store.getters['message/list'];
});
messageList.value = store.getters['message/list'];
}
watch(() => props.user, (current) => {listMessage(current)});
@ -44,7 +45,8 @@ export default {
listMessage(props.user);
return {
messageList
messageList,
isLoading: computed(() => store.state.message.isLoading)
}
}
}

@ -1,7 +1,10 @@
<template>
<div class="row q-col-gutter-md">
<div class="col-8">
<SocialNetworkHome :user="user" />
<SocialNetworkHome
:user="user"
v-if="user && user['@id']"
/>
</div>
<div class="col-4">
<q-card flat bordered>
@ -41,7 +44,11 @@ export default {
async function setUser(uid) {
if (uid) {
store.dispatch('user/load', uid).then(data => {user.value = data});
try {
user.value = await store.dispatch('user/load', uid);
} catch (e) {
user.value = {};
}
} else {
user.value = currentUser;
}

Loading…
Cancel
Save