- 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

@@ -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'))