From b9db274286c15d1fc26638f602e95baf773b94fb Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Tue, 17 Feb 2015 10:12:34 -0800 Subject: [PATCH] ChangeScreen: explicitly load revision info The new explicit loading of the revision actions is performed by the new REST API call /changes//revisions//actions, which also checks other changes for submittability if `submitWholeTopic` is enabled. This may slow down revision loading, hence move it out in an extra async call. Change-Id: I0be8bcef18aed34d912ab3048436bd62cbc47ead --- .../gerrit/client/change/ChangeScreen.java | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/ChangeScreen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/ChangeScreen.java index f690ce0788..98220dabb4 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/ChangeScreen.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/ChangeScreen.java @@ -240,7 +240,10 @@ public class ChangeScreen extends Screen { @Override public void onSuccess(ChangeInfo info) { info.init(); + // Revision loading may be slower than the rest, so do it + // asynchronous to have the rest fast. loadConfigInfo(info, base); + loadRevisionInfo(); } })); } @@ -248,7 +251,7 @@ public class ChangeScreen extends Screen { void loadChangeInfo(boolean fg, AsyncCallback cb) { RestApi call = ChangeApi.detail(changeId.get()); ChangeList.addOptions(call, EnumSet.of( - ListChangesOption.CURRENT_ACTIONS, + ListChangesOption.CHANGE_ACTIONS, ListChangesOption.ALL_REVISIONS)); if (!fg) { call.background(); @@ -256,6 +259,18 @@ public class ChangeScreen extends Screen { call.get(cb); } + void loadRevisionInfo() { + RestApi call = ChangeApi.actions(changeId.get(), revision); + call.background(); + call.get(new GerritCallback>() { + @Override + public void onSuccess(NativeMap actionMap) { + actionMap.copyKeysIntoChildren("id"); + renderRevisionInfo(changeInfo, actionMap); + } + }); + } + @Override protected void onUnload() { if (replyAction != null) { @@ -1074,12 +1089,9 @@ public class ChangeScreen extends Screen { } setWindowTitle(sb.toString()); - RevisionInfo revInfo = info.revision(revision); - NativeMap actionMap = revInfo.has_actions() - ? info.actions() - : NativeMap. create(); - actionMap.copyKeysIntoChildren("id"); - renderRevisionInfo(info, actionMap); + // Properly render revision actions initially while waiting for + // the callback to populate them correctly. + renderRevisionInfo(changeInfo, NativeMap. create()); } private void renderRevisionInfo(ChangeInfo info,