Send git-commit hash to client on reconnect to force client reload on backend update

This commit is contained in:
softsimon
2020-03-01 00:42:41 +07:00
parent 943d96ee8c
commit c9b161423d
2 changed files with 27 additions and 1 deletions

View File

@@ -17,6 +17,7 @@ export class WebsocketService {
private lastWant: string[] | null = null;
private trackingTxId: string | null = null;
private trackingAddress: string | null = null;
private latestGitCommit = '';
constructor(
private stateService: StateService,
@@ -58,6 +59,18 @@ export class WebsocketService {
this.stateService.mempoolBlocks$.next(response['mempool-blocks']);
}
if (response['git-commit']) {
if (!this.latestGitCommit) {
this.latestGitCommit = response['git-commit'];
} else {
if (this.latestGitCommit !== response['git-commit']) {
setTimeout(() => {
window.location.reload();
}, Math.floor(Math.random() * 60000) + 1000);
}
}
}
if (response['address-transactions']) {
response['address-transactions'].forEach((addressTransaction: Transaction) => {
this.stateService.mempoolTransactions$.next(addressTransaction);