Skip to content

Commit dd4017f

Browse files
committed
Deprecate noteId var from getNoteTags in Js-API
1 parent 1d88784 commit dd4017f

3 files changed

Lines changed: 4 additions & 13 deletions

File tree

AnkiDroid/src/main/assets/scripts/js-api.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ Object.keys(jsApiList).forEach(method => {
129129
return;
130130
}
131131
if (method === "ankiSetNoteTags") {
132-
AnkiDroidJS.prototype[method] = async function (noteId, tags) {
132+
AnkiDroidJS.prototype[method] = async function (tags) {
133133
let hasSpaces = false;
134134
for (let i = 0; i < tags.length; i++) {
135135
tags[i] = tags[i].trim();
@@ -147,14 +147,6 @@ Object.keys(jsApiList).forEach(method => {
147147
};
148148
return;
149149
}
150-
if (method === "ankiGetNoteTags") {
151-
AnkiDroidJS.prototype[method] = async function (noteId) {
152-
const endpoint = jsApiList[method];
153-
const data = JSON.stringify({ noteId });
154-
return await this.handleRequest(endpoint, data);
155-
};
156-
return;
157-
}
158150
if (method === "ankiTtsSpeak") {
159151
AnkiDroidJS.prototype[method] = async function (text, queueMode = 0) {
160152
const endpoint = jsApiList[method];

AnkiDroid/src/main/java/com/ichi2/anki/AnkiDroidJsAPI.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ open class AnkiDroidJsAPI(
380380

381381
"setNoteTags" -> {
382382
val jsonObject = JSONObject(apiParams)
383-
val noteId = jsonObject.getLong("noteId")
383+
val noteId = currentCard.nid
384384
val tags = jsonObject.getJSONArray("tags")
385385
withCol {
386386
fun Note.setTagsFromList(tagList: List<String>) {
@@ -403,8 +403,7 @@ open class AnkiDroidJsAPI(
403403
}
404404

405405
"getNoteTags" -> {
406-
val jsonObject = JSONObject(apiParams)
407-
val noteId = jsonObject.getLong("noteId")
406+
val noteId = currentCard.nid
408407
val noteTags =
409408
withCol {
410409
getNote(noteId).tags

AnkiDroid/src/test/java/com/ichi2/anki/AnkiDroidJsAPITest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ class AnkiDroidJsAPITest : RobolectricTest() {
428428

429429
// test get tags for note
430430
val expectedTags = n.tags
431-
val response = getDataFromRequest("getNoteTags", jsapi, jsonObjectOf("noteId" to n.id))
431+
val response = getDataFromRequest("getNoteTags", jsapi)
432432
val jsonResponse = JSONObject(response)
433433
val actualTags = JSONArray(jsonResponse.getString("value"))
434434

0 commit comments

Comments
 (0)