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:
@@ -21,8 +21,7 @@ import com.google.gerrit.client.RpcStatus;
|
||||
import com.google.gerrit.client.changes.CommitMessageBlock;
|
||||
import com.google.gerrit.client.changes.PatchTable;
|
||||
import com.google.gerrit.client.changes.Util;
|
||||
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.rpc.ScreenLoadCallback;
|
||||
@@ -392,12 +391,11 @@ public abstract class PatchScreen extends Screen implements
|
||||
if (commentLinkProcessor == null) {
|
||||
// Fetch config in parallel if we haven't previously.
|
||||
CallbackGroup cb = new CallbackGroup();
|
||||
ProjectApi.config(patchSetDetail.getProject())
|
||||
.get(cb.add(new AsyncCallback<ConfigInfo>() {
|
||||
ConfigInfoCache.get(patchSetDetail.getProject(),
|
||||
cb.add(new AsyncCallback<ConfigInfoCache.Entry>() {
|
||||
@Override
|
||||
public void onSuccess(ConfigInfo result) {
|
||||
commentLinkProcessor =
|
||||
new CommentLinkProcessor(result.commentlinks());
|
||||
public void onSuccess(ConfigInfoCache.Entry result) {
|
||||
commentLinkProcessor = result.getCommentLinkProcessor();
|
||||
contentTable.setCommentLinkProcessor(commentLinkProcessor);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user