Move Screen RPC calls into the onLoad method
By making the RPC call during onLoad we ensure the screen is actually attached to the browser window, and thus has a good chance of wanting to get its data from the server. Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -22,7 +22,11 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
|
|||||||
public class AccountSettings extends AccountScreen {
|
public class AccountSettings extends AccountScreen {
|
||||||
public AccountSettings() {
|
public AccountSettings() {
|
||||||
super(Util.C.accountSettingsHeading());
|
super(Util.C.accountSettingsHeading());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad() {
|
||||||
|
super.onLoad();
|
||||||
Util.ACCOUNT_SVC.myAccount(new AsyncCallback<Account>() {
|
Util.ACCOUNT_SVC.myAccount(new AsyncCallback<Account>() {
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
GWT.log("myAccount failed", caught);
|
GWT.log("myAccount failed", caught);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
|
|||||||
|
|
||||||
|
|
||||||
public class MineScreen extends AccountScreen {
|
public class MineScreen extends AccountScreen {
|
||||||
|
private Account.Id ownerId;
|
||||||
private ChangeTable table;
|
private ChangeTable table;
|
||||||
private ChangeTable.Section byOwner;
|
private ChangeTable.Section byOwner;
|
||||||
private ChangeTable.Section forReview;
|
private ChangeTable.Section forReview;
|
||||||
@@ -34,12 +35,24 @@ public class MineScreen extends AccountScreen {
|
|||||||
public MineScreen(final Account.Id id) {
|
public MineScreen(final Account.Id id) {
|
||||||
super(Util.C.mineHeading());
|
super(Util.C.mineHeading());
|
||||||
|
|
||||||
|
ownerId = id;
|
||||||
table = new ChangeTable();
|
table = new ChangeTable();
|
||||||
byOwner = new ChangeTable.Section(Util.C.mineByMe());
|
byOwner = new ChangeTable.Section(Util.C.mineByMe());
|
||||||
forReview = new ChangeTable.Section(Util.C.mineForReview());
|
forReview = new ChangeTable.Section(Util.C.mineForReview());
|
||||||
closed = new ChangeTable.Section(Util.C.mineClosed());
|
closed = new ChangeTable.Section(Util.C.mineClosed());
|
||||||
|
|
||||||
Util.LIST_SVC.forAccount(id, new AsyncCallback<AccountDashboardInfo>() {
|
table.addSection(byOwner);
|
||||||
|
table.addSection(forReview);
|
||||||
|
table.addSection(closed);
|
||||||
|
add(table);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad() {
|
||||||
|
super.onLoad();
|
||||||
|
|
||||||
|
Util.LIST_SVC.forAccount(ownerId,
|
||||||
|
new AsyncCallback<AccountDashboardInfo>() {
|
||||||
public void onSuccess(final AccountDashboardInfo r) {
|
public void onSuccess(final AccountDashboardInfo r) {
|
||||||
byOwner.display(r.getByOwner());
|
byOwner.display(r.getByOwner());
|
||||||
forReview.display(r.getForReview());
|
forReview.display(r.getForReview());
|
||||||
@@ -50,11 +63,5 @@ public class MineScreen extends AccountScreen {
|
|||||||
GWT.log("Fail", caught);
|
GWT.log("Fail", caught);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
table.addSection(byOwner);
|
|
||||||
table.addSection(forReview);
|
|
||||||
table.addSection(closed);
|
|
||||||
|
|
||||||
add(table);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ public class MineStarredScreen extends AccountScreen {
|
|||||||
starred = new ChangeTable.Section();
|
starred = new ChangeTable.Section();
|
||||||
|
|
||||||
table.addSection(starred);
|
table.addSection(starred);
|
||||||
|
|
||||||
add(table);
|
add(table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user