Skip to content

Commit

Permalink
fix: redirect if task is self service
Browse files Browse the repository at this point in the history
  • Loading branch information
devmiguelangel committed Aug 19, 2024
1 parent c0734a7 commit 49bfbad
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/components/task.vue
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ export default {
return `/tasks/${firstTask.id}/edit`;
}
return document.referrer || null;
return this.getSessionRedirectUrl();
} catch (error) {
console.error("Error in getDestinationUrl:", error);
return null;
Expand All @@ -465,7 +465,27 @@ export default {
const sessionStorageUrl = sessionStorage.getItem("elementDestinationURL");
return sessionStorageUrl || null;
},
/**
* Retrieves the URL from the session storage or the document referrer.
*
* This method is used to determine the source of the redirection when the task is claimed.
* It retrieves the 'sessionUrlSelfService' value from sessionStorage, and if present, removes it.
* If the value is not found, it returns the document referrer.
*
* @returns {string|null} - The URL from the session storage or the document referrer.
*/
getSessionRedirectUrl() {
const urlSelfService = sessionStorage.getItem('sessionUrlSelfService');
if (urlSelfService) {
// Remove 'sessionUrlSelfService' from sessionStorage after retrieving its value
sessionStorage.removeItem('sessionUrlSelfService');
// Emit the source of the redirection
return urlSelfService;
}
return document.referrer || null;
},
loadNextAssignedTask(requestId = null) {
if (!requestId) {
requestId = this.requestId;
Expand Down Expand Up @@ -809,8 +829,8 @@ export default {
* Checks for the presence of a URL action blocker in sessionStorage and handles it.
*
* This method retrieves the 'sessionUrlActionBlocker' value from sessionStorage,
* and if present, removes it and emits a 'closed' event with the task id and
* the source of the redirection. It returns false if the blocker was handled,
* and if present, removes it and emits a 'closed' event with the task id and
* the source of the redirection. It returns false if the blocker was handled,
* and true otherwise.
*
* @returns {boolean} Returns false if the 'sessionUrlActionBlocker' was found and handled, true otherwise.
Expand Down

0 comments on commit 49bfbad

Please sign in to comment.