[Client] Directchatroom should exist
This commit is contained in:
		
							parent
							
								
									f885dfbecc
								
							
						
					
					
						commit
						37866359be
					
				|  | @ -123,12 +123,14 @@ 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) => |   String getDirectChatFromUserId(String userId) => accountData["m.direct"] != | ||||||
|       accountData["m.direct"] != null && |               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 && | ||||||
|           ? accountData["m.direct"].content[userId][0] |           roomList.getRoomById(accountData["m.direct"].content[userId][0]) != | ||||||
|           : null; |               null | ||||||
|  |       ? accountData["m.direct"].content[userId][0] | ||||||
|  |       : 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 | ||||||
|  |  | ||||||
|  | @ -78,6 +78,13 @@ class RoomList { | ||||||
|     return null; |     return null; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   Room getRoomById(String id) { | ||||||
|  |     for (int j = 0; j < rooms.length; j++) { | ||||||
|  |       if (rooms[j].id == id) return rooms[j]; | ||||||
|  |     } | ||||||
|  |     return null; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   void _handleRoomUpdate(RoomUpdate chatUpdate) { |   void _handleRoomUpdate(RoomUpdate chatUpdate) { | ||||||
|     // Update the chat list item. |     // Update the chat list item. | ||||||
|     // Search the room in the rooms |     // Search the room in the rooms | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue