Skip to content

Commit 8e097df

Browse files
committed
Fix for #280, unloading project when deleted.
1 parent 71c692e commit 8e097df

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

wwwroot/modules/main.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ import { DropPosition } from "./types.js";
7272
import TileMapUtil from "./util/tileMapUtil.js";
7373
import PaintUtil from "./util/paintUtil.js";
7474
import PaletteUtil from "./util/paletteUtil.js";
75+
import TileMapList from "./models/tileMapList.js";
7576

7677

7778
/* ****************************************************************************************************
@@ -2621,13 +2622,6 @@ function formatForNoProject() {
26212622

26222623
currentProject.nativePalettes = null;
26232624

2624-
const dummyProject = createEmptyProject({ systemType: 'smsgg' });
2625-
while (dummyProject.paletteList.length > 1) {
2626-
dummyProject.paletteList.removeAt(0);
2627-
}
2628-
dummyProject.tileMapList.clear();
2629-
dummyProject.tileSet.clear();
2630-
26312625
projectToolbar.setState({
26322626
enabled: false,
26332627
projectTitle: ' ',
@@ -2686,8 +2680,8 @@ function formatForNoProject() {
26862680
enabled: false
26872681
});
26882682
tileManager.setState({
2689-
tileMapList: dummyProject.tileMapList,
2690-
tileSet: dummyProject.tileSet,
2683+
tileMapList: new TileMapList([]),
2684+
tileSet: new TileSet(),
26912685
palette: null,
26922686
paletteList: null,
26932687
selectedTileMapId: null
@@ -4096,7 +4090,7 @@ function changePaletteEditorDisplayNativeColours(displayNative) {
40964090
}
40974091

40984092
function updateTileEditorGridColours() {
4099-
const isGameboyProject = getUIState().displayNativeColour && getProject().systemType === 'gb';
4093+
const isGameboyProject = getUIState().displayNativeColour && getProject()?.systemType === 'gb';
41004094
tileEditor.setState({
41014095
pixelGridColour: (isGameboyProject) ? '#98a200' : '#000000',
41024096
pixelGridOpacity: (isGameboyProject) ? 0.5 : 0.2,

wwwroot/modules/state.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,6 @@ export default class State {
5656
return contexts;
5757
}
5858

59-
/**
60-
* Gets a list of sources that may trigger an event.
61-
*/
62-
static get EventSources() {
63-
return eventSources;
64-
}
65-
6659

6760
/**
6861
* Gets the presistent UI state (must call the 'loadPersistentUIStateFromLocalStorage()' method before accessing).
@@ -326,7 +319,7 @@ export default class State {
326319
this.#dispatcher.dispatch(EVENT_OnEvent, createArgs(events.projectListChanged, { context: contexts.deleted, projectId: projectId }));
327320

328321
if (this.project?.id === projectId) {
329-
this.setProject(null, eventSources.none);
322+
this.setProject(null, contexts.deleted);
330323
}
331324
}
332325
addOrRemoveProjectEntriesBasedOnLocalStorage(this.#projectEntries, this);

0 commit comments

Comments
 (0)