Friendship Accepted and Refused (notification updated)
This commit is contained in:
@@ -859,6 +859,11 @@ export const shared_consts = {
|
||||
NEW_ADV_SECTOR: 32,
|
||||
},
|
||||
|
||||
StatusNotifs: {
|
||||
STATUS_FRIENDS_ACCEPTED: 1,
|
||||
STATUS_FRIENDS_REFUSED: 2,
|
||||
},
|
||||
|
||||
TypeNotifs: {
|
||||
TYPEDIR_BACHECA: 1,
|
||||
ID_BACHECA_NEW_GOOD: 1,
|
||||
@@ -872,11 +877,15 @@ export const shared_consts = {
|
||||
ID_FRIENDS_NEW_REC: 1,
|
||||
ID_FRIENDS_ACCEPTED: 2,
|
||||
|
||||
TYPEDIR_CIRCUITS: 4,
|
||||
TYPEDIR_GROUPS: 4,
|
||||
ID_GROUP_NEW_REC: 1,
|
||||
ID_GROUP_ACCEPTED: 2,
|
||||
|
||||
TYPEDIR_BOOKING: 5,
|
||||
TYPEDIR_CIRCUITS: 5,
|
||||
|
||||
TYPEDIR_MSGS: 6,
|
||||
TYPEDIR_BOOKING: 6,
|
||||
|
||||
TYPEDIR_MSGS: 7,
|
||||
ID_MSGS_NEW_REC: 1,
|
||||
|
||||
},
|
||||
|
||||
@@ -80,6 +80,12 @@ export default defineComponent({
|
||||
}
|
||||
})
|
||||
|
||||
watch(() => notifStore.updateNotification, async (to: any, from: any) => {
|
||||
if (notifStore.updateNotification) {
|
||||
await refreshdata(userStore.my.username)
|
||||
}
|
||||
})
|
||||
|
||||
function clickNotif(notif: INotif) {
|
||||
if (notif.openUrl) {
|
||||
let mylink = tools.updateQueryStringParameter(notif.openUrl, 'idnotif', notif._id)
|
||||
@@ -101,7 +107,7 @@ export default defineComponent({
|
||||
// Get msg for this
|
||||
|
||||
let myrec = getlastnotif(username)
|
||||
const lastdata: any = (myrec) ? myrec.lastdataread : tools.getLastDateReadReset()
|
||||
const lastdata: any = (myrec && myrec.lastdataread) ? myrec.lastdataread : tools.getLastDateReadReset()
|
||||
|
||||
let mydate = ''
|
||||
if (!tools.isIsoDate(lastdata))
|
||||
@@ -127,6 +133,7 @@ export default defineComponent({
|
||||
lastdataread: getlastdataread(username)
|
||||
}).then((ris) => {
|
||||
|
||||
notifStore.updateNotification = false
|
||||
notifsel.value.dest = username
|
||||
loading.value = false
|
||||
|
||||
@@ -170,6 +177,7 @@ export default defineComponent({
|
||||
show_all,
|
||||
t,
|
||||
username,
|
||||
userStore,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -86,7 +86,31 @@
|
||||
</q-item-section>
|
||||
|
||||
<q-item-section v-ripple @click="clickNotif(notif)">
|
||||
<q-item-label lines="3" :class="(!notif.read) ? 'unread' : 'read'"><div v-html="getNotifText(notif, false)"></div></q-item-label>
|
||||
<q-item-label lines="3" :class="(!notif.read) ? 'unread' : 'read'">
|
||||
<div v-html="getNotifText($t, notif, false)"></div>
|
||||
</q-item-label>
|
||||
|
||||
<q-item-label caption lines="2" v-if="notif.typedir === shared_consts.TypeNotifs.TYPEDIR_FRIENDS && notif.status === 0">
|
||||
<div class="row no-wrap justify-evenly" v-if="userStore.IsReqFriendByUsername(notif.sender)">
|
||||
<q-btn
|
||||
dense
|
||||
rounded
|
||||
size="sm"
|
||||
icon="fas fa-user-plus"
|
||||
color="positive" :label="$t('friends.accept')"
|
||||
@click="tools.addToMyFriends($q, userStore.my.username, notif.sender)"
|
||||
/>
|
||||
<q-btn
|
||||
dense
|
||||
rounded
|
||||
size="sm"
|
||||
icon="fas fa-user-minus"
|
||||
color="negative" :label="$t('friends.refuse')"
|
||||
@click="tools.refuseReqFriends($q, userStore.my.username, notif.sender)"
|
||||
/>
|
||||
</div>
|
||||
</q-item-label>
|
||||
|
||||
<q-item-label caption lines="1" :class="(!notif.read) ? 'unread-date' : 'read-date'">
|
||||
{{ tools.timeAgo(notif.datenotif) }}
|
||||
<!--{{ // getUsernameChatByNotif(notif) }}-->
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useGlobalStore } from '@store/globalStore'
|
||||
import { useProducts } from '@store/Products'
|
||||
import { serv_constants } from '@store/Modules/serv_constants'
|
||||
import { tools } from '@store/Modules/tools'
|
||||
import { shared_consts } from '@src/common/shared_vuejs'
|
||||
|
||||
// You can declare a mixin as the same style as components.
|
||||
export default function () {
|
||||
@@ -156,9 +157,20 @@ export default function () {
|
||||
return ris
|
||||
}
|
||||
|
||||
function getNotifText(notif: INotif) {
|
||||
function getNotifText($t: any, notif: INotif) {
|
||||
|
||||
let descr = notif.descr
|
||||
|
||||
if (notif.typedir === shared_consts.TypeNotifs.TYPEDIR_FRIENDS) {
|
||||
if (notif.status === shared_consts.StatusNotifs.STATUS_FRIENDS_ACCEPTED) {
|
||||
descr += '\n' + $t('friends.accepted')
|
||||
} else if (notif.status === shared_consts.StatusNotifs.STATUS_FRIENDS_REFUSED) {
|
||||
descr += '\n' + $t('friends.refused')
|
||||
}
|
||||
}
|
||||
|
||||
return descr
|
||||
|
||||
return notif.descr
|
||||
}
|
||||
|
||||
function getNumNotif() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { shared_consts } from '@src/common/shared_vuejs'
|
||||
import { EState } from './Calendar'
|
||||
import { shared_consts } from '@src/common/shared_vuejs'
|
||||
|
||||
export interface IMessagePage {
|
||||
show: boolean
|
||||
@@ -117,4 +117,5 @@ export interface IMessageState {
|
||||
export interface INotifState {
|
||||
last_notifs: INotif[]
|
||||
show_all: boolean
|
||||
updateNotification: boolean
|
||||
}
|
||||
|
||||
@@ -885,6 +885,7 @@ const msg_enUs = {
|
||||
rejected: 'Rifiutati',
|
||||
},
|
||||
friends: {
|
||||
accepted: 'Amicizia Accettata',
|
||||
accept_trust: 'Accetta Fiducia',
|
||||
accept_friend: 'Accetta Amicizia',
|
||||
refuse_trust: 'Rifiuta Fiducia',
|
||||
|
||||
@@ -977,6 +977,10 @@ const msg_it = {
|
||||
},
|
||||
friends: {
|
||||
accept_trust: 'Accetta Fiducia',
|
||||
accepted: 'Amicizia Accettata',
|
||||
refused: 'Amicizia Rifiutata',
|
||||
accept: 'Accetta',
|
||||
refuse: 'Rifiuta',
|
||||
accept_friend: 'Accetta Amicizia',
|
||||
refuse_trust: 'Rifiuta Fiducia',
|
||||
reject_trust: 'Revoca Fiducia',
|
||||
@@ -985,7 +989,7 @@ const msg_it = {
|
||||
ask_friend: 'Chiedi l\'Amicizia',
|
||||
cancel_ask_friend: 'Annulla la richiesta di Amicizia',
|
||||
cancel_ask_friend_short: 'Annulla richiesta',
|
||||
reject_ask_friend: 'Rifiuta la richiesta di Amicizia',
|
||||
reject_ask_friend: 'Rifiuta l\'Amicizia',
|
||||
},
|
||||
groups: {
|
||||
member: 'membro',
|
||||
|
||||
@@ -40,6 +40,7 @@ import { useCalendarStore } from '@store/CalendarStore'
|
||||
import { Router } from 'vue-router'
|
||||
import { AxiosResponse, default as Axios } from 'axios'
|
||||
import { PayloadMessageTypes } from '@/common'
|
||||
import { useNotifStore } from '@store/NotifStore'
|
||||
|
||||
export interface INotify {
|
||||
color?: string | 'primary'
|
||||
@@ -4614,6 +4615,7 @@ export const tools = {
|
||||
addToMyFriends($q: any, username: string, usernameDest: string) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
const notifStore = useNotifStore()
|
||||
$q.dialog({
|
||||
message: t('db.domanda_addtofriend', { username: usernameDest }),
|
||||
ok: { label: t('dialog.yes'), push: true },
|
||||
@@ -4624,6 +4626,7 @@ export const tools = {
|
||||
userStore.setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.SETFRIEND, null)
|
||||
.then((res: any) => {
|
||||
if (res) {
|
||||
notifStore.updateNotification = true
|
||||
userStore.my.profile.friends = [...userStore.my.profile.friends, res]
|
||||
userStore.my.profile.req_friends = userStore.my.profile.req_friends.filter((rec: IFriends) => rec.username !== usernameDest)
|
||||
tools.showPositiveNotif($q, t('db.addedfriend'))
|
||||
@@ -4671,6 +4674,7 @@ export const tools = {
|
||||
refuseReqFriends($q: any, username: string, usernameDest: string) {
|
||||
|
||||
const userStore = useUserStore()
|
||||
const notifStore = useNotifStore()
|
||||
$q.dialog({
|
||||
message: t('db.domanda_revoke_friend', { username: usernameDest }),
|
||||
ok: { label: t('dialog.yes'), push: true },
|
||||
@@ -4680,6 +4684,7 @@ export const tools = {
|
||||
|
||||
userStore.setFriendsCmd($q, t, username, usernameDest, shared_consts.FRIENDSCMD.REMOVE_FROM_MYFRIENDS, null).then((res) => {
|
||||
if (res) {
|
||||
notifStore.updateNotification = true
|
||||
userStore.my.profile.req_friends = userStore.my.profile.req_friends.filter((user: IFriends) => user.username !== usernameDest)
|
||||
tools.showPositiveNotif($q, t('db.removedfriend'))
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ import { useUserStore } from '@store/UserStore'
|
||||
export const useNotifStore = defineStore('NotifStore', {
|
||||
state: (): INotifState => ({
|
||||
last_notifs: [],
|
||||
show_all: true
|
||||
show_all: true,
|
||||
updateNotification: false,
|
||||
}),
|
||||
|
||||
getters: {
|
||||
|
||||
@@ -71,12 +71,18 @@
|
||||
</div>
|
||||
|
||||
<div v-if="!isMyRecord(myuser.username)">
|
||||
<div class="row centeritems q-ma-sm q-pa-sm" v-if="userStore.IsReqFriendByUsername(myuser.username)">
|
||||
<q-btn
|
||||
v-if="userStore.IsReqFriendByUsername(myuser.username)"
|
||||
icon="fas fa-user-plus"
|
||||
color="primary" :label="$t('friends.accept_friend')"
|
||||
color="positive" :label="$t('friends.accept_friend')"
|
||||
@click="tools.addToMyFriends($q, userStore.my.username, myuser.username)"
|
||||
/>
|
||||
<q-btn
|
||||
icon="fas fa-user-minus"
|
||||
color="negative" :label="$t('friends.reject_ask_friend')"
|
||||
@click="tools.refuseReqFriends($q, userStore.my.username, myuser.username)"
|
||||
/>
|
||||
</div>
|
||||
<div v-else>
|
||||
<q-btn
|
||||
v-if="!userStore.IsMyFriendByUsername(myuser.username) && !userStore.IsAskedFriendByUsername(myuser.username)"
|
||||
|
||||
Reference in New Issue
Block a user