Commit e3e8eba
authored
Mimic autosave in Scratch Editor (#1469)
This change adds autosave for Scratch projects and keeps the behaviour
close to the existing Python and HTML editors.
Python and HTML already autosave after a short delay when the user owns
a saved project. Scratch is different because project changes happen
inside the Scratch iframe, so we listen to Scratch VM change events and
pass those changes back to the main app.
Autosave only starts once the Scratch project has been saved or remixed
and has an identifier. New Scratch projects, and projects that need to
be remixed first, still show the manual Save button. After that first
save/remix, the manual Save button is hidden and the header shows the
autosave status instead.
The autosave delay is 2 seconds. If a save is already running, we do not
start another one immediately; we queue the next autosave until the
current save finishes.
Scratch save events now update the shared Redux editor save state:
saving, lastSavedTime, and lastSaveAutosave. This is the same state used
by the existing save status UI, so Scratch can reuse SaveStatus instead
of keeping a separate local save-status flow in the Scratch hook.
The Scratch save/remix tests have also been updated to cover the new
flow: first save/remix, identifier update, hiding the manual Save
button, and triggering autosave once the project is eligible.
As Teacher:
https://github.com/user-attachments/assets/ee9010bc-0ae8-4cb7-953e-eeaea70253ec
As Student (first time):
https://github.com/user-attachments/assets/60bb464b-6bb6-4fc9-9131-d9c84994496d1 parent 44ade45 commit e3e8eba
10 files changed
Lines changed: 710 additions & 197 deletions
File tree
- cypress/e2e
- src
- components
- ProjectBar
- ScratchEditor
- hooks
- redux
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
134 | 142 | | |
135 | 143 | | |
136 | 144 | | |
| |||
146 | 154 | | |
147 | 155 | | |
148 | 156 | | |
149 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
150 | 165 | | |
151 | | - | |
152 | | - | |
153 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
154 | 186 | | |
155 | 187 | | |
156 | 188 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
| 1 | + | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
15 | 22 | | |
16 | 23 | | |
| 24 | + | |
17 | 25 | | |
18 | 26 | | |
19 | 27 | | |
| 28 | + | |
20 | 29 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
29 | 35 | | |
30 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
31 | 58 | | |
32 | 59 | | |
33 | 60 | | |
| |||
55 | 82 | | |
56 | 83 | | |
57 | 84 | | |
58 | | - | |
| 85 | + | |
59 | 86 | | |
60 | 87 | | |
61 | 88 | | |
62 | 89 | | |
63 | | - | |
| 90 | + | |
64 | 91 | | |
65 | 92 | | |
66 | 93 | | |
67 | 94 | | |
68 | 95 | | |
69 | 96 | | |
70 | 97 | | |
| 98 | + | |
71 | 99 | | |
72 | 100 | | |
73 | 101 | | |
| |||
0 commit comments