Fix new added account's order
This commit is contained in:
		| @@ -69,6 +69,8 @@ and this project adheres to | |||||||
| - Make sure the account shown in the left pane is immediatly updated  | - Make sure the account shown in the left pane is immediatly updated  | ||||||
|   after changing display name or avatar in the accounty settings |   after changing display name or avatar in the accounty settings | ||||||
|  |  | ||||||
|  | - When signing in a new account, correctly position it after the other | ||||||
|  |   existing ones without needing a restart | ||||||
|  |  | ||||||
| ## 0.5.0 | ## 0.5.0 | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										1
									
								
								TODO.md
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								TODO.md
									
									
									
									
									
								
							| @@ -3,7 +3,6 @@ | |||||||
| - fix cursor over field | - fix cursor over field | ||||||
| - update room highlight when creating new room | - update room highlight when creating new room | ||||||
| - keyerror when forgetting room while loading members | - keyerror when forgetting room while loading members | ||||||
| - account order, and verify not adding to config fiel works |  | ||||||
|  |  | ||||||
| ## Refactoring | ## Refactoring | ||||||
|  |  | ||||||
|   | |||||||
| @@ -117,7 +117,7 @@ class Backend: | |||||||
|         password:   str, |         password:   str, | ||||||
|         device_id:  Optional[str] = None, |         device_id:  Optional[str] = None, | ||||||
|         homeserver: str           = "https://matrix.org", |         homeserver: str           = "https://matrix.org", | ||||||
|         order:      int           = -1, |         order:      Optional[int] = None, | ||||||
|    ) -> str: |    ) -> str: | ||||||
|         """Create and register a `MatrixClient`, login and return a user ID.""" |         """Create and register a `MatrixClient`, login and return a user ID.""" | ||||||
|  |  | ||||||
| @@ -131,6 +131,14 @@ class Backend: | |||||||
|             await client.close() |             await client.close() | ||||||
|             raise |             raise | ||||||
|  |  | ||||||
|  |         if order is None and not self.models["accounts"]: | ||||||
|  |             order = 0 | ||||||
|  |         elif order is None: | ||||||
|  |             order = max( | ||||||
|  |                 account.order | ||||||
|  |                 for i, account in enumerate(self.models["accounts"].values()) | ||||||
|  |             ) + 1 | ||||||
|  |  | ||||||
|         self.clients[client.user_id]            = client |         self.clients[client.user_id]            = client | ||||||
|         self.models["accounts"][client.user_id] = Account(client.user_id,order) |         self.models["accounts"][client.user_id] = Account(client.user_id,order) | ||||||
|         return client.user_id |         return client.user_id | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	