Skip to content

Move "print" job logic and management out of area composable#737

Merged
pakb merged 2 commits intodevelopfrom
feat_split_print_functions
Mar 27, 2024
Merged

Move "print" job logic and management out of area composable#737
pakb merged 2 commits intodevelopfrom
feat_split_print_functions

Conversation

@pakb
Copy link
Contributor

@pakb pakb commented Mar 25, 2024

The print area preview composable was doing the preview, the printing and also coffee. It is now only responsible for the preview area. I also took the opportunity to remove from the store things that weren't making much sense being there, as no one else as the print menu section was using them (and as the menu section is now the one triggering the print job, it's much clearer this way)

Test link

@pakb pakb requested a review from ltshb March 25, 2024 16:41
@cypress
Copy link

cypress bot commented Mar 25, 2024

Passing run #1339 ↗︎

0 166 22 0 Flakiness 0

Details:

PR Review
Project: web-mapviewer Commit: d836bed380
Status: Passed Duration: 04:43 💡
Started: Mar 27, 2024 9:49 AM Ended: Mar 27, 2024 9:54 AM

Review all test suite changes for PR #737 ↗︎

@pakb pakb force-pushed the feat_split_print_functions branch from e8b5613 to e91646a Compare March 25, 2024 16:58
Copy link
Contributor

@ltshb ltshb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will probably enter in conflict with #727 and it might make more sense that ismail review it

@pakb pakb requested review from ismailsunni and ltshb March 27, 2024 06:19
@pakb pakb force-pushed the feat_split_print_functions branch from e91646a to fce4af7 Compare March 27, 2024 07:07
Copy link
Contributor

@ismailsunni ismailsunni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really much better. Thanks!. Only some small questions.

// for now, we only check if app is ready and printing status
// TODO: any pending request to the backend should trigger the loading bar
const shouldLoadingBarBeVisible = !state.app.isReady || state.print.printingStatus
const shouldLoadingBarBeVisible = !state.app.isReady
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the printStatus is removed, how will the loading bar be shown?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should add a todo in the usePrint composable to tackle that.
The idea is that the composable itself will dispatch something (the source it is waiting on) and then subsequently dispatch once more when it is done. The loading bar will be shown whenever a source is not done loading, meaning we will be removing this loading bar management plugin altogether.

Comment on lines +29 to +41
const printLayout = computed(() => store.state.print.selectedLayout)
const printScale = computed(() => store.state.print.selectedScale)
const attributions = computed(() =>
store.getters.visibleLayers
.map((layer) => layer.attributions)
.map((attribution) => attribution.name)
.filter((attribution, index, self) => self.indexOf(attribution) === index)
)
const layersWithLegends = computed(() =>
store.getters.visibleLayers.filter((layer) => layer.hasLegend)
)
const lang = computed(() => store.state.i18n.lang)
const projection = computed(() => store.state.map.projection)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For these computed, should we just retrieve once when we call the function to prevent impact on performancce? e.g. only retrieve from store when we call createPrintJob?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might be a good idea yeah, I'll try and see if it works as intended

await abortCurrentJob()
}
printStatus.value = PrintStatus.PRINTING
await store.dispatch('generateShortLinks', dispatcher)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, @ltshb suggested me to call the function directy without saving the result to avoid a dispatch. #658 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is sound, then I'll move the part of the logic that decide to remove geolocation out of the store, in some function in shortLink.api.js so that we can re-use it.
I used the dispatch so that this part of the code wasn't duplicated (removing the geolocation URL param and so on)

The print area preview composable was doing the preview, the printing and also coffee. It is now only responsible for the preview area.
I also took the opportunity to remove from the store things that weren't making much sense being there, as no one else as the print menu section was using them (and as the menu section is now the one triggering the print job, it's much clearer this way)
@pakb pakb force-pushed the feat_split_print_functions branch from fce4af7 to e195f54 Compare March 27, 2024 09:37
move geolocation removal into API file directly (so that the logic is shared across the app
use store value directly when printing, no need to go through a reactivity computed prop as we won't be reacting to changes while printing
@pakb pakb force-pushed the feat_split_print_functions branch from e195f54 to d836bed Compare March 27, 2024 09:45
@pakb pakb merged commit e4f478d into develop Mar 27, 2024
@pakb pakb deleted the feat_split_print_functions branch March 27, 2024 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants