Skip to content

Added methods to convert gkeepapi.node.Note to gkeepapi.node.List and gkeepapi.node.List to gkeepapi.node.Note#165

Open
kyrlon wants to merge 1 commit intokiwiz:mainfrom
kyrlon:main
Open

Added methods to convert gkeepapi.node.Note to gkeepapi.node.List and gkeepapi.node.List to gkeepapi.node.Note#165
kyrlon wants to merge 1 commit intokiwiz:mainfrom
kyrlon:main

Conversation

@kyrlon
Copy link
Copy Markdown

@kyrlon kyrlon commented Apr 18, 2024

Fixes #122. Added methods roughly outlined in the issue

@kyrlon kyrlon changed the title Added methods to convert a gkeepapi.node.Note to gkeepapi.node.List and gkeepapi.node.List to gkeepapi.node.Note Added methods to convert gkeepapi.node.Note to gkeepapi.node.List and gkeepapi.node.List to gkeepapi.node.Note Apr 18, 2024
@kiwiz
Copy link
Copy Markdown
Owner

kiwiz commented May 28, 2024

Thanks for the PR. The (official) clients preserve the ID when converting between List/Note. IIRC, that was what made implementing this feature complicated.

The code needs to:

  • Convert the body ✅
  • Preserve the metadata
  • Replace the existing List/Note that the Keep instance knows about

The last item is tricky as individual Nodes don't contain a reference to the Keep instance. This is why ListItems aren't visible to the Keep until they've been synced.

Our options:

  • Use the implementation in the PR and add a note to "Known Issues".
  • Refactor the code to inject a reference to the Keep instance within every Node.
@kyrlon
Copy link
Copy Markdown
Author

kyrlon commented Jun 1, 2024

Interesting. The latter option sounds like a challenge, but with your guidance I am up for it. Would this be some variant of dependency injection?

@kiwiz
Copy link
Copy Markdown
Owner

kiwiz commented Jun 5, 2024

Hmm, perhaps we can get around this by making it a method on the Keep object like so:

list_ = keep.to_list(note) note = keep.to_note(list)

That looks kind of odd though. I think the crux of the issue is: Does a user expect a converted Note/List to retain all its metadata?

@kyrlon
Copy link
Copy Markdown
Author

kyrlon commented Jun 11, 2024

Hmm that does look peculiar. Is it possible to make the reference to the keep instance optional?

@kyrlon
Copy link
Copy Markdown
Author

kyrlon commented Nov 4, 2025

How about we can add a replace=True (default) param for advanced use cases (e.g. convert_to_list(..., replace=False) to get a new ID).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants