diff options
author | Maxime “pep” Buquet <pep@bouah.net> | 2022-02-25 19:05:54 +0100 |
---|---|---|
committer | Maxime “pep” Buquet <pep@bouah.net> | 2022-02-25 19:05:54 +0100 |
commit | 06dbefebb763c86bee3e242e290370df6f7d50f5 (patch) | |
tree | c5dedf61ad55134344f508bbd5133536d5e028ac | |
parent | a1af1355a99c370a056337a826d5a29a90a13447 (diff) | |
download | poezio-06dbefebb763c86bee3e242e290370df6f7d50f5.tar.gz poezio-06dbefebb763c86bee3e242e290370df6f7d50f5.tar.bz2 poezio-06dbefebb763c86bee3e242e290370df6f7d50f5.tar.xz poezio-06dbefebb763c86bee3e242e290370df6f7d50f5.zip |
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>
-rw-r--r-- | poezio/core/commands.py | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/poezio/core/commands.py b/poezio/core/commands.py index bc594494..4c7b3e4f 100644 --- a/poezio/core/commands.py +++ b/poezio/core/commands.py @@ -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 |