From 059db280bba858a3cab3a542aef13f19737aaf6e Mon Sep 17 00:00:00 2001
From: toasted-nutbread <toasted-nutbread@users.noreply.github.com>
Date: Sun, 15 Mar 2020 17:13:00 -0400
Subject: Add custom context object for note creation

---
 ext/mixed/js/api.js     | 8 ++++----
 ext/mixed/js/display.js | 8 ++++++--
 2 files changed, 10 insertions(+), 6 deletions(-)

(limited to 'ext/mixed/js')

diff --git a/ext/mixed/js/api.js b/ext/mixed/js/api.js
index df6a93f5..feec94df 100644
--- a/ext/mixed/js/api.js
+++ b/ext/mixed/js/api.js
@@ -53,12 +53,12 @@ function apiKanjiFind(text, optionsContext) {
     return _apiInvoke('kanjiFind', {text, optionsContext});
 }
 
-function apiDefinitionAdd(definition, mode, details, optionsContext) {
-    return _apiInvoke('definitionAdd', {definition, mode, details, optionsContext});
+function apiDefinitionAdd(definition, mode, context, details, optionsContext) {
+    return _apiInvoke('definitionAdd', {definition, mode, context, details, optionsContext});
 }
 
-function apiDefinitionsAddable(definitions, modes, optionsContext) {
-    return _apiInvoke('definitionsAddable', {definitions, modes, optionsContext});
+function apiDefinitionsAddable(definitions, modes, context, optionsContext) {
+    return _apiInvoke('definitionsAddable', {definitions, modes, context, optionsContext});
 }
 
 function apiNoteView(noteId) {
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index 8587657f..ecf92013 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -760,7 +760,7 @@ class Display {
                 }
             }
 
-            const noteId = await apiDefinitionAdd(definition, mode, details, this.getOptionsContext());
+            const noteId = await apiDefinitionAdd(definition, mode, this._getNoteContext(), details, this.getOptionsContext());
             if (noteId) {
                 const index = this.definitions.indexOf(definition);
                 const adderButton = this.adderButtonFind(index, mode);
@@ -908,7 +908,7 @@ class Display {
 
     async getDefinitionsAddable(definitions, modes) {
         try {
-            return await apiDefinitionsAddable(definitions, modes, this.getOptionsContext());
+            return await apiDefinitionsAddable(definitions, modes, this._getNoteContext(), this.getOptionsContext());
         } catch (e) {
             return [];
         }
@@ -934,6 +934,10 @@ class Display {
         return (typeof key === 'string' ? (key.length === 1 ? key.toUpperCase() : key) : '');
     }
 
+    _getNoteContext() {
+        return {};
+    }
+
     async _getAudioUri(definition, source) {
         const optionsContext = this.getOptionsContext();
         return await apiAudioGetUri(definition, source, optionsContext);
-- 
cgit v1.2.3