-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
JS function to setTags and getTags #17795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@david-allison Do you think we should deprecate addTagToNote? Also [set/replace]NoteTags triggers lint failure |
mikehardy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we should deprecate addTagToNote
Yes - haven't done our deprecation strategy in a while, not sure exactly how. Is it documented anywhere? May not be, but we should be able to mark something as deprecated and have it emit a warning in console or similar
This comment was marked as spam.
This comment was marked as spam.
783f9fa to
36e8da6
Compare
From some searching, the most I can find is the deprecated decorator on Kotlin side, I dunno how we would approach on js. Is there official documentation for JS api? if not we can just have a comment? |
Hey! Can you you elaborate further? |
|
@Mizokuiam please stop. You are wasting everyone's time. |
Spammer? :( |
|
@Haz3-jolt I assume so. Negative value contributions, banned at organization level by me now. |
|
@mikehardy How is this for a deprecation warning? Since people mainly interact on Js side Subject: [PATCH] JS function to setTags and getTags
---
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 6d3d270e9067fbad4797f25b0f3060adc60e41cd)
+++ b/AnkiDroid/src/main/assets/scripts/js-api.js (date 1736620228061)
@@ -121,6 +121,7 @@
Object.keys(jsApiList).forEach(method => {
if (method === "ankiAddTagToNote") {
AnkiDroidJS.prototype[method] = async function (noteId, tag) {
+ console.warn("ankiAddTagToNote is deprecated. Use ankiSetNoteTags instead.");
const endpoint = jsApiList[method];
const data = JSON.stringify({ noteId, tag });
return await this.handleRequest(endpoint, data); |
|
@Haz3-jolt I believe that deprecation in javascript console is the correctly location for it |
Amend the current commit or separate commit? |
|
amend I think, the deprecation of the old is part of adding the new to me, it's all one piece |
Cool! |
This comment was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
4b7ec2b to
5b2f5bc
Compare
david-allison
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be the last one!
|
@david-allison Any other changes? Ive double checked that both functions are working. |
|
@david-allison although I don't think I can do it rn, any idea on how a integration test for the setTags can be done? Perhaps setting a note with the Js function in the note, and using espresso to find the button or something? |
|
@david-allison should I re base and force push to check if any conflicts are there? its been a while since this PR has been open |
Okay so looks like no conflicts |
|
The PR will display conflicts if there are any (and it'll have Has Conflicts ) If it's sat for a while, a rebase saves a little time on our end |
david-allison
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cheers!
lukstbit
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM. Please squash the two commits into one and then this can be merged.
Iirc @mikehardy and @david-allison agreed seprate commits might be better because it's adding the calls and unit tests for it in a seperate commit. But yeah I'm fine with squash merge as well. |
Purpose / Description
Adds two JS API functions [set/replace]NoteTags and getTagsFromNote which act similar to PUT and GET from a REST API
Fixes
Approach
Adds two methods to allow the caller to get Tags and update/set tags.
How Has This Been Tested?
Added two unit tests both verified and passing.
Checklist
Please, go through these checks before submitting the PR.