dreautall / waterfly-iii

Unofficial Android App for Firefly III, a free and open source personal finance manager.
MIT License
371 stars 30 forks source link

[Feature request] Offline transactions? #27

Open SekoiaTree opened 1 year ago

SekoiaTree commented 1 year ago

Currently it seems like it's impossible to make a transaction without internet. This totally makes sense, but personally I often don't have data as I'm doing a transaction (I don't have a data plan).

This is probably quite hard to implement, since you need to figure out when to submit further transactions etc.. But I'd be really grateful!

Thank you for the great app!

LucasSaliba commented 1 year ago

I was able to do that using https://github.com/cyxou/firefly-iii-telegram-bot

watertrainer commented 9 months ago

Would wrapping this function in a helper
https://github.com/dreautall/waterfly-iii/blob/0fa7b62a7631fd6232d7c71b8c149908086d39bc/lib/generated/swagger_fireflyiii_api/firefly_iii.swagger.dart#L5064-L5075 storing the transactions if the future was unsuccsesfull using https://pub.dev/packages/flutter_secure_file_storage would make storing transactions possible, wouldn't it? I'm not too sure what the best play is regarding uploading. Having the app try to sync while running seems like wasted resources, maybe posting a notification and asking the user when to sync?

dreautall commented 9 months ago

You could upload on a successful app startup (since this requires internet), as an idea.

You need quite a few fallbacks/function wrappings, as the complete transaction page relies on internet (Autocomplete etc.). Some needed stuff like currencies or own bank accounts are currently not stored within the app but absolutely required for creating transactions.

Also, starting the app without internet would need to show an "add transaction" button as well.

watertrainer commented 9 months ago

I'm still trying to figure out how to detect if the application is online or offline, so it can decide in which "mode" to start the transaction page (and maybe even other pages in the future). Detecting for a positive connection is quite easy, as you can just update on each succsessfull response in the chopper response interceptor. I couldn't find an easy way to check for a disconnect though, there are two possibilities I saw, which I'm not to sure which one to pick:

  1. There could be wrapper for all api calls, which detects disconnection by calling on error on all the futures. Many api calls would need a wrapper anyway to return the stored values, so the extra code wouldn't be as big, but there would probably still be lots of exxra code
  2. Something like this https://stackoverflow.com/questions/49648022/check-whether-there-is-an-internet-connection-available-on-flutter-app, which would be easier (changing google.com to the firefly url), but adding a extra dependency.
dreautall commented 8 months ago

Hi, sorry for my late reply - I was out the last two weeks and not in front of my computer.

The name resolution thing ("one-time check" here: https://stackoverflow.com/a/56959146) might be a sensible way to go, but maybe just for the "important" API calls, e.g. check on saving a transaction.

What might be more troubling is detecting being back online and handling conflicts etc.