[go: nahoru, domu]

Skip to content

Commit

Permalink
fix async effect (#7383)
Browse files Browse the repository at this point in the history
  • Loading branch information
hlshen committed Jun 25, 2024
1 parent edb2b47 commit 1f579c8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions firebase-vscode/src/core/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { listProjects } from "../cli";
import { pluginLogger } from "../logger-wrapper";
import { globalSignal } from "../utils/globals";
import { firstWhereDefined } from "../utils/signal";
import { User } from "../types/auth";

/** Available projects */
export const projects = globalSignal<Record<string, FirebaseProjectMetadata[]>>(
Expand Down Expand Up @@ -43,15 +44,20 @@ export const currentProject = computed<FirebaseProjectMetadata | undefined>(
);

export function registerProject(broker: ExtensionBrokerImpl): Disposable {
const sub1 = effect(async () => {
const user = currentUser.value;
if (user) {
pluginLogger.info("(Core:Project) New user detected, fetching projects");

async function fetchNewProjects(user: User) {
const userProjects = await listProjects();
projects.value = {
...projects.value,
[user.email]: userProjects,
};
}

const sub1 = effect(() => {
const user = currentUser.value;
if (user) {
pluginLogger.info("(Core:Project) New user detected, fetching projects");
fetchNewProjects(user);
}
});

Expand Down

0 comments on commit 1f579c8

Please sign in to comment.