-
Notifications
You must be signed in to change notification settings - Fork 16
PB-2064: load layers lang topic reload #1517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PB-2064: load layers lang topic reload #1517
Conversation
| function updateActiveLayersFromTopics(this: TopicsStore): Layer[] { | ||
| const layersStore = useLayersStore() | ||
| // Get IDs of currently active layers | ||
| const activeLayerIds = new Set(layersStore.activeLayers.map(layer => layer.id)) | ||
|
|
||
| // Create a map of active layers by ID for quick lookup with their time configs | ||
| const activeLayersMap = new Map( | ||
| layersStore.activeLayers.map(layer => [layer.id, layer]) | ||
| ) | ||
|
|
||
| // Filter layersToActivate to only include layers that are currently active | ||
| const layersToKeep = this.currentTopic!.layersToActivate.filter(layer => | ||
| activeLayerIds.has(layer.id) | ||
| ).map(layer => { | ||
| const activeLayer = activeLayersMap.get(layer.id) | ||
| layer.isVisible = activeLayer?.isVisible || false | ||
| // If the active layer has a time config and current time entry, update the new layer's time config | ||
| if (activeLayer?.timeConfig?.currentTimeEntry && layer.timeConfig) { | ||
| layer.timeConfig.currentTimeEntry = activeLayer.timeConfig.currentTimeEntry | ||
| } | ||
|
|
||
| return layer | ||
| }) | ||
| return layersToKeep |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO you could move that inside the action above, I don't really like the way we need to bind it to have access to this here. (we don't have to deal with this usually, better keep it to the minimum complexity possible)
If you want to keep a bit of "compartments" you can add the name you've given this function as comment just before the logic it contains.
Or if you really think it makes sense to have that as a dedicated function, I'd move it to the utils/ folder, and have it import the topic store with the standard useTopicsStore() instead of relying on this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i removed the function and put it all back into the main loadTopic function
ltkum
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this PR : #1509 , I managed to have an adequate behavior for layers when changing languages with the following change in the setLang action : the changeLayersOnTopicChange option is set to false.
We still have an issue (changing the language open the topic section, maybe we should have an option for that too), but I don't think we need that many changes to achieve what we want.
@ltkum yes your PR seems to fix the language changes, my PR makes it now that the topic changes also reload/set the layers |
160d1d2 to
183a422
Compare
This fixes the behavior of having selected active layers and background layer and then reloading.
Also when changing the language it now replaces the currently active layers with the ones in the new language.
On topic change the new topic layers are set as active layers.
Test link