mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-08-31 23:53:25 +00:00
remove duplicate logic
This commit is contained in:
@@ -26,7 +26,6 @@
|
||||
// remove controls for deleted files
|
||||
routingControls.forEach((controls, fileId) => {
|
||||
if (!get(filestore).find((file) => file._data.id === fileId)) {
|
||||
console.log('remove controls for deleted file', fileId);
|
||||
controls.remove();
|
||||
routingControls.delete(fileId);
|
||||
|
||||
@@ -38,7 +37,6 @@
|
||||
}
|
||||
|
||||
$: if ($map && $selectedFiles) {
|
||||
console.log('selectedFiles', $selectedFiles);
|
||||
// update selected file
|
||||
if ($selectedFiles.size == 0 || $selectedFiles.size > 1 || !active) {
|
||||
if (selectedId) {
|
||||
@@ -54,14 +52,12 @@
|
||||
selectedId = newSelectedId;
|
||||
}
|
||||
}
|
||||
console.log('selectedId', selectedId);
|
||||
}
|
||||
|
||||
$: if ($map && selectedId) {
|
||||
if (!routingControls.has(selectedId)) {
|
||||
let selectedFileStore = filestore.getFileStore(selectedId);
|
||||
if (selectedFileStore) {
|
||||
console.log('add controls for selected file', selectedId);
|
||||
routingControls.set(
|
||||
selectedId,
|
||||
new RoutingControls(get(map), selectedFileStore, popup, popupElement)
|
||||
|
@@ -88,7 +88,6 @@ export function createGPXFileStore(): GPXFileStore {
|
||||
}
|
||||
}
|
||||
if (global) {
|
||||
console.log("Global patch", patch);
|
||||
notify();
|
||||
}
|
||||
updateUndoRedo();
|
||||
@@ -181,19 +180,11 @@ export function createGPXFileStore(): GPXFileStore {
|
||||
draft.delete(fileId);
|
||||
});
|
||||
});
|
||||
selectedFiles.update($selected => {
|
||||
$selected.clear();
|
||||
return $selected;
|
||||
});
|
||||
},
|
||||
deleteAllFiles: () => {
|
||||
applyToGlobalStore((draft) => {
|
||||
draft.clear();
|
||||
});
|
||||
selectedFiles.update($selected => {
|
||||
$selected.clear();
|
||||
return $selected;
|
||||
});
|
||||
},
|
||||
getFileStore: (id: string) => {
|
||||
return filestores.get(id);
|
||||
|
@@ -14,7 +14,7 @@ export const fileOrder = writable<string[]>([]);
|
||||
export const selectedFiles = writable<Set<string>>(new Set());
|
||||
export const selectFiles = writable<{ [key: string]: (fileId?: string) => void }>({});
|
||||
|
||||
filestore.subscribe((files) => { // Update selectedFiles if a file is deleted
|
||||
filestore.subscribe((files) => { // Update selectedFiles automatically when files are deleted (either by action or by undo-redo)
|
||||
let deletedFileIds: string[] = [];
|
||||
get(selectedFiles).forEach((fileId) => {
|
||||
if (!files.find((f) => f._data.id === fileId)) {
|
||||
|
Reference in New Issue
Block a user