mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
improve chat token timer
This commit is contained in:
@@ -354,7 +354,7 @@ export class ChatService {
|
||||
headers: this.headers,
|
||||
};
|
||||
|
||||
this.resetTimer()
|
||||
this.resetTimer();
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -370,18 +370,26 @@ export class ChatService {
|
||||
headers: this.headers
|
||||
};
|
||||
|
||||
let res = await this.http.get(environment.apiURL + 'UserAuthentication/RegenereChatToken', options).toPromise();
|
||||
|
||||
let data = {
|
||||
status: res['status'],
|
||||
data: {
|
||||
userId: res['data'].userId,
|
||||
authToken: res['data'].authToken
|
||||
try {
|
||||
let res = await this.http.get(environment.apiURL + 'UserAuthentication/RegenereChatToken', options).toPromise();
|
||||
|
||||
let data = {
|
||||
status: res['status'],
|
||||
data: {
|
||||
userId: res['data'].userId,
|
||||
authToken: res['data'].authToken
|
||||
}
|
||||
}
|
||||
SessionStore.user.ChatData = data
|
||||
SessionStore.save()
|
||||
this.setheader()
|
||||
this.timerEventTriggerDateLastUpdate = new Date();
|
||||
} catch (error) {
|
||||
|
||||
this.resetTimer();
|
||||
|
||||
}
|
||||
SessionStore.user.ChatData = data
|
||||
SessionStore.save()
|
||||
this.setheader()
|
||||
|
||||
|
||||
} else {
|
||||
this.setheader()
|
||||
@@ -391,10 +399,15 @@ export class ChatService {
|
||||
|
||||
|
||||
functionTimer = null;
|
||||
timerEventTriggerDate = null
|
||||
timerEventTriggerDateLastUpdate = null
|
||||
|
||||
resetTimer() {
|
||||
clearTimeout(this.functionTimer);
|
||||
this.functionTimer = setTimeout(()=>{
|
||||
this.timerEventTriggerDate = new Date(+new Date() + 60000*15);
|
||||
|
||||
this.functionTimer = setTimeout(() => {
|
||||
this.timerEventTriggerDateLastUpdate = new Date();
|
||||
this.refreshtoken();
|
||||
}, 60000 * 5); // time is in milliseconds
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user