Skip to content

Commit 807fd65

Browse files
authored
Fix live project WebSocket dashboard updates (#140)
Maintainer merge: verified the frontend WebSocket visibility/stat update diff against current master. Local merged preview with #138/#143 passed frontend tests and build; no security issue found in #140. Claimant/payout dispute remains separate from accepting this safe code change.
1 parent c9f9154 commit 807fd65

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

frontend/src/App.vue

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4879,11 +4879,15 @@ function handleWSEvent(payload = {}) {
48794879
_wsSeenProjectIDs.add(project.id);
48804880
48814881
if (user.value) {
4882-
const exists = dashboardProjects.value.some((p) => p.id === project.id);
4883-
if (!exists) {
4884-
dashboardProjects.value = [project, ...dashboardProjects.value];
4885-
if (!selectedDashboardProjectID.value) {
4886-
selectedDashboardProjectID.value = project.id;
4882+
const isAdmin = user.value.role === 'admin';
4883+
const isOwner = user.value.id === project.client_user_id;
4884+
if (isAdmin || isOwner) {
4885+
const exists = dashboardProjects.value.some((p) => p.id === project.id);
4886+
if (!exists) {
4887+
dashboardProjects.value = [project, ...dashboardProjects.value];
4888+
if (!selectedDashboardProjectID.value) {
4889+
selectedDashboardProjectID.value = project.id;
4890+
}
48874891
}
48884892
}
48894893
}
@@ -4894,6 +4898,11 @@ function handleWSEvent(payload = {}) {
48944898
marketplaceData.value = {
48954899
...marketplaceData.value,
48964900
projects: [project, ...marketplaceData.value.projects],
4901+
stats: {
4902+
...marketplaceData.value.stats,
4903+
project_count: (Number(marketplaceData.value.stats?.project_count) || marketplaceData.value.projects.length) + 1,
4904+
total_budget_cents: (Number(marketplaceData.value.stats?.total_budget_cents) || 0) + (Number(project.budget_cents) || 0),
4905+
},
48974906
};
48984907
}
48994908
}

0 commit comments

Comments
 (0)