-
Notifications
You must be signed in to change notification settings - Fork 13.5k
feat: remove a particular view from the history #3750
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
Comments
I added this method under /**
* @ngdoc method
* @name $ionicHistory#removeBackView
* @description Remove the previous view from the history completely, including the
* cached element and scope (if they exist).
*/
removeBackView: function () {
var self = this;
var currentHistory = viewHistory.histories[this.currentHistoryId()];
var currentCursor = currentHistory.cursor;
var currentView = currentHistory.stack[currentCursor];
var backView = currentHistory.stack[currentCursor - 1];
var replacementView = currentHistory.stack[currentCursor - 2];
// fail if we dont have enough views in the history
if (!backView || !replacementView) {
return;
}
// remove the old backView and the cached element/scope
currentHistory.stack.splice(currentCursor - 1, 1);
self.clearCache([backView.viewId]);
// make the replacementView and currentView point to each other (bypass the old backView)
currentView.backViewId = replacementView.viewId;
currentView.index = currentView.index - 1;
replacementView.forwardViewId = currentView.viewId;
// update the cursor and set new backView
viewHistory.backView = replacementView;
currentHistory.currentCursor += -1;
}, |
Probably going to make this a bit more generic like Eg: Anybody interested? |
I'd like to see a PR where you can remove previous states by state name and possibly also by ID. This is a very sensitive area though and would need lots of unit tests and a few HTML tests. If anyone wants to start a PR, I can get it up to snuff so it's ready to be submitted to the core. Is there any more demand for this? |
If you google "ionic location replace" and similar there are quite a lot of people having this issue. PR is coming tonight... |
Greetings @Deminetix! I've closed this issue because my sensors indicated it was old and inactive, and may have already been fixed in recent versions of Ionic. However, if you are still experiencing this issue, please feel free to reopen this issue by creating a new one, and include any examples and other necessary information, so that we can look into it further. Thank you for allowing me to assist you. |
Hi, I think this is related to #1287 and can be used to fix that problem instead of using any kind of "hack". |
Has this been integrated in the core yet or are work-a-rounds still required? |
@MoPHL Workarounds are still required, unfortunately. |
Would be great if this would make it to core - playing around with these workarounds and there is always something broken :/ |
+1 |
4 similar comments
+1 |
+1 |
+1 |
+1 |
+1, this is very major problem for us |
+1 |
4 similar comments
+1 |
+1 |
+1 |
+1 |
If you want to prevent the user to nav back to the last state you can always use $ionicHistory.goBack() before navigating to an other state. Something like : It is not as flexible as being able to remove a particular page though, but in my case it was enough. |
+1 |
+1 |
7 similar comments
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
I think it is necessary. |
+1 |
+2 |
This will be a part of tonight's nightly build. No further +1s needed 👍 . Thanks for contribution everyone! Thanks, |
I had the issue of deleting a portion of the backviews
|
Calling removeBackView() twice returns error:
Ah, I think this line:
should be...
|
Have the same issue with @cjlucani, is there any update on this? did you find another proper way to solve this? |
Basically if we would have something like the |
I think I have a related issue because I need to remove a particular view from the history, specifically the forwardView. Any thought about achieve that? The other workarounds commented here don't apply to this need because I don't want to remove any backView. |
+1 |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Type: feat
Platform: mobile webview
Say i have traversed 3 views and i have a history that looks like this:
A -> B -> C
and i am now onC
:Is there currently a way that i can remove
B
completely from the history - including the cached elements and scope? This would mean going back goes to AThe
goBack([amount])
method works perfectly in some situations, but it doesn't work with iOS swipe to go back. A better solution would be a method to remove a specific item in the current history.The text was updated successfully, but these errors were encountered: