This commit is contained in:
Peter Maquiran
2023-01-04 11:27:40 +01:00
parent f70391df4a
commit 3709de00ed
2 changed files with 24 additions and 15 deletions
+18 -9
View File
@@ -8,6 +8,9 @@ import { Storage } from '@ionic/storage';
import { PermissionService } from './permission.service';
import { SessionStore } from '../store/session.service';
import { ChangeProfileService } from 'src/app/services/change-profile.service';
import { NetworkServiceService , ConnectionStatus} from 'src/app/services/network-service.service';
import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service';
@Injectable({
providedIn: 'root'
})
@@ -26,7 +29,9 @@ export class ChatService {
private storage: Storage,
private storageService: StorageService,
public p: PermissionService,
private changeProfileService: ChangeProfileService,) {
private changeProfileService: ChangeProfileService,
private NetworkServiceService: NetworkServiceService,
private RochetChatConnectorService: RochetChatConnectorService) {
this.changeProfileService.registerCallback(() => {
this.setheader();
@@ -388,11 +393,19 @@ export class ChatService {
this.timerEventTriggerDateLastUpdate = new Date();
} catch (error) {
this.resetTimer();
setTimeout(async() =>{
if(this.NetworkServiceService.getCurrentNetworkStatus() == ConnectionStatus.Offline) {
this.RochetChatConnectorService.registerCallback({
type: 'reConnect',
funx: async ()=> {
this.resetTimer();
await this.refreshtoken();
}
})
} else {
this.resetTimer();
await this.refreshtoken();
}, 8000)
}
}
@@ -402,10 +415,6 @@ export class ChatService {
} else if (!this.headers) {
this.setheader()
this.refreshtoken()
} else {
setTimeout(async ()=>{
await this.refreshtoken();
}, 8000)
}
}