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>
(cherry picked from commit 662c7d069693e7b0aee906194a29f2a437007a5c)
This commit is contained in:
Urs Liska 2017-09-26 15:16:15 +02:00
parent 204cea1421
commit c6ef1d935c
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).