[Client] Fix directChat db
This commit is contained in:
		
							parent
							
								
									37866359be
								
							
						
					
					
						commit
						c04a3debe4
					
				|  | @ -123,14 +123,22 @@ class Client { | ||||||
| 
 | 
 | ||||||
|   /// Returns the (first) room ID from the store which is a private chat with the user [userId]. |   /// Returns the (first) room ID from the store which is a private chat with the user [userId]. | ||||||
|   /// Returns null if there is none. |   /// Returns null if there is none. | ||||||
|   String getDirectChatFromUserId(String userId) => accountData["m.direct"] != |   String getDirectChatFromUserId(String userId) { | ||||||
|               null && |     if (accountData["m.direct"] != null && | ||||||
|         accountData["m.direct"].content[userId] is List<dynamic> && |         accountData["m.direct"].content[userId] is List<dynamic> && | ||||||
|           accountData["m.direct"].content[userId].length > 0 && |         accountData["m.direct"].content[userId].length > 0) { | ||||||
|           roomList.getRoomById(accountData["m.direct"].content[userId][0]) != |       if (roomList.getRoomById(accountData["m.direct"].content[userId][0]) != | ||||||
|               null |           null) return accountData["m.direct"].content[userId][0]; | ||||||
|       ? accountData["m.direct"].content[userId][0] |       (accountData["m.direct"].content[userId] as List<dynamic>) | ||||||
|       : null; |           .remove(accountData["m.direct"].content[userId][0]); | ||||||
|  |       connection.jsonRequest( | ||||||
|  |           type: HTTPType.PUT, | ||||||
|  |           action: "/client/r0/user/${userID}/account_data/m.direct", | ||||||
|  |           data: directChats); | ||||||
|  |       return getDirectChatFromUserId(userId); | ||||||
|  |     } | ||||||
|  |     return null; | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   /// Checks the supported versions of the Matrix protocol and the supported |   /// Checks the supported versions of the Matrix protocol and the supported | ||||||
|   /// login types. Returns false if the server is not compatible with the |   /// login types. Returns false if the server is not compatible with the | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue