
The absence of a loading spinner in the ADAMANT header guarantees that the user is viewing the latest list of chats and messages. The spinner should be shown if there is no internet connection, no active ADM nodes, or no enabled ADM nodes.
When a connection and active nodes exist, the system checks further. Upon receiving fresh messages—meaning no newer ones exist—it saves a timestamp chatActualUntil in the store.
const chatsActualUntil = adamant.toTimestamp(nodeTimestamp) + INTERVAL + CHAT_ACTUALITY_BUFFER_MS
The INTERVAL represents the polling interval for new chats over REST, which varies depending on whether a socket connection is available.
INTERVAL: (state, getters, rootState) => {
return rootState.options.useSocketConnection ? SOCKET_ENABLED_TIMEOUT : SOCKET_DISABLED_TIMEOUT
},
The Chat and Chat List screens observe chatActualUntil and subscribe to the hook chatActual = chatActualUntil > currentTime. This hook runs every 500 milliseconds to trigger the spinner even if chatActualUntil has not changed due to a lack of new messages. Ultimately, the spinner is displayed if there is no internet, no nodes online, or if !chatActual evaluates to true.
When the app is restored from the background, no tweaks are needed because it still relies on chatActualUntil. If the device time exceeds the chat validity timestamp, the user will see the spinner. In the worst case, if the connection is lost, the user might not see the spinner and could mistakenly believe everything is up-to-date for a maximum duration of INTERVAL + CHAT_ACTUALITY_BUFFER_MS seconds.