mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Unblock subsequent Singleton.createInstance() (#3225)
- Also fix clusters with unknown workspaces Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
c4623c424d
commit
803c3a3d34
@ -46,12 +46,15 @@ export class Singleton {
|
|||||||
static createInstance<T, R extends any[]>(this: StaticThis<T, R>, ...args: R): T {
|
static createInstance<T, R extends any[]>(this: StaticThis<T, R>, ...args: R): T {
|
||||||
if (!Singleton.instances.has(this)) {
|
if (!Singleton.instances.has(this)) {
|
||||||
if (Singleton.creating.length > 0) {
|
if (Singleton.creating.length > 0) {
|
||||||
throw new TypeError("Cannot create a second singleton while creating a first");
|
throw new TypeError(`Cannot create a second singleton (${this.name}) while creating a first (${Singleton.creating})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
Singleton.creating = this.name;
|
try {
|
||||||
Singleton.instances.set(this, new this(...args));
|
Singleton.creating = this.name;
|
||||||
Singleton.creating = "";
|
Singleton.instances.set(this, new this(...args));
|
||||||
|
} finally {
|
||||||
|
Singleton.creating = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Singleton.instances.get(this) as T;
|
return Singleton.instances.get(this) as T;
|
||||||
|
|||||||
@ -44,8 +44,10 @@ export function joinMigrations(...declarations: MigrationDeclaration[]): Migrati
|
|||||||
|
|
||||||
return Object.fromEntries(
|
return Object.fromEntries(
|
||||||
iter.map(
|
iter.map(
|
||||||
migrations,
|
migrations,
|
||||||
([v, fns]) => [v, (store: Conf<any>) => {
|
([v, fns]) => [v, (store: Conf<any>) => {
|
||||||
|
migrationLog(`Running ${v} migration for ${store.path}`);
|
||||||
|
|
||||||
for (const fn of fns) {
|
for (const fn of fns) {
|
||||||
fn(store);
|
fn(store);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,6 +75,11 @@ export default {
|
|||||||
for (const workspaceId of cluster.workspaces ?? [cluster.workspace].filter(Boolean)) {
|
for (const workspaceId of cluster.workspaces ?? [cluster.workspace].filter(Boolean)) {
|
||||||
const workspaceHotbar = workspaceHotbars.get(workspaceId);
|
const workspaceHotbar = workspaceHotbars.get(workspaceId);
|
||||||
|
|
||||||
|
if (!workspaceHotbar) {
|
||||||
|
migrationLog(`Cluster ${uid} has unknown workspace ID, skipping`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
migrationLog(`Adding cluster ${uid} to ${workspaceHotbar.name}`);
|
migrationLog(`Adding cluster ${uid} to ${workspaceHotbar.name}`);
|
||||||
|
|
||||||
if (workspaceHotbar?.items.length < defaultHotbarCells) {
|
if (workspaceHotbar?.items.length < defaultHotbarCells) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user