Ensure /bookmark{,_local} and /join use the proper tab object
Now that _add_bookmark is async. Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
a1af1355a9
commit
06dbefebb7
1 changed files with 17 additions and 15 deletions
|
@ -446,13 +446,18 @@ class CommandCore:
|
|||
"""
|
||||
/bookmark_local [room][/nick] [password]
|
||||
"""
|
||||
if not args and not isinstance(self.core.tabs.current_tab,
|
||||
tabs.MucTab):
|
||||
tab = self.core.tabs.current_tab
|
||||
if not args and not isinstance(tab, tabs.MucTab):
|
||||
return
|
||||
|
||||
room, nick = self._parse_join_jid(args[0] if args else '')
|
||||
password = args[1] if len(args) > 1 else None
|
||||
|
||||
if not room:
|
||||
room = tab.jid.bare
|
||||
if password is None and tab.password is not None:
|
||||
password = tab.password
|
||||
|
||||
asyncio.create_task(
|
||||
self._add_bookmark(
|
||||
room=room,
|
||||
|
@ -468,8 +473,8 @@ class CommandCore:
|
|||
"""
|
||||
/bookmark [room][/nick] [autojoin] [password]
|
||||
"""
|
||||
if not args and not isinstance(self.core.tabs.current_tab,
|
||||
tabs.MucTab):
|
||||
tab = self.core.tabs.current_tab
|
||||
if not args and not isinstance(tab, tabs.MucTab):
|
||||
return
|
||||
room, nick = self._parse_join_jid(args[0] if args else '')
|
||||
password = args[2] if len(args) > 2 else None
|
||||
|
@ -478,13 +483,18 @@ class CommandCore:
|
|||
autojoin = (method == 'local' or
|
||||
(len(args) > 1 and args[1].lower() == 'true'))
|
||||
|
||||
if not room:
|
||||
room = tab.jid.bare
|
||||
if password is None and tab.password is not None:
|
||||
password = tab.password
|
||||
|
||||
asyncio.create_task(
|
||||
self._add_bookmark(room, nick, autojoin, password, method)
|
||||
)
|
||||
|
||||
async def _add_bookmark(
|
||||
self,
|
||||
room: Optional[str],
|
||||
room: str,
|
||||
nick: Optional[str],
|
||||
autojoin: bool,
|
||||
password: str,
|
||||
|
@ -503,16 +513,8 @@ class CommandCore:
|
|||
method: 'local' or 'remote'.
|
||||
'''
|
||||
|
||||
# No room Jid was specified. A nick may have been specified. Set the
|
||||
# room Jid to be bookmarked to the current tab bare jid.
|
||||
if not room:
|
||||
tab = self.core.tabs.current_tab
|
||||
if not isinstance(tab, tabs.MucTab):
|
||||
return
|
||||
room = tab.jid.bare
|
||||
if password is None and tab.password is not None:
|
||||
password = tab.password
|
||||
elif room == '*':
|
||||
|
||||
if room == '*':
|
||||
return await self._add_wildcard_bookmarks(method)
|
||||
|
||||
# Once we found which room to bookmark, find corresponding tab if it
|
||||
|
|
Loading…
Reference in a new issue