PeteGashek / puzzlebazar

Automatically exported from code.google.com/p/puzzlebazar
0 stars 0 forks source link

CurrentUser.java continues to fire after a log in process or sign out process has been completed. #112

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.  Load and Run Puzzlebazar

What is the expected output? What do you see instead?
When a user logs in or out of the application the 
CurrentUserChangedEvent.fire(eventBus, result.getUser()); should fire only 
once.  At present it continues to fire according to a timer object in the 
class.  This means if you are using this event to perform say a setup of the 
screen when a user first logs in, such as a go to Application Dashboard type 
action then this will continue to happen throughout the lifetime of the 
application.

What version of the product are you using? On what operating system?
GWTP v0.2, PuzzleBazar v0.2

Please provide any additional information below.
Fix is below in the onSuccess() and failed() methods the scheduleFetchUser 
should not be re-setup as this re-initialises the timer.

{{{
/**
     * Fetches the user information from the server. Fires a {@link CurrentUserChangedEvent} when successful.
     */
    public void fetchUser() {
        fetchUserTimer.cancel();
        dispatcher.execute(new GetCurrentUserAction(), new AsyncCallback<GetUserResult>() {

            @Override
            public void onFailure(Throwable caught) {
                confirmed = true; // Async call is back. We know if user is logged-in or not.
                failed();
            }

            @Override
            public void onSuccess(GetUserResult result) {
                confirmed = true; // Async call is back. We know if user is logged-in or not.
                if (result != null) {
                    user = result.getUser();
                    loginUrl = result.getLoginUrl();
                    logoutUrl = result.getLogoutUrl();
                    CurrentUserChangedEvent.fire(eventBus, result.getUser());
                    fetchUserTimer.cancel();
                    //scheduleFetchUser(refreshDelay);
                } else {
                    failed();
                }
            }

            private void failed() {
                user = null; // Nobody is logged in
                //scheduleFetchUser(retryDelay);
                fetchUserTimer.cancel();
                CurrentUserChangedEvent.fire(eventBus, null);
            }
        });

    }
}}}

Original issue reported on code.google.com by drgenejones on 14 Jul 2010 at 4:40