@@ -1399,12 +1399,22 @@ class SteamService : Service(), IChallengeUrlChanged {
1399
1399
// Timber.d("Adding ${appToAdd?.name} with appId of ${appToAdd?.id} and pkgId of ${appToAdd?.packageId}")
1400
1400
1401
1401
val appIds = picsChangesCallback.appChanges.values
1402
- .filter { it.changeNumber != appDao.findApp(it.id).first()?.lastChangeNumber }
1402
+ .filter { changeData ->
1403
+ // only queue PICS requests for apps existing in the db that have changed
1404
+ appDao.findApp(changeData.id).first()?.let {
1405
+ changeData.changeNumber != it.lastChangeNumber
1406
+ } == true
1407
+ }
1403
1408
.map { AppRequest (it.id) }.toTypedArray()
1404
1409
queueAppPICSRequests(* appIds)
1405
1410
1406
1411
val pkgsWithChanges = picsChangesCallback.packageChanges.values
1407
- .filter { it.changeNumber != licenseDao.findLicense(it.id).first()?.lastChangeNumber }
1412
+ .filter { changeData ->
1413
+ // only queue PICS requests for pkgs existing in the db that have changed
1414
+ licenseDao.findLicense(changeData.id).first()?.let {
1415
+ changeData.changeNumber != it.lastChangeNumber
1416
+ } == true
1417
+ }
1408
1418
val pkgsForAccessTokens = pkgsWithChanges.filter { it.isNeedsToken }.map { it.id }
1409
1419
val accessTokens = _steamApps ?.picsGetAccessTokens(
1410
1420
emptyList(),
@@ -1624,7 +1634,10 @@ class SteamService : Service(), IChallengeUrlChanged {
1624
1634
if (callback.result == EResult .OK ) {
1625
1635
dbScope.launch {
1626
1636
// check first if any apps already exist in the db that need PICS
1627
- val apps = appDao.getAllAppsWithoutPICS().firstOrNull()?.map { AppRequest (it.id) }?.toTypedArray()
1637
+ val apps = appDao.getAllOwnedAppsWithoutPICS(userSteamId!! .accountID.toInt())
1638
+ .firstOrNull()
1639
+ ?.map { AppRequest (it.id) }
1640
+ ?.toTypedArray()
1628
1641
Timber .d(" ${apps?.size ? : 0 } app(s) need PICS" )
1629
1642
if (apps?.isNotEmpty() == true ) {
1630
1643
queueAppPICSRequests(* apps)
@@ -1698,13 +1711,17 @@ class SteamService : Service(), IChallengeUrlChanged {
1698
1711
licenseDao.updateApps(pkg.id, appIds)
1699
1712
licenseDao.updateDepots(pkg.id, depotIds)
1700
1713
1701
- val steamAppsToAdd = appIds.map { appId ->
1702
- appDao.findApp(appId).first()?.copy(packageId = pkg.id)
1703
- ? : SteamApp (id = appId, packageId = pkg.id)
1704
- }.toTypedArray()
1705
- appDao.insert(* steamAppsToAdd)
1714
+ val license = licenseDao.findLicense(pkg.id).first()
1715
+ // only add the apps belonging to the license if the user owns it
1716
+ if (license?.ownerAccountId == userSteamId?.accountID?.toInt()) {
1717
+ val steamAppsToAdd = appIds.map { appId ->
1718
+ appDao.findApp(appId).first()?.copy(packageId = pkg.id)
1719
+ ? : SteamApp (id = appId, packageId = pkg.id)
1720
+ }.toTypedArray()
1706
1721
1707
- queueAppPICSRequests(* appIds.map { AppRequest (it) }.toTypedArray())
1722
+ appDao.insert(* steamAppsToAdd)
1723
+ queueAppPICSRequests(* appIds.map { AppRequest (it) }.toTypedArray())
1724
+ }
1708
1725
}
1709
1726
}
1710
1727
0 commit comments