donmor / Tiddloid

Tiddloid is an app to work with locally stored TiddlyWikis.
GNU General Public License v2.0
234 stars 10 forks source link

[Problem] Remote wiki isn't cached offline #47

Closed andrigamerita closed 7 months ago

andrigamerita commented 1 year ago

Hi, I found this app while looking for a better way to use TiddlyWiki on my Android.
I don't know if this is a bug or just a missing feature, but the remote (import from an URL) wiki feature doesn't work properly.

I added my wiki from GitLab Pages, and while my device is connected to the Internet I can use it fine. If I close the wiki (get back to the main menu) but the app remains in RAM, I can even reopen the wiki without an Internet connection.
However, if the app gets closed, then the wiki will refuse to open again if I don't have Internet: I get the Android webview error screen saying the server is unreachable (and a Tiddloid popup saying the wiki doesn't exist anymore online, and asking me if I want to remove it).

Tiddloid should cache the HTML files of the remote wiki in the device storage for offline availability. On open, it should check if the server is reachable, and if so, it downloads the file from that. If the server isn't reachable, then the latest cached HTML file gets loaded instead, and all the saves get saved locally.
TiddlyWiki will of course be unable to sync changes remotely in this state, so Tiddloid should set a flag to make it possible for the wiki to sync the next time there is Internet; for example, the very next time there is Internet, it's still the local HTML file that gets loaded, so that one has a chance of letting TiddlyWiki sync changes. Exposing a button in the app's status bar to switch between latest cached version and online version would also work fine, if the all-automatic solution is too unreliable.

For some extra context: I have my wiki configured to sync changes to GitLab, and this works fine even in Tiddloid. My device is a tablet running armv7 Android 8.1.0 (Samsung Experience 9.5). I run the latest APK of Tiddloid downloaded from the Releases of this repo.

Thanks for your time!

donmor commented 1 year ago

Fun fact: You can save a copy of your wiki to a local file at any time lol

andrigamerita commented 1 year ago

How do you do that?

On the menu screen if I long-press the wiki I can only "Remove" and "Create a shortcut". The only other button is "Clone" but it's grayed out, it doesn't press. Also the 2 checkboxes ("Default Wiki" and "Enable backup") are grayed out.

In the wiki screen, when I open my wiki, I only see a Back button and a "Save changes" one.

After a bit of testing I've seen that manually pressing "Save changes" seems to cache the wiki offline permanently only some times. Sometimes it works and I can open it without Internet even after closing the app. Other times it doesn't work and I can't open the wiki without Internet after clearing recent apps, for example.

I just now also noted that, while maybe the initial file does get cached some times, changes are not saved locally. If I open the wiki, press save without Internet, then close the wiki and reopen it, I see that all I've done wasn't saved, and I only see things as they were when I had Internet.

I suspect that the internal Git saving is causing problems. When that is enabled, in a normal web browser download-type saves don't happen anymore. And if your app internally relies on listening for file download triggers, then of course things don't work.

If that's the case, I should probably either make an issue to TiddlyWiki, or try to hack in myself something for making so that, when Git saving is enabled, if saving online fails (no Internet) then a file download is triggered.

donmor commented 1 year ago

We didn't use Git at all... Bookmarks stores only source URL, just like what a browser do. Clicking "Save changes" actually clones the wiki to a local file. Recently I found some bugs of IO logic and the whole app is being refactored now.

donmor commented 1 year ago

Okay I uploaded 2.3.0 to GitHub/Gitee/CoolApk (F-droid version needs some time to be built). Try it and let me know if it ceased your problem.

donmor commented 1 year ago

Does anyone still have problem? I may close this if no problem reported.