Skip to content

feat: noHistory Feature #3418

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

Closed
calendee opened this issue Mar 26, 2015 · 15 comments
Closed

feat: noHistory Feature #3418

calendee opened this issue Mar 26, 2015 · 15 comments
Assignees
Milestone

Comments

@calendee
Copy link

Type: feat

Platform: all

There are quite a few issues related to overcoming the back view in some apps. Most of the have been closed. I'll try to make a use case as clear as possible.

Scenario 1:

  • App opens
  • User tries to view something
  • They aren't authorized
  • Transition to a Login state
  • User logs in
  • Transition to originally requested state
  • User Happy
  • User goes back
  • User sees login again

Scenario 2;

  • Registered and logged in user opens app
  • Goes to "Contacts" page
  • Realized his BFF is missing from the list
  • Taps "+"
  • Transitions to and Add Contact page
  • Enters the person's name and number
  • Next Button takes to an Addresses page
  • Enters the contacts address info.
  • Saves new contact
  • Goes "back"
  • Is unfortunately seeing the add contact pages again

Scenario # 2 is especially contrived - but it happens. Now, you may be thinking, just do the forms in a modal! Good idea. But in some cases, designers/UX/client doesn't want a modal.

Feature Request:

In the router, be able to add a property like avoidHistory or noHistory. This would indicate that the view in question should never be added to the history stack. This way, after login in, the user will simply go back to the home page.

Right now, people are trying all kinds of ways to prevent the previous view being in their history stack. This feature would solve many of those problems.

FYI : Tried adding this to Trello but doesn't seem possible.

@Purus
Copy link
Contributor

Purus commented Mar 27, 2015

+1

This is the problem I am facing and was trying to solve without any success. Good that someone else took care to log a request.

Thanks for your time.

@ochsenius
Copy link

+1 Thanks for any help

@AMar4enko
Copy link

$ionicHistory.nextViewOptions({historyRoot: true});
$state.go('app.home');

should solve your issue.

@perrygovier
Copy link
Contributor

@calendee does @AlexYankee's approach work?

@perrygovier perrygovier added navigation needs: reply the issue needs a response from the user labels Mar 30, 2015
@ochsenius
Copy link

I did this in the landing page (welcome page):

$ionicHistory.clearHistory();
$ionicHistory.clearCache();

In the origin page (login page):

$ionicHistory.clearHistory();
$ionicHistory.nextViewOptions({
disableBack: true
, historyRoot: true
});
$ionicLoading.hide();
$scope.data.password = null;
$state.go('welcome');

Regards!

On Mon, Mar 30, 2015 at 8:11 PM, Perry Govier [email protected]
wrote:

@calendee https://github.com/calendee does @AlexYankee
https://github.com/AlexYankee's approach work?

Reply to this email directly or view it on GitHub
#3418 (comment).

Christian Ochsenius

Director

M: (+56 9) 9489 6625



www.cursor.cl

T: (+56 2) 2656 4044

Los Leones 382
Of. 101, Providencia

ISO 9001:2008 CERTIFIED

@calendee
Copy link
Author

calendee commented Apr 2, 2015

@perrygovier No, that actually clears the entire history. So, in scenario # 2, if the user is down about 5 levels in the app (stupid I know) and then tries to add a new contact, when they do they can't get back to home anymore because the contact's list has suddenly become the history root.

@Ionitron Ionitron removed the needs: reply the issue needs a response from the user label Apr 2, 2015
@beliz
Copy link

beliz commented Apr 7, 2015

+1

In my app, when a user create a new item, he is send in the item page, but if use the back button he is send on the create page, but I want to send him on the list page.

In fact, i think some functions are missing in $ionicHistory like :

remove(position); // Remove a specific entry in the history stack
addAfter(position, page); // Add a stat in the history at the specified position

In other world, it would be nice if we can manage the history, so we can achieve what we want.

@calendee calendee changed the title feat: noHistoryFeature feat: noHistory Feature Apr 9, 2015
@josephfinlayson
Copy link

+1

@josephfinlayson
Copy link

I've solved this in the interim using the following decorator:

.config(function ($provide, $injector) {
    var ionicHistory = $injector.get('$ionicHistoryProvider').$get();
    var regFunc = ionicHistory.register.bind(ionicHistory);

    ionicHistory.register = function (parentScope, viewLocals) {
        if (viewLocals.$$state.noHistory) {
            return {};
        }
        return regFunc(parentScope, viewLocals);
    };

    $provide.decorator('$ionicHistory', function () {
        return ionicHistory;
    });
})

Am I doing anything incredibly stupid here?

UPDATE: It doesn't work!

@adamdbradley adamdbradley modified the milestone: 1.0.1 Apr 27, 2015
@msalman
Copy link

msalman commented Apr 30, 2015

Hi,
I have a simple login based application in which user can access About menu with or without login, issue came with android hardware back button,

Login screen > About page > From Menu go to Login > Press hardware back button > Application Should get closed rather go to About page.

Below is the code for navigation to login screen.

$scope.login = function() {
            $ionicHistory.nextViewOptions({
                disableBack: true,
                disableAnimate: true,
                historyRoot: true
            });
            $ionicHistory.clearCache();
            $ionicHistory.clearHistory();
            $ionicSideMenuDelegate.toggleLeft();
            $state.go('login');
        };

I am using ionic rc release 4 currently.

@lewisl9029
Copy link

In the mean time, here's something that worked for me:

$state.go(stateName, null, { location: 'replace' });

This will update the current history entry to the new state you're navigating to, and won't create a new history entry for the previous state.

See the ui-router docs here for details: http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.$state

@mlynch mlynch modified the milestones: 1.3, 1.2 Dec 10, 2015
@alwayrun
Copy link

+1

@PritishC
Copy link

PritishC commented Jul 4, 2016

+1, I came across scenario 1 in my app. I too have been trying the clear cache, clear history, disable back and history root stuff. Leads to subtle bugs 2-3 views down in the stack. It would be nice to have a noHistory feature.

Will try @lewisl9029's suggestion, seems clean and interesting.

@jgw96
Copy link
Contributor

jgw96 commented Dec 14, 2016

Hello all! Since we are not planning on adding any additional features to Ionic 1 I am going to go ahead and close this issue for now. Thanks!

@jgw96 jgw96 closed this as completed Dec 14, 2016
@ionitron-bot
Copy link

ionitron-bot bot commented Sep 5, 2018

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.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests