api(deltachat-rpc-client): add Account.bring_online()

This commit is contained in:
link2xt
2024-04-08 13:50:25 +00:00
parent f5e8a04fd0
commit 0b73f9cebd
2 changed files with 9 additions and 5 deletions

View File

@@ -87,6 +87,14 @@ class Account:
"""Configure an account."""
yield self._rpc.configure.future(self.id)
def bring_online(self):
"""Start I/O and wait until IMAP becomes IDLE."""
self.start_io()
while True:
event = self.wait_for_event()
if event.kind == EventType.IMAP_INBOX_IDLE:
break
def create_contact(self, obj: Union[int, str, Contact], name: Optional[str] = None) -> Contact:
"""Create a new Contact or return an existing one.

View File

@@ -54,11 +54,7 @@ class ACFactory:
@futuremethod
def get_online_account(self):
account = yield self.new_configured_account.future()
account.start_io()
while True:
event = account.wait_for_event()
if event.kind == EventType.IMAP_INBOX_IDLE:
break
account.bring_online()
return account
def get_online_accounts(self, num: int) -> List[Account]: