fix: multiple bug fixes
isolated users, db backup, weird disconnect issues for long voice sessions,
This commit is contained in:
@@ -145,6 +145,7 @@ export class ServerEndpointStateService {
|
||||
|
||||
if (target.isDefault) {
|
||||
this.markDefaultEndpointRemoved(target);
|
||||
this.clearDefaultEndpointDisabled(target);
|
||||
}
|
||||
|
||||
const updatedEndpoints = ensureAnyActiveEndpoint(
|
||||
@@ -171,6 +172,7 @@ export class ServerEndpointStateService {
|
||||
|
||||
this._servers.update((endpoints) => ensureAnyActiveEndpoint([...endpoints, ...restoredEndpoints]));
|
||||
this.storage.clearRemovedDefaultEndpointKeys();
|
||||
this.clearDisabledDefaultEndpointKeys(restoredEndpoints);
|
||||
this.saveEndpoints();
|
||||
return restoredEndpoints;
|
||||
}
|
||||
@@ -190,6 +192,12 @@ export class ServerEndpointStateService {
|
||||
);
|
||||
});
|
||||
|
||||
const target = this._servers().find((endpoint) => endpoint.id === endpointId);
|
||||
|
||||
if (target?.isDefault) {
|
||||
this.clearDefaultEndpointDisabled(target);
|
||||
}
|
||||
|
||||
this.saveEndpoints();
|
||||
}
|
||||
|
||||
@@ -206,6 +214,12 @@ export class ServerEndpointStateService {
|
||||
)
|
||||
);
|
||||
|
||||
const target = this._servers().find((endpoint) => endpoint.id === endpointId);
|
||||
|
||||
if (target?.isDefault) {
|
||||
this.markDefaultEndpointDisabled(target);
|
||||
}
|
||||
|
||||
this.saveEndpoints();
|
||||
}
|
||||
|
||||
@@ -225,7 +239,7 @@ export class ServerEndpointStateService {
|
||||
instanceId: versions?.serverInstanceId ?? endpoint.instanceId,
|
||||
status,
|
||||
latency,
|
||||
isActive: status === 'incompatible' ? false : endpoint.isActive,
|
||||
isActive: status === 'incompatible' && !endpoint.isDefault ? false : endpoint.isActive,
|
||||
serverVersion: versions?.serverVersion ?? endpoint.serverVersion,
|
||||
clientVersion: versions?.clientVersion ?? endpoint.clientVersion
|
||||
};
|
||||
@@ -258,6 +272,7 @@ export class ServerEndpointStateService {
|
||||
private reconcileStoredEndpoints(storedEndpoints: ServerEndpoint[]): ServerEndpoint[] {
|
||||
const reconciled: ServerEndpoint[] = [];
|
||||
const claimedDefaultKeys = new Set<string>();
|
||||
const disabledDefaultKeys = this.storage.loadDisabledDefaultEndpointKeys();
|
||||
const removedDefaultKeys = this.storage.loadRemovedDefaultEndpointKeys();
|
||||
|
||||
for (const endpoint of storedEndpoints) {
|
||||
@@ -279,6 +294,7 @@ export class ServerEndpointStateService {
|
||||
...endpoint,
|
||||
name: matchedDefault.name,
|
||||
url: matchedDefault.url,
|
||||
isActive: this.isDefaultEndpointActive(matchedDefault.defaultKey, disabledDefaultKeys),
|
||||
isDefault: true,
|
||||
defaultKey: matchedDefault.defaultKey,
|
||||
status: endpoint.status ?? 'unknown'
|
||||
@@ -303,7 +319,7 @@ export class ServerEndpointStateService {
|
||||
reconciled.push({
|
||||
...defaultEndpoint,
|
||||
id: uuidv4(),
|
||||
isActive: defaultEndpoint.isActive
|
||||
isActive: this.isDefaultEndpointActive(defaultEndpoint.defaultKey, disabledDefaultKeys)
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -324,6 +340,64 @@ export class ServerEndpointStateService {
|
||||
this.storage.saveRemovedDefaultEndpointKeys(removedDefaultKeys);
|
||||
}
|
||||
|
||||
private markDefaultEndpointDisabled(endpoint: ServerEndpoint): void {
|
||||
const defaultKey = endpoint.defaultKey ?? findDefaultEndpointKeyByUrl(this.defaultEndpoints, endpoint.url);
|
||||
|
||||
if (!defaultKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
const disabledDefaultKeys = this.storage.loadDisabledDefaultEndpointKeys();
|
||||
|
||||
disabledDefaultKeys.add(defaultKey);
|
||||
this.storage.saveDisabledDefaultEndpointKeys(disabledDefaultKeys);
|
||||
}
|
||||
|
||||
private clearDefaultEndpointDisabled(endpoint: ServerEndpoint): void {
|
||||
const defaultKey = endpoint.defaultKey ?? findDefaultEndpointKeyByUrl(this.defaultEndpoints, endpoint.url);
|
||||
|
||||
if (!defaultKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
const disabledDefaultKeys = this.storage.loadDisabledDefaultEndpointKeys();
|
||||
|
||||
if (!disabledDefaultKeys.delete(defaultKey)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.storage.saveDisabledDefaultEndpointKeys(disabledDefaultKeys);
|
||||
}
|
||||
|
||||
private clearDisabledDefaultEndpointKeys(endpoints: ServerEndpoint[]): void {
|
||||
const disabledDefaultKeys = this.storage.loadDisabledDefaultEndpointKeys();
|
||||
|
||||
let didChange = false;
|
||||
|
||||
for (const endpoint of endpoints) {
|
||||
const defaultKey = endpoint.defaultKey ?? findDefaultEndpointKeyByUrl(this.defaultEndpoints, endpoint.url);
|
||||
|
||||
if (!defaultKey) {
|
||||
continue;
|
||||
}
|
||||
|
||||
didChange = disabledDefaultKeys.delete(defaultKey) || didChange;
|
||||
}
|
||||
|
||||
if (!didChange) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.storage.saveDisabledDefaultEndpointKeys(disabledDefaultKeys);
|
||||
}
|
||||
|
||||
private isDefaultEndpointActive(
|
||||
defaultKey: string,
|
||||
disabledDefaultKeys: Set<string>
|
||||
): boolean {
|
||||
return !disabledDefaultKeys.has(defaultKey);
|
||||
}
|
||||
|
||||
private saveEndpoints(): void {
|
||||
this.storage.saveEndpoints(this._servers());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user