diff options
author | Lucas Hoffmann <lucc@users.noreply.github.com> | 2019-07-22 09:39:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-22 09:39:05 +0200 |
commit | a935ab494aba253501758bc59a1f586ad39ed303 (patch) | |
tree | 80378185b00aa446b19613b8d7dcf589cf56903d /alot | |
parent | f602676a9a5095bcbc11dc5112fb2a1dd172b11a (diff) | |
parent | 544d035444252e532e39209d127f8c889b752adb (diff) |
Merge pull request #1398 from pazz/0.8-summary-only
Faster Thread loading
Diffstat (limited to 'alot')
-rw-r--r-- | alot/commands/search.py | 6 | ||||
-rw-r--r-- | alot/widgets/thread.py | 20 |
2 files changed, 21 insertions, 5 deletions
diff --git a/alot/commands/search.py b/alot/commands/search.py index 80aecb24..e2e135d4 100644 --- a/alot/commands/search.py +++ b/alot/commands/search.py @@ -38,9 +38,9 @@ class OpenThreadCommand(Command): query = ui.current_buffer.querystring logging.info('open thread view for %s', self.thread) - sb = buffers.ThreadBuffer(ui, self.thread) - ui.buffer_open(sb) - sb.unfold_matching(query) + tb = buffers.ThreadBuffer(ui, self.thread) + ui.buffer_open(tb) + tb.unfold_matching(query) @registerCommand(MODE, 'refine', help='refine query', arguments=[ diff --git a/alot/widgets/thread.py b/alot/widgets/thread.py index bef80b45..ce35b480 100644 --- a/alot/widgets/thread.py +++ b/alot/widgets/thread.py @@ -169,7 +169,7 @@ class MessageTree(CollapsibleTree): self._default_headers_tree = None self.display_attachments = True self._attachments = None - self._maintree = SimpleTree(self._assemble_structure()) + self._maintree = SimpleTree(self._assemble_structure(True)) CollapsibleTree.__init__(self, self._maintree) def get_message(self): @@ -191,7 +191,23 @@ class MessageTree(CollapsibleTree): logging.debug('DHT %s', str(self._default_headers_tree)) logging.debug('MAINTREE %s', str(self._maintree._treelist)) - def _assemble_structure(self): + def expand(self, pos): + """ + overload CollapsibleTree.expand method to ensure all parts are present. + Initially, only the summary widget is created to avoid reading the + messafe file and thus speed up the creation of this object. Once we + expand = unfold the message, we need to make sure that body/attachments + exist. + """ + logging.debug("MT expand") + if not self._bodytree: + self.reassemble() + CollapsibleTree.expand(self, pos) + + def _assemble_structure(self, summary_only=False): + if summary_only: + return [(self._get_summary(), None)] + mainstruct = [] if self.display_source: mainstruct.append((self._get_source(), None)) |