From a9367d5aef0c764d91ba2c036e330b4c0e5cd3ce Mon Sep 17 00:00:00 2001 From: Surya Paolo Date: Mon, 9 Jan 2023 04:05:18 +0100 Subject: [PATCH] fix strette di mano --- src/store/Modules/tools.ts | 5 +- src/store/UserStore.ts | 1 + src/views/user/myprofile/myprofile.ts | 33 +- src/views/user/myprofile/myprofile.vue | 478 +++++++++++++++---------- 4 files changed, 311 insertions(+), 206 deletions(-) diff --git a/src/store/Modules/tools.ts b/src/store/Modules/tools.ts index 2f18f105..6aabbd87 100644 --- a/src/store/Modules/tools.ts +++ b/src/store/Modules/tools.ts @@ -5475,7 +5475,8 @@ export const tools = { .then((res: any) => { if (res) { notifStore.updateNotification = true - userStore.my.profile.handshake = [...userStore.my.profile.handshake, res] + userStore.my.profile.handshake = res.myuser.profile.handshake + userStore.userprofile = res.userprofile tools.showPositiveNotif($q, t('db.addedhandshake')) } }) @@ -5494,7 +5495,7 @@ export const tools = { userStore.setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.REMOVE_FROM_MYHANDSHAKE, null).then((res) => { if (res) { - userStore.my.profile.handshake = userStore.my.profile.handshake.filter((rec: IFriends) => rec.username !== usernameDest) + userStore.userprofile.profile.handshake = userStore.userprofile.profile.handshake.filter((rec: IFriends) => rec.username !== username) tools.showPositiveNotif($q, t('db.removedhandshake')) } }) diff --git a/src/store/UserStore.ts b/src/store/UserStore.ts index 0ce1b7e4..1bdae776 100755 --- a/src/store/UserStore.ts +++ b/src/store/UserStore.ts @@ -148,6 +148,7 @@ export const DefaultProfile: IUserProfile = { export const useUserStore = defineStore('UserStore', { state: () => ({ my: { ...DefaultUser }, + userprofile: DefaultUser, groups: [], lang: process.env.LANG_DEFAULT ? process.env.LANG_DEFAULT : 'it', repeatPassword: '', diff --git a/src/views/user/myprofile/myprofile.ts b/src/views/user/myprofile/myprofile.ts index f09527b0..cb3f131b 100755 --- a/src/views/user/myprofile/myprofile.ts +++ b/src/views/user/myprofile/myprofile.ts @@ -52,27 +52,27 @@ export default defineComponent({ const { getRefLink } = MixinUsers() const animation = ref('fade') - const quantiHandShake = ref('') - const quanteHandShakeInCommon = ref('') - const usersList = ref({show: false, title: '', list: []}) + const usersList = ref({ show: false, title: '', list: [] }) const username = computed(() => $route.params.username ? $route.params.username.toString() : userStore.my.username) const idnotif = computed(() => $route.query.idnotif ? $route.query.idnotif.toString() : '') const isDebugOn = computed(() => tools.isDebugOn()) + const filtroutente = ref([]) const showPic = ref(false) const caricato = ref(false) const showsendCoinTo = ref(false) const showinghand = ref(false) - const myuser = ref(null) - const handshake_inCommon = ref([]) - const actualcard = ref('mygoods') const notifStore = useNotifStore() + const quantiHandShake = computed(() => (userStore.userprofile.profile.handshake ? userStore.userprofile.profile.handshake.length : 0) + ' ' + t('handshake.strettedimano')) + const handshake_inCommon = computed(() => userStore.getMyHandshakeInCommon(userStore.userprofile)) + const quanteHandShakeInCommon = computed(() => (handshake_inCommon.value ? handshake_inCommon.value.length : 0) + ' ' + t('handshake.incommon')) + const mycards = computed(() => { return costanti.MAINCARDS.filter((rec: any) => rec.table) }) @@ -97,23 +97,21 @@ export default defineComponent({ if (username.value) { await userStore.loadUserProfile({ username: username.value, idnotif: idnotif.value }).then((ris) => { console.log('loadUserProfile = ', ris) - myuser.value = ris - if (myuser.value) { - filtroutente.value = [{ userId: myuser.value._id }] + userStore.userprofile = ris + if (userStore.userprofile) { + filtroutente.value = [{ userId: userStore.userprofile._id }] notifStore.setAsRead(idnotif.value) - quantiHandShake.value = (myuser.value.profile.handshake ? myuser.value.profile.handshake.length : 0) + ' ' + t('handshake.strettedimano') - handshake_inCommon.value = userStore.getMyHandshakeInCommon(myuser.value) - quanteHandShakeInCommon.value = (handshake_inCommon.value ? handshake_inCommon.value.length : 0) + ' ' + t('handshake.incommon') try { - listgroupsfiltered.value = globalStore.mygroups.filter((grp: IMyGroup) => myuser.value!.profile.mygroups.findIndex((rec: IMyGroup) => rec.groupname === grp.groupname) >= 0) + if (userStore.userprofile) + listgroupsfiltered.value = globalStore.mygroups.filter((grp: IMyGroup) => userStore.userprofile.profile.mygroups.findIndex((rec: IMyGroup) => rec.groupname === grp.groupname) >= 0) } catch (e) { listgroupsfiltered.value = [] } try { - listcircuitsfiltered.value = myuser.value.profile.mycircuits + listcircuitsfiltered.value = userStore.userprofile.profile.mycircuits } catch (e) { listcircuitsfiltered.value = [] } @@ -123,7 +121,7 @@ export default defineComponent({ caricato.value = true } - }catch (e) { + } catch (e) { console.error('ERR loadProfile', e) } } @@ -141,8 +139,8 @@ export default defineComponent({ } function getImgUser() { - if (myuser.value) - return userStore.getImgByProfile(myuser.value) + if (userStore.userprofile) + return userStore.getImgByProfile(userStore.userprofile) else return '' } @@ -164,7 +162,6 @@ export default defineComponent({ tools, toolsext, costanti, - myuser, shared_consts, getImgUser, checkifShow, diff --git a/src/views/user/myprofile/myprofile.vue b/src/views/user/myprofile/myprofile.vue index bf907f0a..9e49a26e 100755 --- a/src/views/user/myprofile/myprofile.vue +++ b/src/views/user/myprofile/myprofile.vue @@ -3,7 +3,9 @@ Logged: {{ tools.isLogged() }} - UserOk: {{ tools.isUserOk() }} - caricato: {{ caricato }} - - myuser: {{ myuser.username }} + userStore.userprofile: {{ userStore.userprofile.username }}
online OnLine: - +
-
+
- - {{ myuser.name }} + {{ userStore.userprofile.name }} -  {{ myuser.surname }} {{ userStore.userprofile.surname }}
- {{ myuser.username }} + {{ userStore.userprofile.username }}
- + - {{ myuser.profile.born_city_str }} ({{ myuser.profile.nationality }})({{ userStore.userprofile.profile.nationality }})
-
- +
+ {{ myuser.profile.qualifica }}{{ + userStore.userprofile.profile.qualifica + }}
-
- {{ myuser.profile.biografia }} +
+ {{ userStore.userprofile.profile.biografia }}
-
+
- OnLine: + OnLine: +
-
+
- - {{ myuser.name }} + {{ userStore.userprofile.name }} -  {{ myuser.surname }} {{ userStore.userprofile.surname }}
- {{ myuser.username }} + {{ userStore.userprofile.username }}
- + - {{ myuser.profile.born_city_str }} ({{ myuser.profile.nationality }})({{ userStore.userprofile.profile.nationality }})
-
- +
+ {{ - myuser.profile.qualifica + userStore.userprofile.profile.qualifica }}
-
- {{ myuser.profile.biografia }} +
+ {{ userStore.userprofile.profile.biografia }}
- -   - {{ $t('db.both_fiducia', { username: myuser.username }) }} - + - - -   - {{ $t('db.handshake_him', { username: myuser.username }) }} -   + {{ + $t('db.both_fiducia', { + username: userStore.userprofile.username, + }) + }} + + + - - -   - {{ $t('db.handshake_you', { username: myuser.username }) }} -   + {{ + $t('db.handshake_him', { + username: userStore.userprofile.username, + }) + }} + + + - +   + {{ + $t('db.handshake_you', { + username: userStore.userprofile.username, + }) + }} + + +
-
+
@@ -337,8 +396,8 @@ @click=" tools.addToMyHandShake( $q, - myuser.username, - userStore.my.username + userStore.my.username, + userStore.userprofile.username ) " /> @@ -346,11 +405,18 @@
-
+
@@ -372,7 +438,7 @@ tools.refuseReqFriends( $q, userStore.my.username, - myuser.username + userStore.userprofile.username ) " /> @@ -380,8 +446,12 @@
+ + + + {{ + $t('handshake.remove_from_myhandshake') + }} + + - {{ - $t('friends.remove_from_myfriends') - }} - - - {{ - $t('friends.block_user') - }} - - @@ -460,23 +521,55 @@ {{ - $t('friends.report_user') + $t('friends.remove_from_myfriends') }} - - + + + + + {{ + $t('friends.block_user') + }} + + + + + + {{ + $t('friends.report_user') + }} @@ -484,8 +577,12 @@
- +