Many of our errors in production are caused
by the alarm module finishing. In devices after
android version 7 we are "required" to use
startForegroundService or else the following
error supposedly occurs:
Exception java.lang.IllegalStateException:
at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1725)
at android.app.ContextImpl.startService (ContextImpl.java:1680)
at android.content.ContextWrapper.startService (ContextWrapper.java:731)
at android.content.ContextWrapper.startService (ContextWrapper.java:731)
at com.massive.AlarmModule$getTimer$1.onFinish (AlarmModule.kt:144)
at android.os.CountDownTimer$1.handleMessage (CountDownTimer.java:127)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:236)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:228)
at java.lang.Thread.run (Thread.java:923)
I say supposedly because on all of my testing
devices (which are android 7+) this error
doesn't occur.
This bug is because I mis-named the event for the alarm finishing.
It would only be possible to create this bug if you do the following:
1. Create a timer
2. Swap to another app for it's duration and keep your phone screen
active
3. On timer completion, without tapping the notification, focus the app
4. See the timer has not been set to zero
The App.tsx had a bunch of separate useState calls which would
cause unneccesary re-renders of the entire app. This became
apparent after adding the global progress bar, since it caused
even more re-renders to the point of being unusable.
The code before needlessly factored out functions in functions
and made it impossible to read and change. Also it wasn't using a
FlatList which is a performance problem.
I tried to maintain the current scroll position
within a list however this caused many issues
to do with outdated data, as well as performance issues.
Now we are going back to just refreshing any list on focus.
Closes#184