Deprecate noteId var from getNoteTags in Js-API#18624
Deprecate noteId var from getNoteTags in Js-API#18624mikehardy merged 1 commit intoankidroid:mainfrom
Conversation
|
It would be useful to know where the method went And leave an extra line between the title and the first line of the message |
would this work? Index: AnkiDroid/src/main/assets/scripts/js-api.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/AnkiDroid/src/main/assets/scripts/js-api.js b/AnkiDroid/src/main/assets/scripts/js-api.js
--- a/AnkiDroid/src/main/assets/scripts/js-api.js (revision 18d14c2dec2f3bb15d03ffd6ebe06c291fcd4c22)
+++ b/AnkiDroid/src/main/assets/scripts/js-api.js (date 1750793826077)
@@ -130,6 +130,7 @@
}
if (method === "ankiSetNoteTags") {
AnkiDroidJS.prototype[method] = async function (noteId, tags) {
+ console.warn("ankiSetNoteTags: The noteId parameter is deprecated and will be ignored. The method now uses the current card's note ID automatically.");
let hasSpaces = false;
for (let i = 0; i < tags.length; i++) {
tags[i] = tags[i].trim();
@@ -147,8 +148,28 @@
};
return;
}
+ if (method === "ankiSetNoteTags") {
+ AnkiDroidJS.prototype[method] = async function (tags) {
+ let hasSpaces = false;
+ for (let i = 0; i < tags.length; i++) {
+ tags[i] = tags[i].trim();
+ if (tags[i].includes(" ") || tags[i].includes("\u3000")) {
+ tags[i] = tags[i].replace(" ", "_").replace("\u3000", "_");
+ hasSpaces = true;
+ }
+ }
+ if (hasSpaces) {
+ console.warn("Spaces in tags have been converted to underscores");
+ }
+ const endpoint = jsApiList[method];
+ const data = JSON.stringify({ tags });
+ return await this.handleRequest(endpoint, data);
+ };
+ return;
+ }
if (method === "ankiGetNoteTags") {
AnkiDroidJS.prototype[method] = async function (noteId) {
+ console.warn("ankiGetNoteTags: The noteId parameter is deprecated and will be ignored. The method now uses the current card's note ID automatically.");
const endpoint = jsApiList[method];
const data = JSON.stringify({ noteId });
return await this.handleRequest(endpoint, data);I think it might be better to do it this way, so as to not directly break anyone's decks, it follows the same |
|
It's alpha functionality which we're removing. No need for complexity. The only change should be in the commit message, making it immediately clear to a reader whether the method was removed, or just refactored to less code |
Now consistent with other methods: the currently selected note is used * Stop special-casing `ankiGetNoteTags` as no params are needed * Adjust Object.keys usage accordingly * Move jsonObjectOf to JsonUtils.kt Issue 17716 Co-authored-by: David Allison <62114487+david-allison@users.noreply.github.com>
david-allison
left a comment
There was a problem hiding this comment.
I fixed up the commit message to reduce the back/forth required.
As I force pushed, PR changes are on me to resolve
Didn't know commit messages can be that long. |
|
No length limit, have some 'long' ones: |
Purpose / Description
Fixes
How Has This Been Tested?
Fixed UnitTests
Checklist