Adding a method to retrieve livedata of crypto device info for a given device id
This commit is contained in:
		
							parent
							
								
									f74a0b0901
								
							
						
					
					
						commit
						e542dc4aac
					
				@ -122,6 +122,8 @@ interface CryptoService {
 | 
			
		||||
 | 
			
		||||
    fun getLiveCryptoDeviceInfo(): LiveData<List<CryptoDeviceInfo>>
 | 
			
		||||
 | 
			
		||||
    fun getLiveCryptoDeviceInfoWithId(deviceId: String): LiveData<Optional<CryptoDeviceInfo>>
 | 
			
		||||
 | 
			
		||||
    fun getLiveCryptoDeviceInfo(userId: String): LiveData<List<CryptoDeviceInfo>>
 | 
			
		||||
 | 
			
		||||
    fun getLiveCryptoDeviceInfo(userIds: List<String>): LiveData<List<CryptoDeviceInfo>>
 | 
			
		||||
 | 
			
		||||
@ -534,6 +534,10 @@ internal class DefaultCryptoService @Inject constructor(
 | 
			
		||||
        return cryptoStore.getLiveDeviceList()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    override fun getLiveCryptoDeviceInfoWithId(deviceId: String): LiveData<Optional<CryptoDeviceInfo>> {
 | 
			
		||||
        return cryptoStore.getLiveDeviceWithId(deviceId)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    override fun getLiveCryptoDeviceInfo(userId: String): LiveData<List<CryptoDeviceInfo>> {
 | 
			
		||||
        return cryptoStore.getLiveDeviceList(userId)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -238,6 +238,8 @@ internal interface IMXCryptoStore {
 | 
			
		||||
    // TODO temp
 | 
			
		||||
    fun getLiveDeviceList(): LiveData<List<CryptoDeviceInfo>>
 | 
			
		||||
 | 
			
		||||
    fun getLiveDeviceWithId(deviceId: String): LiveData<Optional<CryptoDeviceInfo>>
 | 
			
		||||
 | 
			
		||||
    fun getMyDevicesInfo(): List<DeviceInfo>
 | 
			
		||||
 | 
			
		||||
    fun getLiveMyDevicesInfo(): LiveData<List<DeviceInfo>>
 | 
			
		||||
 | 
			
		||||
@ -581,6 +581,12 @@ internal class RealmCryptoStore @Inject constructor(
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    override fun getLiveDeviceWithId(deviceId: String): LiveData<Optional<CryptoDeviceInfo>> {
 | 
			
		||||
        return Transformations.map(getLiveDeviceList()) { devices ->
 | 
			
		||||
            devices.firstOrNull { it.deviceId == deviceId }.toOptional()
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    override fun getMyDevicesInfo(): List<DeviceInfo> {
 | 
			
		||||
        return monarchy.fetchAllCopiedSync {
 | 
			
		||||
            it.where<MyDeviceLastSeenInfoEntity>()
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user