aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/yomichan.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-08-20 19:15:30 -0700
committerAlex Yatskov <alex@foosoft.net>2016-08-20 19:15:30 -0700
commit18fc8d9865406a74dbea47f49ac959a543035ec7 (patch)
treec7de9835e4385dc18a6245944fcf2d673276bb49 /ext/bg/js/yomichan.js
parent015c262bbf4a9af7cee62fdb0be15450ef736f74 (diff)
Performance improvements
Diffstat (limited to 'ext/bg/js/yomichan.js')
-rw-r--r--ext/bg/js/yomichan.js20
1 files changed, 13 insertions, 7 deletions
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js
index b8fa9593..fd9b84d3 100644
--- a/ext/bg/js/yomichan.js
+++ b/ext/bg/js/yomichan.js
@@ -35,6 +35,7 @@ class Yomichan {
this.translator = new Translator();
this.asyncPools = {};
+ this.ankiConnectVer = 0;
this.setState('disabled');
chrome.runtime.onInstalled.addListener(this.onInstalled.bind(this));
@@ -129,13 +130,18 @@ class Yomichan {
}
ankiInvokeSafe(action, params, pool, callback) {
- this.api_getVersion({callback: (version) => {
- if (version === this.getApiVersion()) {
- this.ankiInvoke(action, params, pool, callback);
- } else {
- callback(null);
- }
- }});
+ if (this.ankiConnectVer === this.getApiVersion()) {
+ this.ankiInvoke(action, params, pool, callback);
+ } else {
+ this.api_getVersion({callback: (version) => {
+ if (version === this.getApiVersion()) {
+ this.ankiConnectVer = version;
+ this.ankiInvoke(action, params, pool, callback);
+ } else {
+ callback(null);
+ }
+ }});
+ }
}
ankiInvoke(action, params, pool, callback) {