aggiunto "Seen"

This commit is contained in:
Surya Paolo
2023-04-13 14:27:06 +02:00
parent 35db79b479
commit 6f1f962c0a
10 changed files with 107 additions and 2 deletions

View File

@@ -35,7 +35,7 @@ import { Router } from 'vue-router'
import { useProjectStore } from '@store/Projects'
import { shared_consts } from '@/common/shared_vuejs'
import { costanti } from '@costanti'
import { IBookmark, IFavBook, IFavorite, IGroupShort, IMyGroup, IUserAdmins } from '@model/UserStore'
import { IBookmark, ISeen, IFavBook, IFavorite, IGroupShort, IMyGroup, IUserAdmins } from '@model/UserStore'
import globalroutines from '../globalroutines/index'
import { useNotifStore } from '@store/NotifStore'
@@ -44,6 +44,7 @@ import { useCircuitStore } from './CircuitStore'
export const CMD_USER = {
SET_FAVORITE: 1,
SET_BOOKMARK: 2,
SET_SEEN: 3,
}
export const DefaultUser: IUserFields = {
@@ -83,8 +84,10 @@ export const DefaultUser: IUserFields = {
notifs: [],
bookmark: [],
favorite: [],
seen: [],
myfav: [],
mybook: [],
myseen: [],
notif_idCities: [],
notif_provinces: [],
notif_regions: [],
@@ -152,8 +155,10 @@ export const DefaultProfile: IUserProfile = {
notifs: [],
bookmark: [],
favorite: [],
seen: [],
myfav: [],
mybook: [],
myseen: [],
notif_idCities: [],
notif_provinces: [],
notif_regions: [],
@@ -1676,6 +1681,12 @@ export const useUserStore = defineStore('UserStore', {
},
isSeen(id: string, table: string) {
const tab = tools.getNumTabByTable(table)
const myseen = this.my.profile.seen.find((rec: ISeen) => ((rec.id === id) && (rec.tab === tab)))
return myseen
},
isBookmarked(id: string, table: string) {
const tab = tools.getNumTabByTable(table)
const mybookmark = this.my.profile.bookmark.find((rec: IBookmark) => ((rec.id === id) && (rec.tab === tab)))
@@ -1718,5 +1729,28 @@ export const useUserStore = defineStore('UserStore', {
},
async setSeen($q: any, t: any, id: any, table: string, myrec: any) {
let value = false
const tab = tools.getNumTabByTable(table)
value = this.isSeen(id, table) ? false : true
return await Api.SendReq('/users/cmd', 'POST', { cmd: CMD_USER.SET_SEEN, id, tab, value })
.then((res) => {
if (res && res.data.state === 1) {
if (!myrec.myseen)
myrec.myseen = []
this.my.profile.seen.push({ id, tab })
if (myrec)
myrec.myseen.push({ username: this.my.username })
}
}).catch((error) => {
console.error('error', error)
return {}
})
},
},
})