strette di mano
This commit is contained in:
@@ -243,6 +243,10 @@ export const costanti = {
|
||||
FIND_GROUP: 20,
|
||||
MY_GROUPS: 21,
|
||||
USER_GROUPS: 22,
|
||||
HANDSHAKE: 23,
|
||||
REQ_HANDSHAKE: 24,
|
||||
ASK_SENT_HANDSHAKE: 25,
|
||||
|
||||
CREATE_GROUP: 30,
|
||||
MANAGE_GROUPS: 31,
|
||||
ADMIN_GROUPS: 40,
|
||||
|
||||
@@ -3030,23 +3030,28 @@ export const tools = {
|
||||
},
|
||||
|
||||
getstrShortDate(mydate: Date | number | string | undefined) {
|
||||
const DateFormatter = new Intl.DateTimeFormat(toolsext.getLocale() || void 0, {
|
||||
weekday: 'long',
|
||||
day: 'numeric',
|
||||
month: 'short',
|
||||
year: 'numeric',
|
||||
// timeZone: 'UTC'
|
||||
})
|
||||
try {
|
||||
if (DateFormatter) {
|
||||
// @ts-ignore
|
||||
const date1 = new Date(mydate)
|
||||
return DateFormatter.format(date1)
|
||||
const DateFormatter = new Intl.DateTimeFormat(toolsext.getLocale() || void 0, {
|
||||
weekday: 'long',
|
||||
day: 'numeric',
|
||||
month: 'short',
|
||||
year: 'numeric',
|
||||
// timeZone: 'UTC'
|
||||
})
|
||||
try {
|
||||
if (DateFormatter) {
|
||||
// @ts-ignore
|
||||
const date1 = new Date(mydate)
|
||||
return DateFormatter.format(date1)
|
||||
}
|
||||
return mydate
|
||||
} catch (e) {
|
||||
return ''
|
||||
}
|
||||
return mydate
|
||||
} catch (e) {
|
||||
return ''
|
||||
}
|
||||
|
||||
},
|
||||
getstrVeryShortDate(mydate: Date | number | string | undefined) {
|
||||
const DateFormatter = new Intl.DateTimeFormat(toolsext.getLocale() || void 0, {
|
||||
@@ -5455,6 +5460,48 @@ export const tools = {
|
||||
})
|
||||
},
|
||||
|
||||
addToMyHandShake($q: any, username: string, usernameDest: string) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
const notifStore = useNotifStore()
|
||||
$q.dialog({
|
||||
message: t('db.domanda_addtohandshake', { username: usernameDest }),
|
||||
ok: { label: t('dialog.yes'), push: true },
|
||||
cancel: { label: t('dialog.cancel') },
|
||||
title: t('db.domanda')
|
||||
}).onOk(() => {
|
||||
|
||||
userStore.setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.SETHANDSHAKE, null)
|
||||
.then((res: any) => {
|
||||
if (res) {
|
||||
notifStore.updateNotification = true
|
||||
userStore.my.profile.handshake = [...userStore.my.profile.handshake, res]
|
||||
userStore.my.profile.req_handshake = userStore.my.profile.req_handshake.filter((rec: IFriends) => rec.username !== usernameDest)
|
||||
tools.showPositiveNotif($q, t('db.addedhandshake'))
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
removeFromMyHandShake($q: any, username: string, usernameDest: string) {
|
||||
const userStore = useUserStore()
|
||||
|
||||
$q.dialog({
|
||||
message: t('db.domanda_removehandshake', { username: usernameDest }),
|
||||
ok: { label: t('dialog.yes'), push: true },
|
||||
cancel: { label: t('dialog.cancel') },
|
||||
title: t('db.domanda')
|
||||
}).onOk(() => {
|
||||
|
||||
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)
|
||||
tools.showPositiveNotif($q, t('db.removedhandshake'))
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
blockUser($q: any, username: string, usernameDest: string) {
|
||||
const userStore = useUserStore()
|
||||
$q.dialog({
|
||||
@@ -5525,6 +5572,27 @@ export const tools = {
|
||||
})
|
||||
},
|
||||
|
||||
refuseReqHandShake($q: any, username: string, usernameDest: string) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
const notifStore = useNotifStore()
|
||||
$q.dialog({
|
||||
message: t('db.domanda_revoke_handshake', { username: usernameDest }),
|
||||
ok: { label: t('dialog.yes'), push: true },
|
||||
cancel: { label: t('dialog.cancel') },
|
||||
title: t('db.domanda')
|
||||
}).onOk(() => {
|
||||
|
||||
userStore.setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.REMOVE_FROM_MYHANDSHAKE, null).then((res) => {
|
||||
if (res) {
|
||||
notifStore.updateNotification = true
|
||||
userStore.my.profile.req_handshake = userStore.my.profile.req_handshake.filter((user: IFriends) => user.username !== usernameDest)
|
||||
tools.showPositiveNotif($q, t('db.removedhandshake'))
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
updateMyData(res: any) {
|
||||
const userStore = useUserStore()
|
||||
const circuitStore = useCircuitStore()
|
||||
@@ -5805,6 +5873,49 @@ export const tools = {
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
setRequestHandShake($q: any, username: string, usernameDest: string, value: boolean) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
let msg = ''
|
||||
if (value) {
|
||||
msg = t('db.domanda_ask_handshake', { username: usernameDest })
|
||||
} else {
|
||||
msg = t('db.domanda_revoke_handshake', { username: usernameDest })
|
||||
}
|
||||
|
||||
$q.dialog({
|
||||
message: msg,
|
||||
ok: {
|
||||
label: t('dialog.yes'),
|
||||
push: true
|
||||
},
|
||||
cancel: {
|
||||
label: t('dialog.cancel')
|
||||
},
|
||||
title: t('db.domanda')
|
||||
}).onOk(() => {
|
||||
|
||||
userStore.setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.REQHANDSHAKE, value)
|
||||
.then((res: any) => {
|
||||
if (res) {
|
||||
if (value) {
|
||||
// ADD to req HandShake
|
||||
userStore.my.profile.asked_handshake.push(res)
|
||||
tools.showPositiveNotif($q, t('db.askedtohandshake', { username: usernameDest }))
|
||||
} else {
|
||||
// REMOVE to req HandShake
|
||||
userStore.my.profile.asked_handshake = userStore.my.profile.asked_handshake.filter((rec: IUserFields) => rec.username !== usernameDest)
|
||||
tools.showPositiveNotif($q, t('db.revoketohandshake', { username: usernameDest }))
|
||||
}
|
||||
|
||||
} else {
|
||||
tools.showNegativeNotif($q, t('db.recfailed'))
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
setRequestGroup($q: any, username: string, groupnameDest: string, value: boolean) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
@@ -5864,6 +5975,23 @@ export const tools = {
|
||||
})
|
||||
})
|
||||
},
|
||||
cancelReqHandShake($q: any, username: string, usernameDest: string) {
|
||||
const userStore = useUserStore()
|
||||
$q.dialog({
|
||||
message: t('db.domanda_cancel_req_handshake', { username: usernameDest }),
|
||||
ok: { label: t('dialog.yes'), push: true },
|
||||
cancel: { label: t('dialog.cancel') },
|
||||
title: t('db.domanda')
|
||||
}).onOk(() => {
|
||||
|
||||
userStore.setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.CANCEL_REQ_HANDSHAKE, null).then((res) => {
|
||||
if (res) {
|
||||
userStore.my.profile.asked_handshake = userStore.my.profile.asked_handshake.filter((rec: IUserFields) => rec.username !== usernameDest)
|
||||
tools.showPositiveNotif($q, t('db.cancel_req_handshake'))
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
cancelReqGroups($q: any, username: string, groupnameDest: string) {
|
||||
const userStore = useUserStore()
|
||||
$q.dialog({
|
||||
@@ -6479,10 +6607,18 @@ export const tools = {
|
||||
tools.addToMyFriends($q, username, dest)
|
||||
} else if (cmd === shared_consts.FRIENDSCMD.REQFRIEND) {
|
||||
tools.setRequestFriendship($q, username, dest, value)
|
||||
} 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.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) {
|
||||
tools.addToMyCircuits($q, username, dest)
|
||||
} else if (cmd === shared_consts.CIRCUITCMD.REQ) {
|
||||
@@ -7079,30 +7215,6 @@ export const tools = {
|
||||
}
|
||||
},
|
||||
|
||||
timeAgo(input: any) {
|
||||
const date = (input instanceof Date) ? input : new Date(input)
|
||||
const formatter = new Intl.RelativeTimeFormat(toolsext.getLocale() || 'it')
|
||||
const ranges: any = {
|
||||
years: 3600 * 24 * 365,
|
||||
months: 3600 * 24 * 30,
|
||||
weeks: 3600 * 24 * 7,
|
||||
days: 3600 * 24,
|
||||
hours: 3600,
|
||||
minutes: 60,
|
||||
seconds: 1
|
||||
}
|
||||
const secondsElapsed = (date.getTime() - Date.now()) / 1000
|
||||
let key: any
|
||||
for (key in ranges) {
|
||||
if (ranges[key] < Math.abs(secondsElapsed)) {
|
||||
// @ts-ignore
|
||||
const delta = secondsElapsed / ranges[key]
|
||||
// @ts-ignore
|
||||
return formatter.format(Math.round(delta), key)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getEnv(name: string) {
|
||||
const config: any = {
|
||||
// @ts-ignore
|
||||
|
||||
@@ -65,6 +65,9 @@ export const DefaultUser: IUserFields = {
|
||||
myshares: [],
|
||||
friends: [],
|
||||
req_friends: [],
|
||||
handshake: [],
|
||||
req_handshake: [],
|
||||
asked_handshake: [],
|
||||
mygroups: [],
|
||||
mycircuits: [],
|
||||
manage_mygroups: [],
|
||||
@@ -123,6 +126,9 @@ export const DefaultProfile: IUserProfile = {
|
||||
myshares: [],
|
||||
friends: [],
|
||||
req_friends: [],
|
||||
handshake: [],
|
||||
req_handshake: [],
|
||||
asked_handshake: [],
|
||||
mygroups: [],
|
||||
mycircuits: [],
|
||||
manage_mygroups: [],
|
||||
@@ -220,6 +226,12 @@ export const useUserStore = defineStore('UserStore', {
|
||||
else
|
||||
return false
|
||||
},
|
||||
IsHandShakeByUsername(username: string): boolean {
|
||||
if (this.my.profile.handshake)
|
||||
return this.my.profile.handshake.findIndex((rec) => rec.username === username) >= 0
|
||||
else
|
||||
return false
|
||||
},
|
||||
|
||||
IsMyGroupByGroupname(groupname: string): boolean {
|
||||
if (this.my.profile.mygroups)
|
||||
@@ -251,6 +263,13 @@ export const useUserStore = defineStore('UserStore', {
|
||||
return false
|
||||
},
|
||||
|
||||
IsAskedHandShakeByUsername(username: string): boolean {
|
||||
if (this.my.profile.asked_handshake)
|
||||
return this.my.profile.asked_handshake.findIndex((rec) => rec.username === username) >= 0
|
||||
else
|
||||
return false
|
||||
},
|
||||
|
||||
IsReqFriendByUsername(username: string): boolean {
|
||||
if (this.my.profile.req_friends)
|
||||
return this.my.profile.req_friends.findIndex((rec) => rec.username === username) >= 0
|
||||
@@ -258,6 +277,13 @@ export const useUserStore = defineStore('UserStore', {
|
||||
return false
|
||||
},
|
||||
|
||||
IsReqHandShakeByUsername(username: string): boolean {
|
||||
if (this.my.profile.req_handshake)
|
||||
return this.my.profile.req_handshake.findIndex((rec) => rec.username === username) >= 0
|
||||
else
|
||||
return false
|
||||
},
|
||||
|
||||
IsAskedGroupByGroupname(groupname: string): boolean {
|
||||
if (this.my.profile.asked_groups)
|
||||
return this.my.profile.asked_groups.findIndex((rec: IGroupShort) => rec.groupname === groupname) >= 0
|
||||
@@ -733,6 +759,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
// Memory
|
||||
this.my.profile.manage_mygroups = []
|
||||
this.my.profile.asked_friends = []
|
||||
this.my.profile.asked_handshake = []
|
||||
this.my.profile.asked_groups = []
|
||||
this.my.profile.refused_groups = []
|
||||
}
|
||||
@@ -1151,7 +1178,10 @@ export const useUserStore = defineStore('UserStore', {
|
||||
.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 : []
|
||||
|
||||
return ris.data.user
|
||||
}).catch((error) => {
|
||||
@@ -1255,7 +1285,10 @@ export const useUserStore = defineStore('UserStore', {
|
||||
.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 : []
|
||||
return ris.data
|
||||
}).catch((error) => {
|
||||
return {}
|
||||
|
||||
@@ -174,6 +174,8 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
showViewProfile: false,
|
||||
enablePwa: false,
|
||||
lang: costanti.Lang.IT,
|
||||
videoPromo: '',
|
||||
PDFPromo: '',
|
||||
},
|
||||
},
|
||||
provinces: [],
|
||||
|
||||
Reference in New Issue
Block a user