Skip to content
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

Add toasts where sensible #294

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

sorenjohanson
Copy link
Contributor

closes #288

@sorenjohanson sorenjohanson changed the title Draft: Add toasts where sensible Add toasts where sensible Jun 19, 2024
@sorenjohanson sorenjohanson marked this pull request as ready for review June 19, 2024 14:25
"NODE_COPIED": "Knoten erfolgreich kopiert!",
"ERRORS": {
"ROOT_NODE_COPIED": "Es ist nicht möglich, den Hauptknoten zu kopieren!",
"GENERIC_NODE_COPY_ERROR": "Beim kopieren des Knoten ist ein Fehler aufgetreten."
Copy link
Member

Choose a reason for hiding this comment

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

Beim Kopieren des Knotens

Copy link
Member

Choose a reason for hiding this comment

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

"Kopieren" needs still a capitalized K ;-)

);
this.toastrService.success(successMessage);
} catch (e) {
if (e.message == 'The root node can not be copied') {
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest always to use strict equality checks with ===

Copy link
Member

Choose a reason for hiding this comment

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

do we have to check for the message or isn't there a specific class / type field available?

Copy link
Member

Choose a reason for hiding this comment

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

if not, maybe its a good idea to at least refactor this message as a constant variable. Better in the mmp lib, otherwise here at the top of the file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't think this has a specific type, but strict equality didn't work for some reason (even though e.message should be typeof string, but maybe it's JS doing JS things), was my first preference as well.

Question is if we've got any other errors this could potentially throw - right now I'm just seeing a specific error message when trying to copy the root node, otherwise it doesn't actually error out at all. If we had multiple errors I could see the value in a constant, but not sure if it's worth it for a one-off.

const showToast = next.queryParamMap.get('showToast');
const toastMessage = next.queryParamMap.get('toastMessage');

if (showToast === 'true' && toastMessage) {
Copy link
Member

Choose a reason for hiding this comment

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

instead of true/false as strings, maybe better to use 1/0?

Copy link
Member

Choose a reason for hiding this comment

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

wouldnt be just the availability of a toastMessage enough? Or what's the case where I am passing a toast message without the showToast flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah good point about the toastMessage actually :D

canActivate(
next: ActivatedRouteSnapshot,
state: RouterStateSnapshot
): Promise<boolean> | boolean {
Copy link
Member

Choose a reason for hiding this comment

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

only use one type, e.g. Promise<boolean>. I don't think you need to change anything else, otherwise you can always a return a Promise.resolve(true).

@@ -35,7 +35,18 @@ export class DialogAboutComponent {
if (confirm(this.translateService.instant('MODALS.INFO.CONFIRM_DELETE'))) {
await this.mapSyncService.deleteMap(await this.mapAdminId);
await this.storageService.remove(this.map.uuid);
window.location.reload();

const url = new URL(window.location.href);
Copy link
Member

Choose a reason for hiding this comment

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

can't we use the router.state here as well? I think its a more unified way of accessing the url

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that was my preferred way of doing it since router.navigate is a much cleaner way of doing things and allows us to separate URL, query params and fragment, but wasn't sure if it was worth it for a one off (esp. considering the component doesn't have the router yet)


url.hash = fragment;

window.location.replace(url.toString());
Copy link
Member

Choose a reason for hiding this comment

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

same here, maybe use angular router instead of doing this manually?

@JannikStreek
Copy link
Member

This is really helpful, I really like these messages where it was unclear before what really happened 😂 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add toasts where sensible
2 participants