strette di mano
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user