1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-06-09 01:17:06 +02:00

fix: always set instanceid in uiconfig

This commit is contained in:
Christopher Kolstad 2021-03-15 08:46:03 +01:00
parent 1152272ed6
commit 3e2ec968f2

View File

@ -12,31 +12,41 @@ class VersionService {
oss: version, oss: version,
enterprise: enterpriseVersion, enterprise: enterpriseVersion,
}; };
if (versionCheck) { this.setInstanceId();
if (versionCheck.url) { if (versionCheck && versionCheck.url) {
this.versionCheckUrl = versionCheck.url; this.versionCheckUrl = versionCheck.url;
}
if (versionCheck.enable === 'true') { if (versionCheck.enable === 'true') {
this.enabled = true; this.enabled = true;
this.checkLatestVersion(); this.checkLatestVersion(this.instanceId);
setInterval(this.checkLatestVersion, TWO_DAYS); setInterval(
() => this.checkLatestVersion(this.instanceId),
TWO_DAYS,
);
} else { } else {
this.enabled = false; this.enabled = false;
} }
} }
} }
async checkLatestVersion() { async setInstanceId() {
if (this.enabled) { try {
const { id } = await this.settingStore.get('instanceInfo'); const { id } = await this.settingStore.get('instanceInfo');
this.instanceId = id; this.instanceId = id;
return id;
} catch (err) {
this.logger.warn('Could not find instanceInfo');
return undefined;
}
}
async checkLatestVersion(instanceId) {
if (this.enabled) {
try { try {
const data = await fetch(this.versionCheckUrl, { const data = await fetch(this.versionCheckUrl, {
method: 'POST', method: 'POST',
body: JSON.stringify({ body: JSON.stringify({
versions: this.current, versions: this.current,
id, instanceId,
}), }),
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
}).then(res => res.json()); }).then(res => res.json());