utf8 (aside): Move code for decodefoldernames

While intending *not* to change the behaviour of the existing
decodefoldernames option this commit transparently improves
the coding.
So far this worked by overriding the folder's getvisiblename() method
which reads self.visiblename from and applies the conversion on
*every* invocation of getvisiblename().
This commit does the calculation once in the IMAPFolder's __init__.

Signed-off-by: Urs Liska <git@ursliska.de>
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Urs Liska 2017-09-26 15:16:15 +02:00 committed by Nicolas Sebrecht
parent 24b3f27e5f
commit dca5f1846d
1 changed files with 2 additions and 7 deletions

View File

@ -47,6 +47,8 @@ class IMAPFolder(BaseFolder):
name = imaputil.dequote(name)
self.sep = imapserver.delim
super(IMAPFolder, self).__init__(name, repository)
if repository.getdecodefoldernames():
self.visiblename = imaputil.decode_mailbox_name(self.visiblename)
self.idle_mode = False
self.expunge = repository.getexpunge()
self.root = None # imapserver.root
@ -290,13 +292,6 @@ class IMAPFolder(BaseFolder):
'keywords': keywords}
self.ui.messagelistloaded(self.repository, self, self.getmessagecount())
# Interface from BaseFolder
def getvisiblename(self):
vname = super(IMAPFolder, self).getvisiblename()
if self.repository.getdecodefoldernames():
return imaputil.decode_mailbox_name(vname)
return vname
# Interface from BaseFolder
def getmessage(self, uid):
"""Retrieve message with UID from the IMAP server (incl body).