Cache recent project configs globally in the client

It is repeating a lot of work to GET /projects/X/config on every
change/patch set/diff load. Instead, just cache a few recent configs.
Don't worry about invalidation for now; the info that we're caching
shouldn't change very often, and if it does, the user just has to
reload the app. (This would not be safe if we were caching permissions
on the client side, but it seems unlikely we would do that.)

Change-Id: I7550311cf32b66498b2998897ccac55434f04a1e
This commit is contained in:
Dave Borowitz
2013-04-08 16:57:02 -07:00
parent 3203293510
commit 7239d86673
6 changed files with 104 additions and 23 deletions

View File

@@ -18,8 +18,7 @@ import com.google.gerrit.client.Dispatcher;
import com.google.gerrit.client.FormatUtil;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.account.AccountInfo;
import com.google.gerrit.client.projects.ConfigInfo;
import com.google.gerrit.client.projects.ProjectApi;
import com.google.gerrit.client.projects.ConfigInfoCache;
import com.google.gerrit.client.rpc.CallbackGroup;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.CommentLinkProcessor;
@@ -270,12 +269,12 @@ public class ChangeScreen extends Screen
// start an async get at the source of every call that might trigger a
// value change.
CallbackGroup cbs = new CallbackGroup();
ProjectApi.config(event.getValue().getChange().getProject())
.get(cbs.add(new GerritCallback<ConfigInfo>() {
ConfigInfoCache.get(
event.getValue().getChange().getProject(),
cbs.add(new GerritCallback<ConfigInfoCache.Entry>() {
@Override
public void onSuccess(ConfigInfo result) {
commentLinkProcessor =
new CommentLinkProcessor(result.commentlinks());
public void onSuccess(ConfigInfoCache.Entry result) {
commentLinkProcessor = result.getCommentLinkProcessor();
}
@Override