Ashinch / ReadYou

An Android RSS reader presented in Material You style.
GNU General Public License v3.0
5.12k stars 202 forks source link

Cannot fetch theoldreader data #691

Open dddaniel1 opened 7 months ago

dddaniel1 commented 7 months ago

1. Environment Device: K40pro OS: Android 13 APP: 0.9.12 2. Describe the bug Cannot fetch theoldreader data, report list is empty.

equeim commented 1 month ago

@Ashinch It seems that the issue is that the app does not expected feed categories to be empty, it fails here (in first() call):

https://github.com/Ashinch/ReadYou/blob/24087803b1211b269253238dd0f6cb6af1a577b4/app/src/main/java/me/ash/reader/domain/service/GoogleReaderRssService.kt#L242

Replacing it with firstOrNull() and also skipping feeds with null category in forEach instead of throwing with requireNotNull fixes this issue.

However it still doesn't work because of issues with article ids. It seems that these ids can be used in two forms - hexadecimal (as they come from API) and decimal (as they are saved in DB), and there are cases where they are not converted as they should. For example here: https://github.com/Ashinch/ReadYou/blob/24087803b1211b269253238dd0f6cb6af1a577b4/app/src/main/java/me/ash/reader/domain/service/GoogleReaderRssService.kt#L364

readIds and unreadIds are hexadecimal, while localReadIds are decimal. It doesn't seem right since they are compared to each other. It then causes another exception since fetchItemsContents tried to parse them as decimal numbers which fails (also toLong() calls can fail when number is too big in which case toBigDecimal can be used).

I think it would a good idea to introduce strongly typed value classes for hexadecimal and decimal ids, so that compiler would prevent using them wrongly without conversion. Or even better, just save them in hexadecimal from in DB (IDK why they are converted to decimal form).