Fixed bad recursive algorithm (I was adding the same entry twice, one with subfolders and the other with nothing). Also, leaf folders are not clickable anymore.

fixed #124
This commit is contained in:
Antoine Nguyen
2011-03-17 17:33:55 +01:00
parent 4adecda984
commit e40536e4f8
2 changed files with 9 additions and 3 deletions
+8 -2
View File
@@ -216,10 +216,16 @@ class IMAPconnector(object):
if not len(parts):
return False
path = "%s%s%s" % (prefix, delimiter, parts[0])
sdescr = {"name" : parts[0], "path" : path, "sub" : []}
sdescr = None
for d in descr:
if d["path"] == path:
sdescr = d
break
if sdescr is None:
sdescr = {"name" : parts[0], "path" : path, "sub" : []}
descr += [sdescr]
if self._parse_folder_name(sdescr["sub"], path, delimiter, parts[1:]):
sdescr["class"] = "subfolders"
descr += [sdescr]
return True
def _listfolders(self, topfolder='INBOX', md_folders=[]):
+1 -1
View File
@@ -138,7 +138,7 @@ def print_folders(folders, selected=None):
cssclass = "unseen"
result += "<a href='%s' class='%s' name='loadfolder'>%s</a>\n" \
% (fd.has_key("path") and fd["path"] or fd["name"], cssclass, label)
if fd.has_key("sub"):
if fd.has_key("sub") and len(fd["sub"]):
result += "<ul name='%s' class='hidden'>" % (fd["path"]) + print_folders(fd["sub"], selected) + "</ul>\n"
result += "</li>\n"
return result