Skip to content

Commit ac57381

Browse files
committed
course: part of #4495 -- students should get immediately added to shared project
1 parent f139621 commit ac57381

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

src/packages/frontend/course/shared-project/actions.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { redux } from "@cocalc/frontend/app-framework";
1111
import { Datastore, EnvVars } from "@cocalc/frontend/projects/actions";
1212
import { CourseActions } from "../actions";
1313
import { CourseStore } from "../store";
14+
import { delay } from "awaiting";
1415

1516
export class SharedProjectActions {
1617
private actions: CourseActions;
@@ -234,6 +235,9 @@ export class SharedProjectActions {
234235
this.actions.set_activity({ id });
235236
}
236237
this.set_project_id(project_id);
238+
// wait for any changes to syncdb to update store, before
239+
// calling configure (which relies on the store being updated).
240+
await delay(10);
237241
await this.configure();
238242
};
239243

src/packages/frontend/course/shared-project/delete-shared-project.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { Popconfirm, Button, Card } from "antd";
77
import { Icon } from "@cocalc/frontend/components";
88

9-
export function DeleteSharedProjectPanel({ actions, settings }) {
9+
export function DeleteSharedProjectPanel({ actions, settings, close }) {
1010
if (!settings.get("shared_project_id")) {
1111
return <Card title={"No Shared Project"}></Card>;
1212
}
@@ -17,7 +17,10 @@ export function DeleteSharedProjectPanel({ actions, settings }) {
1717
title="Are you sure you want to delete the shared project?"
1818
okText="Yes"
1919
cancelText="No"
20-
onConfirm={() => actions.shared_project.delete()}
20+
onConfirm={() => {
21+
actions.shared_project.delete();
22+
close?.();
23+
}}
2124
>
2225
<Button danger>
2326
<Icon name="trash" /> Delete Shared Project...

src/packages/frontend/course/shared-project/shared-project-panel.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ interface SharedProjectPanelProps {
1616
settings: CourseSettingsRecord;
1717
redux: AppRedux;
1818
name: string;
19+
close?: Function;
1920
}
2021

2122
export function SharedProjectPanel({
2223
settings,
2324
redux,
2425
name,
26+
close,
2527
}: SharedProjectPanelProps) {
2628
const actions = useActions<CourseActions>({ name });
2729

@@ -67,7 +69,11 @@ export function SharedProjectPanel({
6769
</Button>
6870
</div>
6971
<hr />
70-
<DeleteSharedProjectPanel settings={settings} actions={actions} />
72+
<DeleteSharedProjectPanel
73+
settings={settings}
74+
actions={actions}
75+
close={close}
76+
/>
7177
</div>
7278
);
7379
}
@@ -76,6 +82,7 @@ export function SharedProjectPanel({
7682
redux.getActions("projects").open_project({
7783
project_id: settings.get("shared_project_id"),
7884
});
85+
close?.();
7986
}
8087

8188
function render_no_shared_project() {
@@ -113,7 +120,10 @@ export function SharedProjectPanel({
113120
}
114121
onConfirm={() => {
115122
const actions = redux.getActions(name) as CourseActions;
116-
if (actions != null) actions.shared_project.create();
123+
if (actions != null) {
124+
actions.shared_project.create();
125+
close?.();
126+
}
117127
}}
118128
okText="Create Shared Project"
119129
cancelText={<CancelText />}

0 commit comments

Comments
 (0)