fix Saldo when press refuse coins.
fix Risolvere problema del ritardo quando si fa il primo login...
This commit is contained in:
@@ -26,7 +26,7 @@ axiosInstance.interceptors.response.use(
|
||||
// console.log('error', error)
|
||||
if (error.response) {
|
||||
if (process.env.DEBUGGING === '1') console.log('Status = ', error.response.status)
|
||||
console.log('Request Error: ', error.response)
|
||||
console.log('Request Error: ', error.response)
|
||||
if (error.response.status !== 0) {
|
||||
globalStore.setStateConnection('online')
|
||||
} else {
|
||||
@@ -149,11 +149,13 @@ async function Request(type: string, path: string, payload: any): Promise<Types.
|
||||
}
|
||||
|
||||
if (error.response) {
|
||||
let code = 0
|
||||
if (error.response.data && error.response.data.code) {
|
||||
code = error.response.data.code
|
||||
mycode = error.response.data.code
|
||||
userStore.setServerCode(mycode)
|
||||
}
|
||||
return Promise.reject(new Types.AxiosError(error.response.status, error.response.data, error.response.data.code))
|
||||
return Promise.reject(new Types.AxiosError(error.response.status, error.response.data, code))
|
||||
}
|
||||
return Promise.reject(new Types.AxiosError(0, null, mycode, error))
|
||||
}
|
||||
|
||||
@@ -3072,7 +3072,7 @@ export const tools = {
|
||||
},
|
||||
|
||||
SignIncheckErrors(mythisq: any, $router: Router, route: any, riscode: any, ispageLogin ?: boolean) {
|
||||
// console.log('SignIncheckErrors: ', riscode)
|
||||
console.log('SignIncheckErrors: ', riscode)
|
||||
const $q = useQuasar()
|
||||
|
||||
const globalStore = useGlobalStore()
|
||||
@@ -3435,11 +3435,13 @@ export const tools = {
|
||||
this.scrollToElement(element)
|
||||
},
|
||||
scrollToElement(el: any) {
|
||||
const target = getScrollTarget(el)
|
||||
const offset = el.offsetTop
|
||||
const duration = 500
|
||||
console.log('target', target, 'offset', offset, 'duration', duration)
|
||||
setScrollPosition(target, offset, duration)
|
||||
if (el) {
|
||||
const target = getScrollTarget(el)
|
||||
const offset = el.offsetTop
|
||||
const duration = 500
|
||||
console.log('target', target, 'offset', offset, 'duration', duration)
|
||||
setScrollPosition(target, offset, duration)
|
||||
}
|
||||
},
|
||||
|
||||
getCellForWhatsapp(numbercell: string) {
|
||||
@@ -4745,6 +4747,7 @@ export const tools = {
|
||||
// console.log('OUT', res)
|
||||
|
||||
if (res && res.user) {
|
||||
console.log('updateMyData')
|
||||
userStore.my = res.user
|
||||
|
||||
if (res.listcircuits) {
|
||||
@@ -6374,6 +6377,7 @@ export const tools = {
|
||||
roundDec2(mynum: number): number {
|
||||
return (Math.round(mynum * 100) / 100)
|
||||
},
|
||||
|
||||
// getLocale() {
|
||||
// if (navigator.languages && navigator.languages.length > 0) {
|
||||
// return navigator.languages[0]
|
||||
|
||||
@@ -20,7 +20,13 @@ export const useNotifStore = defineStore('NotifStore', {
|
||||
getters: {
|
||||
|
||||
getlasts_notifs: (mystate: INotifState) => (): INotif[] => {
|
||||
const ctrec = (mystate.last_notifs) ? mystate.last_notifs.slice(0, 20).filter((rec) => mystate.show_all ? true : !rec.read) : []
|
||||
const ctrec = (mystate.last_notifs) ? mystate.last_notifs.slice(0, 20).filter((rec) => (mystate.show_all ? true : !rec.read) && (rec.typedir !== shared_consts.TypeNotifs.TYPEDIR_CIRCUITS)) : []
|
||||
return (ctrec)
|
||||
|
||||
},
|
||||
|
||||
getlasts_coins: (mystate: INotifState) => (): INotif[] => {
|
||||
const ctrec = (mystate.last_notifs) ? mystate.last_notifs.slice(0, 20).filter((rec) => (mystate.show_all ? true : !rec.read) && (rec.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS)) : []
|
||||
return (ctrec)
|
||||
|
||||
},
|
||||
@@ -32,7 +38,12 @@ export const useNotifStore = defineStore('NotifStore', {
|
||||
},
|
||||
|
||||
getnumNotifUnread: (mystate: INotifState) => () => {
|
||||
const myarr = mystate.last_notifs.filter((notif) => !notif.read)
|
||||
const myarr = mystate.last_notifs.filter((notif) => !notif.read && (notif.typedir !== shared_consts.TypeNotifs.TYPEDIR_CIRCUITS))
|
||||
return (tools.isArray(myarr) ? myarr.length : 0)
|
||||
},
|
||||
|
||||
getnumCoinsUnread: (mystate: INotifState) => () => {
|
||||
const myarr = mystate.last_notifs.filter((notif) => !notif.read && (notif.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS))
|
||||
return (tools.isArray(myarr) ? myarr.length : 0)
|
||||
},
|
||||
|
||||
@@ -89,8 +100,8 @@ export const useNotifStore = defineStore('NotifStore', {
|
||||
}
|
||||
},
|
||||
|
||||
setAllRead(username: string) {
|
||||
return Api.SendReq(`/sendnotif/setall/${username}/${process.env.APP_ID}`, 'GET', null)
|
||||
setAllRead(username: string, qualinotif: number) {
|
||||
return Api.SendReq(`/sendnotif/setall/${username}/${qualinotif}/${process.env.APP_ID}`, 'GET', null)
|
||||
.then((res) => {
|
||||
// console.log('res', res)
|
||||
if (res) {
|
||||
@@ -124,12 +135,15 @@ export const useNotifStore = defineStore('NotifStore', {
|
||||
|
||||
},
|
||||
|
||||
deleteAll(username: string, id: string) {
|
||||
return Api.SendReq(`/sendnotif/delall/${username}/${process.env.APP_ID}`, 'GET', null)
|
||||
deleteAll(username: string, qualinotif: number) {
|
||||
return Api.SendReq(`/sendnotif/delall/${username}/${qualinotif}/${process.env.APP_ID}`, 'GET', null)
|
||||
.then((res) => {
|
||||
// console.log('res', res)
|
||||
if (res) {
|
||||
this.last_notifs = []
|
||||
if (qualinotif === shared_consts.QualiNotifs.CIRCUITS)
|
||||
this.last_notifs = this.last_notifs.filter((rec: INotif) => rec.typedir !== shared_consts.TypeNotifs.TYPEDIR_CIRCUITS)
|
||||
else if (qualinotif === shared_consts.QualiNotifs.OTHERS)
|
||||
this.last_notifs = this.last_notifs.filter((rec: INotif) => rec.typedir === shared_consts.TypeNotifs.TYPEDIR_CIRCUITS)
|
||||
this.updateArrNotif()
|
||||
}
|
||||
|
||||
@@ -146,7 +160,7 @@ export const useNotifStore = defineStore('NotifStore', {
|
||||
},
|
||||
|
||||
async updateNotifDataFromServer({ username, lastdataread }: {username: string, lastdataread: Date}) {
|
||||
// console.log('updateNotifDataFromServer', username, lastdataread)
|
||||
console.log('updateNotifDataFromServer', username, lastdataread)
|
||||
|
||||
return Api.SendReq(`/sendnotif/${username}/${lastdataread}/${process.env.APP_ID}`, 'GET', null)
|
||||
.then((res) => {
|
||||
@@ -157,6 +171,7 @@ export const useNotifStore = defineStore('NotifStore', {
|
||||
this.last_notifs = []
|
||||
}
|
||||
this.updateArrNotif()
|
||||
tools.updateMyData(res.data)
|
||||
return true
|
||||
})
|
||||
.catch((error) => {
|
||||
|
||||
@@ -310,14 +310,17 @@ export const useUserStore = defineStore('UserStore', {
|
||||
|
||||
IsMyCircuitByUser(user: IUserFields): any[] {
|
||||
|
||||
if (!this.my.profile.mycircuits || !user.profile.mycircuits)
|
||||
if (!this.my.profile.mycircuits || (!user || !user.profile || !user.profile.mycircuits))
|
||||
return []
|
||||
return tools.getCommon([...this.my.profile.mycircuits], [...user.profile.mycircuits], 'circuitname')
|
||||
},
|
||||
|
||||
|
||||
getAccountByCircuitId(circuitId: string): any {
|
||||
return this.my.profile.useraccounts.find((rec: IAccount) => rec.circuitId === circuitId)
|
||||
if (this.my.profile.useraccounts) {
|
||||
return this.my.profile.useraccounts.find((rec: IAccount) => rec.circuitId === circuitId)
|
||||
}
|
||||
return null
|
||||
},
|
||||
|
||||
IsRefusedCircuitByName(circuitname: string): boolean {
|
||||
@@ -360,7 +363,7 @@ export const useUserStore = defineStore('UserStore', {
|
||||
},
|
||||
|
||||
isOldRegNotFinished(): boolean {
|
||||
return (!this.my.profile.teleg_id || this.my.profile.teleg_id <= 0) || !this.isUsernameTelegOk()
|
||||
return tools.isLogged() && ((!this.my.profile.teleg_id || this.my.profile.teleg_id <= 0) || !this.isUsernameTelegOk())
|
||||
// return this.my.verified_email! && this.my.profile.teleg_id! > 0 && this.my.verified_by_aportador!
|
||||
},
|
||||
|
||||
@@ -762,30 +765,6 @@ export const useUserStore = defineStore('UserStore', {
|
||||
console.log('LOGIN signin')
|
||||
const globalStore = useGlobalStore()
|
||||
|
||||
// console.log('MYLANG = ' + this.lang)
|
||||
|
||||
let sub = null
|
||||
|
||||
try {
|
||||
if (static_data.functionality.PWA) {
|
||||
if ('serviceWorker' in navigator) {
|
||||
console.log('serviceWorker')
|
||||
sub = await navigator.serviceWorker.ready
|
||||
.then((swreg) => {
|
||||
console.log('swreg')
|
||||
sub = swreg.pushManager.getSubscription()
|
||||
return sub
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(' ERROR ')
|
||||
sub = null
|
||||
})
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Err navigator.serviceWorker.ready ... GetSubscription:', e)
|
||||
}
|
||||
|
||||
const options = {
|
||||
title: tools.translate('notification.title_subscribed', [{
|
||||
strin: 'sitename',
|
||||
@@ -795,13 +774,10 @@ export const useUserStore = defineStore('UserStore', {
|
||||
openUrl: '/',
|
||||
}
|
||||
|
||||
console.log('2')
|
||||
|
||||
const usertosend = {
|
||||
username: authData.username.trim(),
|
||||
password: authData.password.trim(),
|
||||
lang: this.lang,
|
||||
subs: sub,
|
||||
options,
|
||||
}
|
||||
|
||||
@@ -813,7 +789,9 @@ export const useUserStore = defineStore('UserStore', {
|
||||
|
||||
let myres: any
|
||||
|
||||
return Api.SendReq('/users/login', 'POST', usertosend, true)
|
||||
console.log('executing login...')
|
||||
|
||||
return await Api.SendReq('/users/login', 'POST', usertosend, true)
|
||||
.then((res) => {
|
||||
|
||||
myres = res
|
||||
|
||||
@@ -68,6 +68,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
leftDrawerOpen: false,
|
||||
rightDrawerOpen: false,
|
||||
rightNotifOpen: false,
|
||||
rightCoinsOpen: false,
|
||||
rightCartOpen: false,
|
||||
stateConnection: stateConnDefault,
|
||||
serverError: false,
|
||||
@@ -606,7 +607,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
return subscription
|
||||
} else {
|
||||
// Create a new subscription
|
||||
console.log('Create a new subscription')
|
||||
console.log('#### Create a new subscription !!!')
|
||||
const convertedVapidPublicKey = urlBase64ToUint8Array(mykey)
|
||||
return reg.pushManager.subscribe({
|
||||
userVisibleOnly: true,
|
||||
@@ -696,7 +697,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
for (const table of ApiTables.allTables()) {
|
||||
await globalroutines('clearalldata', table, null)
|
||||
}
|
||||
}catch (e) {
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
|
||||
@@ -704,20 +705,23 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
if ('serviceWorker' in navigator) {
|
||||
// REMOVE ALL SUBSCRIPTION
|
||||
console.log('REMOVE ALL SUBSCRIPTION...')
|
||||
await navigator.serviceWorker.ready.then((reg) => {
|
||||
console.log('... Ready')
|
||||
reg.pushManager.getSubscription().then((subscription) => {
|
||||
console.log(' Found Subscription...')
|
||||
if (subscription) {
|
||||
subscription.unsubscribe().then((successful) => {
|
||||
// You've successfully unsubscribed
|
||||
console.log('You\'ve successfully unsubscribed')
|
||||
}).catch((e) => {
|
||||
// Unsubscription failed
|
||||
})
|
||||
}
|
||||
navigator.serviceWorker.ready
|
||||
.then((reg) => {
|
||||
console.log('... Ready')
|
||||
reg.pushManager.getSubscription().then((subscription) => {
|
||||
console.log(' Found Subscription...')
|
||||
if (subscription) {
|
||||
subscription.unsubscribe().then((successful) => {
|
||||
// You've successfully unsubscribed
|
||||
console.log('You\'ve successfully unsubscribed')
|
||||
}).catch((e) => {
|
||||
// Unsubscription failed
|
||||
})
|
||||
}
|
||||
})
|
||||
}).catch((err) => {
|
||||
console.error('err ready service worker', err)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -818,7 +822,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
.then((res) => {
|
||||
this.serverError = false
|
||||
// if (tools.isDebug())
|
||||
// console.table(res)
|
||||
// console.table(res)
|
||||
return res.data
|
||||
})
|
||||
.catch((error) => {
|
||||
@@ -968,7 +972,14 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
},
|
||||
|
||||
isErroreDispositivoServer() {
|
||||
return this.serverMsgError.code === -2
|
||||
if (this.serverMsgError) {
|
||||
if (this.serverMsgError.code)
|
||||
return this.serverMsgError.code === -2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
|
||||
return false
|
||||
},
|
||||
|
||||
async saveSubRec(mydata: any) {
|
||||
@@ -1645,7 +1656,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
|
||||
if (table === toolsext.TABMYGOODS) {
|
||||
obj['idSectorGood'] = []
|
||||
} else if ((table === toolsext.TABMYSKILLS) ) {
|
||||
} else if ((table === toolsext.TABMYSKILLS)) {
|
||||
obj['idSector'] = []
|
||||
}
|
||||
|
||||
@@ -1684,10 +1695,10 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
getServerHost() {
|
||||
|
||||
let myserv = ''
|
||||
myserv = window.location.host
|
||||
// myserv = window.location.host
|
||||
|
||||
if (process.env.DEBUGGING) {
|
||||
myserv = 'http://localhost:3000'; // 'http://192.168.1.54:3000'
|
||||
myserv = process.env.MONGODB_HOST! // 'http://192.168.1.54:3000'
|
||||
} else {
|
||||
myserv = process.env.MONGODB_HOST!
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user