Skip to content

Commit

Permalink
Fixes #31
Browse files Browse the repository at this point in the history
  • Loading branch information
IzHoBX committed Jul 2, 2020
1 parent bbc8c88 commit 6687a19
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/src/main/java/com/izho/saveentry/data/Database.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import androidx.sqlite.db.SupportSQLiteDatabase

@Dao
interface AppDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
@Insert(onConflict = OnConflictStrategy.IGNORE)
suspend fun insertLocation(location: Location): Long

@Insert(onConflict = OnConflictStrategy.REPLACE)
Expand Down Expand Up @@ -53,6 +53,9 @@ interface AppDao {

@Query("SELECT * FROM visit WHERE check_out_at IS NULL AND location_id = :locationId")
fun getActiveVisitWithLocationId(locationId:String) : LiveData<List<VisitWithLocation>>

@Query("UPDATE location SET organization = :organization, venue_name = :venueName WHERE location_id = :location_id")
fun updateLocationNames(venueName:String, organization:String, location_id:String)
}

@Database(entities = [Location::class, Visit::class], version = 3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class CheckInOrOutViewModel(app: Application,
info?.let {
_currentLocation.postValue(
Location(locationId, info.entityName, info.venueName, url))
database.dao.updateLocationNames(info.venueName, info.entityName, locationId)
}
}
} catch (e:Throwable) {
Expand Down

0 comments on commit 6687a19

Please sign in to comment.