Skip to content

Commit

Permalink
go back if there is history, otherwise go to /app after post delete
Browse files Browse the repository at this point in the history
  • Loading branch information
avi-l committed Feb 6, 2024
1 parent 09250db commit 4ed770e
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ export function PostOptions({
setIndexOfOptionLoading(null);
if (error) throw new Error('Error trying to delete');
deleteFromCloundinary(image_url);
router.push('/app');
if (typeof window !== 'undefined') {
if (window.history.length > 1) {
window.history.back(); // Go back to the previous page
} else {
router.push('/app'); // Navigate to '/app' if no history
}
}
router.refresh();
} catch (e) {
//
Expand Down

0 comments on commit 4ed770e

Please sign in to comment.