- Refused User

- Report User
- Unblock User
- refresh tables when an action (setFriends and setGroups) occurred.
- fix duplicate call of loadsite
This commit is contained in:
paoloar77
2022-08-08 16:34:30 +02:00
parent ce20daed6d
commit 4cde86c113
15 changed files with 155 additions and 14 deletions

View File

@@ -4672,6 +4672,22 @@ export const tools = {
})
},
unblockUser($q: any, username: string, usernameDest: string) {
const userStore = useUserStore()
$q.dialog({
message: t('db.domanda_unblockuser', { 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.UNBLOCK_USER, null).then((res: any) => {
if (res) {
tools.showPositiveNotif($q, t('db.unblockedfriend'))
}
})
})
},
reportUser($q: any, username: string, usernameDest: string) { // Segnala Profilo
const userStore = useUserStore()
$q.dialog({
@@ -4740,7 +4756,7 @@ export const tools = {
const userStore = useUserStore()
const notifStore = useNotifStore()
$q.dialog({
message: t('db.domanda_revoke_group', { groupname: groupnameDest }),
message: t('db.domanda_refuse_group', { username, groupname: groupnameDest }),
ok: { label: t('dialog.yes'), push: true },
cancel: { label: t('dialog.cancel') },
title: t('db.domanda')
@@ -4750,7 +4766,7 @@ export const tools = {
if (res) {
notifStore.updateNotification = true
userStore.my.profile.asked_groups = userStore.my.profile.asked_groups.filter((rec: IMyGroup) => rec.groupname !== groupnameDest)
tools.showPositiveNotif($q, t('db.refusedgroup'))
tools.showPositiveNotif($q, t('db.refusedgroup', { username }))
}
})
})
@@ -5526,6 +5542,7 @@ export const tools = {
userStore.my.profile.list_usersgroup = ris.listUsersGroup ? ris.listUsersGroup : []
userStore.groups = ris.listgroups ? ris.listgroups : []
userStore.my.profile.asked_groups = ris.listSentRequestGroups ? ris.listSentRequestGroups : []
userStore.my.profile.refused_groups = ris.listRefusedGroups ? ris.listRefusedGroups : []
return [{ userId: userStore.my._id }]
}
})

View File

@@ -60,9 +60,14 @@ export const useNotifStore = defineStore('NotifStore', {
// just to give more context for this demo.
const countNow = this.getnumNotifUnread()
// @ts-ignore
await navigator.setAppBadge(countNow)
.catch((error: any) => { /* ... */ });
try {
// @ts-ignore
await navigator.setAppBadge(countNow)
.catch((error: any) => { /* ... */
});
}catch (e) {
}
},
setAllRead(username: string) {

View File

@@ -56,6 +56,7 @@ export const DefaultUser: IUserFields = {
manage_mygroups: [],
asked_friends: [],
asked_groups: [],
refused_groups: [],
notifs: [],
notif_idCities: [],
notif_provinces: [],
@@ -107,6 +108,7 @@ export const DefaultProfile: IUserProfile = {
manage_mygroups: [],
asked_friends: [],
asked_groups: [],
refused_groups: [],
notifs: [],
notif_idCities: [],
notif_provinces: [],
@@ -137,6 +139,7 @@ export const useUserStore = defineStore('UserStore', {
usersList: [],
countusers: 0,
lastparamquery: {},
updateTables: false,
}),
getters: {
@@ -220,6 +223,13 @@ export const useUserStore = defineStore('UserStore', {
return false
},
IsRefusedGroupByGroupname(groupname: string): boolean {
if (this.my.profile.refused_groups)
return this.my.profile.refused_groups.findIndex((rec: IMyGroup) => rec.groupname === groupname) >= 0
else
return false
},
getUserByUsername(username: string): IUserFields | null {
// Check if is this User!
if (this.my.username === username) return this.my
@@ -538,6 +548,7 @@ export const useUserStore = defineStore('UserStore', {
this.my.profile.manage_mygroups = []
this.my.profile.asked_friends = []
this.my.profile.asked_groups = []
this.my.profile.refused_groups = []
}
this.isAdmin = tools.isBitActive(this.my.perm, shared_consts.Permissions.Admin.value)
@@ -765,7 +776,7 @@ export const useUserStore = defineStore('UserStore', {
this.updateLocalStorage(myuser)
globalStore.loadSite()
// globalStore.loadSite()
}
}
@@ -1108,6 +1119,7 @@ export const useUserStore = defineStore('UserStore', {
async setFriendsCmd($q: any, t: any, usernameOrig: string, usernameDest: string, cmd: number, value: any) {
return Api.SendReq('/users/friends/cmd', 'POST', { usernameOrig, usernameDest, cmd, value })
.then((res) => {
this.updateTables = true
return res.data
}).catch((error) => {
tools.showNegativeNotif($q, t('db.recfailed'))
@@ -1119,6 +1131,7 @@ export const useUserStore = defineStore('UserStore', {
async setGroupsCmd($q: any, t: any, usernameOrig: string, groupnameDest: string, cmd: number, value: any) {
return Api.SendReq('/users/groups/cmd', 'POST', { usernameOrig, groupnameDest, cmd, value })
.then((res) => {
this.updateTables = true
return res.data
}).catch((error) => {
tools.showNegativeNotif($q, t('db.recfailed'))

View File

@@ -724,7 +724,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
},
async loadAfterLogin() {
// console.log('loadAfterLogin')
console.log('loadAfterLogin')
this.clearDataAfterLoginOnlyIfActiveConnection()
let isok = false