erikbrinkman / rmapi-js

JavaScript implementation of the reMarkable api
https://erikbrinkman.github.io/rmapi-js/modules.html
MIT License
9 stars 1 forks source link

Document/Collection deleted/parent information #10

Closed Bartek532 closed 6 months ago

Bartek532 commented 7 months ago

How could I receive information if documents or collections were deleted or they're in the trash?

Currently, when I call getEntriesMetadata, I only receive the following properties: id, hash, type, visibleName, pinned, and lastModified, while deleted and parent are undefined.

Thanks in advance!

Bartek532 commented 7 months ago

It's also strange that when I created a folder then deleted it and called getEntriesMetadata I'm still getting it back, but I shouldn't 🤔

Bartek532 commented 7 months ago

Also when I created folder in the app/device, I can't see it as a result of getEntriesMetadata which is at least weird.

erikbrinkman commented 7 months ago

I don't observe the same behavior you do, but in general these api's aren't documented or stable, so you'll have to check trial and error.

In general, when things get deleted, they get a special parent hash "trash". At least, that's what I see. If that doesn't work, I would try first getting the root entries, and then getting metadata from there, similar to what's shown here.

You should get back deleted things because they're in the trash. Maybe you also deleted it from the trash, although that might be marked in some other way.

I don't know why you don't see created folders. I do, but in general, I'd rely more on getEntries than getEntriesMetadata as I'm not sure what they're doing with that newer api.

Bartek532 commented 7 months ago

So is getEntriesMetadata working fine for you? I tried with getEntries and seems to be working, but it's taking a lot more time with all promises to fulfill 😕 Any chance for update to newer API?

erikbrinkman commented 7 months ago

getEntriesMetadata seems to work for me, but it may not be updating regularly. Remember, I don't work for reMarkable, I can't change how they handle the requests, just make it slightly easier to do what their requests allow.

If the old api is slow or your purposes, you should try using the cache. The first time you do anything it will be close, but if you persist the cache with cache = await api.getCache() and them re-initialize with remarkable(token, { initCache = cache }) only the updates files should require refetching, which should speed things up considerably.

Bartek532 commented 7 months ago

Sure, thanks, will try!

Btw, could you please take a look on how I'm currently using this API? Maybe there is something that I could do better to accomplish faster and more reliable action? Thanks in advance!

https://github.com/Bartek532/rssmarkable/blob/main/apps/sync/src/device/remarkable/remarkable.strategy.ts

erikbrinkman commented 6 months ago

this looks about right. I considered adding something to make publishing the root hash more convenient, but it quickly involved making my own filesystem wrapper and having an api around that, as well as how to manage collisions, and that ultimately seemed like too much work. Sorry I can't offer more advice!