++Strette di Mano
This commit is contained in:
@@ -5601,7 +5601,7 @@ export const tools = {
|
||||
// console.log('OUT', res)
|
||||
|
||||
if (res && res.userprofile) {
|
||||
// console.log('updateMyData')
|
||||
console.log('updateMyData', res.userprofile)
|
||||
userStore.my.profile = res.userprofile
|
||||
|
||||
if (res.listcircuits) {
|
||||
@@ -6599,24 +6599,26 @@ export const tools = {
|
||||
tools.refuseReqGroup($q, username, dest)
|
||||
} else if (cmd === shared_consts.GROUPSCMD.CANCEL_REQ_GROUP) {
|
||||
tools.cancelReqGroups($q, username, dest)
|
||||
} else if (cmd === shared_consts.FRIENDSCMD.REMOVE_FROM_MYFRIENDS) {
|
||||
tools.removeFromMyFriends($q, username, dest)
|
||||
} else if (cmd === shared_consts.FRIENDSCMD.BLOCK_USER) {
|
||||
tools.blockUser($q, username, dest)
|
||||
} else if (cmd === shared_consts.FRIENDSCMD.SETFRIEND) {
|
||||
tools.addToMyFriends($q, username, dest)
|
||||
} else if (cmd === shared_consts.FRIENDSCMD.REQFRIEND) {
|
||||
tools.setRequestFriendship($q, username, dest, value)
|
||||
} else if (cmd === shared_consts.FRIENDSCMD.REMOVE_FROM_MYFRIENDS) {
|
||||
tools.removeFromMyFriends($q, username, dest)
|
||||
} else if (cmd === shared_consts.FRIENDSCMD.REFUSE_REQ_FRIEND) {
|
||||
tools.refuseReqFriends($q, username, dest)
|
||||
} else if (cmd === shared_consts.FRIENDSCMD.CANCEL_REQ_FRIEND) {
|
||||
tools.cancelReqFriends($q, username, dest)
|
||||
} else if (cmd === shared_consts.FRIENDSCMD.SETHANDSHAKE) {
|
||||
tools.addToMyHandShake($q, username, dest)
|
||||
} else if (cmd === shared_consts.FRIENDSCMD.REQHANDSHAKE) {
|
||||
tools.setRequestHandShake($q, username, dest, value)
|
||||
} else if (cmd === shared_consts.FRIENDSCMD.REFUSE_REQ_FRIEND) {
|
||||
tools.refuseReqFriends($q, username, dest)
|
||||
} else if (cmd === shared_consts.FRIENDSCMD.REMOVE_FROM_MYHANDSHAKE) {
|
||||
tools.removeFromMyHandShake($q, username, dest)
|
||||
} else if (cmd === shared_consts.FRIENDSCMD.REFUSE_REQ_HANDSHAKE) {
|
||||
tools.refuseReqHandShake($q, username, dest)
|
||||
} else if (cmd === shared_consts.FRIENDSCMD.CANCEL_REQ_FRIEND) {
|
||||
tools.cancelReqFriends($q, username, dest)
|
||||
} else if (cmd === shared_consts.FRIENDSCMD.CANCEL_REQ_HANDSHAKE) {
|
||||
tools.cancelReqHandShake($q, username, dest)
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.SET) {
|
||||
@@ -7282,6 +7284,35 @@ export const tools = {
|
||||
|
||||
return common
|
||||
},
|
||||
// Function to return commonElements
|
||||
getCommonAllRecord(arr1: any, arr2: any, field: string): any[] {
|
||||
// @ts-ignore
|
||||
arr1.sort((a: any, b: any) => (a[field] > b[field]) - (a[field] < b[field])) // Sort both the arrays
|
||||
// @ts-ignore
|
||||
arr2.sort((a: any, b: any) => (a[field] > b[field]) - (a[field] < b[field]))
|
||||
|
||||
// console.log('arr1', arr1)
|
||||
// console.log('arr2', arr2)
|
||||
let common = [] // Array to contain common elements
|
||||
let i = 0, j = 0 // i points to arr1 and j to arr2
|
||||
// Break if one of them runs out
|
||||
while (i < arr1.length && j < arr2.length) {
|
||||
|
||||
if (arr1[i][field] == arr2[j][field]) { // If both are same, add it to result
|
||||
common.push(arr1[i])
|
||||
i++
|
||||
j++
|
||||
} else if (arr1[i][field] < arr2[j][field]) { // Increment the smaller value so that
|
||||
i++ // it could be matched with the larger
|
||||
} // element
|
||||
else {
|
||||
j++
|
||||
}
|
||||
}
|
||||
|
||||
return common
|
||||
},
|
||||
|
||||
isTypeByRecMov(rec: IMovVisu) {
|
||||
|
||||
let type = costanti.TypeMov.Nessuno
|
||||
|
||||
@@ -410,6 +410,13 @@ export const useUserStore = defineStore('UserStore', {
|
||||
return tools.getCommon([...this.my.profile.mycircuits], [...group.mycircuits], 'circuitname')
|
||||
},
|
||||
|
||||
getMyHandshakeInCommon(myuser: IUserFields): any[] {
|
||||
|
||||
if (!this.my.profile.handshake || (!myuser || !myuser.profile.handshake))
|
||||
return []
|
||||
return tools.getCommonAllRecord([...this.my.profile.handshake], [...myuser.profile.handshake], 'username')
|
||||
},
|
||||
|
||||
|
||||
getAccountByCircuitId(circuitId: string): any {
|
||||
if (this.my.profile.useraccounts) {
|
||||
@@ -1174,14 +1181,11 @@ export const useUserStore = defineStore('UserStore', {
|
||||
idnotif
|
||||
}
|
||||
|
||||
return Api.SendReq('/users/profile', 'POST', data)
|
||||
return await Api.SendReq('/users/profile', 'POST', data)
|
||||
.then((ris) => {
|
||||
this.my.profile.friends = ris.data.friends.listFriends ? ris.data.friends.listFriends : []
|
||||
this.my.profile.req_friends = ris.data.friends.listRequestFriends ? ris.data.friends.listRequestFriends : []
|
||||
this.my.profile.handshake = ris.data.friends.listHandShake ? ris.data.friends.listHandShake : []
|
||||
this.my.profile.req_handshake = ris.data.friends.listRequestHandShake ? ris.data.friends.listRequestHandShake : []
|
||||
this.my.profile.asked_friends = ris.data.friends.listSentRequestFriends ? ris.data.friends.listSentRequestFriends : []
|
||||
this.my.profile.asked_handshake = ris.data.friends.listSentRequestHandShake ? ris.data.friends.listSentRequestHandShake : []
|
||||
if (this.my.username === ris.data.user.username) {
|
||||
// this.updateDataFr(ris.data.friends)
|
||||
}
|
||||
|
||||
return ris.data.user
|
||||
}).catch((error) => {
|
||||
@@ -1280,15 +1284,21 @@ export const useUserStore = defineStore('UserStore', {
|
||||
|
||||
},
|
||||
|
||||
async loadFriends(username: string) {
|
||||
updateDataFr(data: any) {
|
||||
console.log('updateDataFr', data)
|
||||
this.my.profile.friends = data.listFriends ? data.listFriends : []
|
||||
this.my.profile.req_friends = data.listRequestFriends ? data.listRequestFriends : []
|
||||
this.my.profile.asked_friends = data.listSentRequestFriends ? data.listSentRequestFriends : []
|
||||
|
||||
this.my.profile.handshake = data.listHandShake ? data.listHandShake : []
|
||||
this.my.profile.req_handshake = data.listRequestHandShake ? data.listRequestHandShake : []
|
||||
this.my.profile.asked_handshake = data.listSentRequestHandShake ? data.listSentRequestHandShake : []
|
||||
},
|
||||
|
||||
async loadFriends() {
|
||||
return Api.SendReq('/users/friends', 'POST', null)
|
||||
.then((ris) => {
|
||||
this.my.profile.friends = ris.data.listFriends ? ris.data.listFriends : []
|
||||
this.my.profile.req_friends = ris.data.listRequestFriends ? ris.data.listRequestFriends : []
|
||||
this.my.profile.handshake = ris.data.friends.listHandShake ? ris.data.friends.listHandShake : []
|
||||
this.my.profile.req_handshake = ris.data.friends.listRequestHandShake ? ris.data.friends.listRequestHandShake : []
|
||||
this.my.profile.asked_friends = ris.data.listSentRequestFriends ? ris.data.listSentRequestFriends : []
|
||||
this.my.profile.asked_handshake = ris.data.friends.listSentRequestHandShake ? ris.data.friends.listSentRequestHandShake : []
|
||||
this.updateDataFr(ris.data)
|
||||
return ris.data
|
||||
}).catch((error) => {
|
||||
return {}
|
||||
|
||||
Reference in New Issue
Block a user