Resolves#404. The issue seems to be that the server expects that when syncing an open (streamed) session, the attribute timeListened to be time since the last sync to the server (as per the API docs). But the app uses that logic to store timeListened offline as well, so updates it cumulatively and sends that to the server where the time is compounded. This explains why the listening sessions seemed only slightly off for a few seconds of listening, but exponentially huge (thousands of hours) for longer streamed listens. This PR just adds a bit of logic to reset that timeListening attribute each time there is a server sync when the book is being streamed. I did some testing both with downloaded and local books and the listening time now seems to be reported accurately.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/advplyr/audiobookshelf-app/pull/456
**Author:** [@benonymity](https://github.com/benonymity)
**Created:** 12/7/2022
**Status:** ✅ Merged
**Merged:** 12/7/2022
**Merged by:** [@advplyr](https://github.com/advplyr)
**Base:** `master` ← **Head:** `listeningStatsFix`
---
### 📝 Commits (1)
- [`d3c6429`](https://github.com/advplyr/audiobookshelf-app/commit/d3c6429fd614c3f5d50b1edb12af246964b296d5) fix: accurate time for streamed sessions
### 📊 Changes
**1 file changed** (+8 additions, -0 deletions)
<details>
<summary>View changed files</summary>
📝 `ios/App/Shared/player/PlayerProgress.swift` (+8 -0)
</details>
### 📄 Description
Resolves #404. The issue seems to be that the server expects that when syncing an open (streamed) session, the attribute `timeListened` to be time since the last sync to the server (as per the [API docs](https://api.audiobookshelf.org/#sync-an-open-session)). But the app uses that logic to store timeListened offline as well, so updates it cumulatively and sends that to the server where the time is compounded. This explains why the listening sessions seemed only slightly off for a few seconds of listening, but exponentially huge (thousands of hours) for longer streamed listens. This PR just adds a bit of logic to reset that timeListening attribute each time there is a server sync when the book is being streamed. I did some testing both with downloaded and local books and the listening time now seems to be reported accurately.
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/advplyr/audiobookshelf-app/pull/456
Author: @benonymity
Created: 12/7/2022
Status: ✅ Merged
Merged: 12/7/2022
Merged by: @advplyr
Base:
master← Head:listeningStatsFix📝 Commits (1)
d3c6429fix: accurate time for streamed sessions📊 Changes
1 file changed (+8 additions, -0 deletions)
View changed files
📝
ios/App/Shared/player/PlayerProgress.swift(+8 -0)📄 Description
Resolves #404. The issue seems to be that the server expects that when syncing an open (streamed) session, the attribute
timeListenedto be time since the last sync to the server (as per the API docs). But the app uses that logic to store timeListened offline as well, so updates it cumulatively and sends that to the server where the time is compounded. This explains why the listening sessions seemed only slightly off for a few seconds of listening, but exponentially huge (thousands of hours) for longer streamed listens. This PR just adds a bit of logic to reset that timeListening attribute each time there is a server sync when the book is being streamed. I did some testing both with downloaded and local books and the listening time now seems to be reported accurately.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.