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

fix: after merge route #13438

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions web/src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const dateFormats = {

export enum QueryParameter {
ACTION = 'action',
AFTER_MERGE_ROUTE = 'afterMergeRoute',
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe NEXT_ROUTE?

ID = 'id',
IS_OPEN = 'isOpen',
ONBOARDING_STEP = 'step',
Expand Down
8 changes: 5 additions & 3 deletions web/src/routes/(user)/people/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,11 @@
};

const handleMergePeople = async (detail: PersonResponseDto) => {
await goto(
`${AppRoute.PEOPLE}/${detail.id}?${QueryParameter.ACTION}=${ActionQueryParameterValue.MERGE}&${QueryParameter.PREVIOUS_ROUTE}=${AppRoute.PEOPLE}`,
);
const url = new URL(`${AppRoute.PEOPLE}/${detail.id}`, window.location.href);
url.searchParams.append(QueryParameter.ACTION, ActionQueryParameterValue.MERGE);
url.searchParams.append(QueryParameter.PREVIOUS_ROUTE, AppRoute.PEOPLE);
url.searchParams.append(QueryParameter.AFTER_MERGE_ROUTE, AppRoute.PEOPLE);
await goto(url);
};

const submitNameChange = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
let viewMode: ViewMode = ViewMode.VIEW_ASSETS;
let isEditingName = false;
let previousRoute: string = AppRoute.EXPLORE;
let afterMergeRoute: string | undefined = undefined;
let people: PersonResponseDto[] = [];
let personMerge1: PersonResponseDto;
let personMerge2: PersonResponseDto;
Expand Down Expand Up @@ -119,6 +120,11 @@
if (getPreviousRoute && !isExternalUrl(getPreviousRoute)) {
previousRoute = getPreviousRoute;
}

const getAfterMergeRoute = $page.url.searchParams.get(QueryParameter.AFTER_MERGE_ROUTE);
if (getAfterMergeRoute && !isExternalUrl(getAfterMergeRoute)) {
afterMergeRoute = getAfterMergeRoute;
}
if (action == 'merge') {
viewMode = ViewMode.MERGE_PEOPLE;
}
Expand Down Expand Up @@ -188,6 +194,10 @@
};

const handleMerge = async (person: PersonResponseDto) => {
if (afterMergeRoute) {
await goto(afterMergeRoute);
return;
}
await updateAssetCount();
await handleGoBack();

Expand Down
Loading