forked from github/wulkanowy-mirror
Use userLoginId to differentiate saved mobiles devices between accounts (#1076)
This commit is contained in:
parent
a1d4b3d19e
commit
8ce59a3098
@ -8,6 +8,6 @@ import kotlinx.coroutines.flow.Flow
|
||||
@Dao
|
||||
interface MobileDeviceDao : BaseDao<MobileDevice> {
|
||||
|
||||
@Query("SELECT * FROM MobileDevices WHERE student_id = :studentId ORDER BY date DESC")
|
||||
fun loadAll(studentId: Int): Flow<List<MobileDevice>>
|
||||
@Query("SELECT * FROM MobileDevices WHERE student_id = :userLoginId ORDER BY date DESC")
|
||||
fun loadAll(userLoginId: Int): Flow<List<MobileDevice>>
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import java.time.LocalDateTime
|
||||
data class MobileDevice(
|
||||
|
||||
@ColumnInfo(name = "student_id")
|
||||
val studentId: Int,
|
||||
val userLoginId: Int,
|
||||
|
||||
@ColumnInfo(name = "device_id")
|
||||
val deviceId: Int,
|
||||
|
@ -8,7 +8,7 @@ import io.github.wulkanowy.sdk.pojo.Device as SdkDevice
|
||||
|
||||
fun List<SdkDevice>.mapToEntities(semester: Semester) = map {
|
||||
MobileDevice(
|
||||
studentId = semester.studentId,
|
||||
userLoginId = semester.studentId,
|
||||
date = it.createDate,
|
||||
deviceId = it.id,
|
||||
name = it.name
|
||||
|
@ -27,7 +27,7 @@ class MobileDeviceRepository @Inject constructor(
|
||||
|
||||
fun getDevices(student: Student, semester: Semester, forceRefresh: Boolean) = networkBoundResource(
|
||||
shouldFetch = { it.isEmpty() || forceRefresh || refreshHelper.isShouldBeRefreshed(getRefreshKey(cacheKey, student)) },
|
||||
query = { mobileDb.loadAll(semester.studentId) },
|
||||
query = { mobileDb.loadAll(student.userLoginId.takeIf { it != 0 } ?: student.studentId) },
|
||||
fetch = {
|
||||
sdk.init(student).switchDiary(semester.diaryId, semester.schoolYear)
|
||||
.getRegisteredDevices()
|
||||
|
Loading…
x
Reference in New Issue
Block a user