Skip to content

Commit

Permalink
Merge branch 'feat/server-get' into 'master'
Browse files Browse the repository at this point in the history
Do not use cache for PartyRepository::get()

See merge request fmasa/wfrp-master!191
  • Loading branch information
fmasa committed Feb 7, 2021
2 parents 40bcb40 + 1254935 commit e803e50
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cz.frantisekmasa.wfrp_master.core.firestore.repositories
import com.google.firebase.firestore.FirebaseFirestore
import com.google.firebase.firestore.FirebaseFirestoreException
import com.google.firebase.firestore.SetOptions
import com.google.firebase.firestore.Source
import cz.frantisekmasa.wfrp_master.core.connectivity.CouldNotConnectToBackend
import cz.frantisekmasa.wfrp_master.core.domain.party.Party
import cz.frantisekmasa.wfrp_master.core.domain.party.PartyId
Expand Down Expand Up @@ -40,7 +41,7 @@ import timber.log.Timber

override suspend fun get(id: PartyId): Party {
try {
val party = parties.document(id.toString()).get().await()
val party = parties.document(id.toString()).get(Source.SERVER).await()
return this.mapper.fromDocumentSnapshot(party)
} catch (e: FirebaseFirestoreException) {
throw PartyNotFound(id, e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ import kotlinx.coroutines.flow.Flow
*/
suspend fun save(characterId: CharacterId, item: InventoryItem)

/**
* Returns specified InventoryItem or throws an exception.
*
* @throws InventoryItemNotFound when inventory item does not exist.
*/
suspend fun get(characterId: CharacterId, itemId: InventoryItemId): InventoryItem

/**
* Removes item from inventory or does nothing if given item is not in user's inventory
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,6 @@ internal class FirestoreInventoryItemRepository(
.await()
}

override suspend fun get(characterId: CharacterId, itemId: InventoryItemId): InventoryItem {
try {
return mapper.fromDocumentSnapshot(
inventoryItems(characterId)
.document(itemId.toString())
.get()
.await()
)
} catch (e: FirebaseFirestoreException) {
throw InventoryItemNotFound(itemId, characterId, e)
}
}

override suspend fun remove(characterId: CharacterId, itemId: InventoryItemId) {
inventoryItems(characterId).document(itemId.toString()).delete().await()
}
Expand Down

0 comments on commit e803e50

Please sign in to comment.