From 3294c6e928bc2d1daedd1a028fa4b6e98a3edbc3 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 30 Nov 2020 17:48:35 +0000 Subject: [PATCH] Function to generate mute icon html --- webapp_post.py | 83 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 26 deletions(-) diff --git a/webapp_post.py b/webapp_post.py index dcf42238..14947d45 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -497,6 +497,51 @@ def getBookmarkIconHtml(nickname: str, domainFull: str, return bookmarkStr +def getMuteIconHtml(isMuted: bool, + postActor: str, + messageId: str, + nickname: str, domainFull: str, + allowDeletion: bool, + pageNumberParam: str, + iconsPath: str, + boxName: str, + timelinePostBookmark: str, + translate: {}) -> str: + """Returns html for mute icon/button + """ + muteStr = '' + if (allowDeletion or + ('/' + domainFull + '/' in postActor and + messageId.startswith(postActor))): + return muteStr + + if not isMuted: + muteStr = \ + ' \n' + muteStr += \ + ' ' + \ + '' + \
+            translate['Mute this post'] + \
+            ' |\n' + else: + muteStr = \ + ' \n' + muteStr += \ + ' ' + \ + '' + translate['Undo mute'] + \
+            ' |\n' + return muteStr + + def individualPostAsHtml(allowDownloads: bool, recentPostsCache: {}, maxRecentPosts: int, iconsPath: str, translate: {}, @@ -833,8 +878,19 @@ def individualPostAsHtml(allowDownloads: bool, if timeDiff > 100: print('TIMING INDIV ' + boxName + ' 13 = ' + str(timeDiff)) + muteStr = \ + getMuteIconHtml(isMuted, + postActor, + messageId, + nickname, domainFull, + allowDeletion, + pageNumberParam, + iconsPath, + boxName, + timelinePostBookmark, + translate) + deleteStr = '' - muteStr = '' if (allowDeletion or ('/' + domainFull + '/' in postActor and messageId.startswith(postActor))): @@ -851,31 +907,6 @@ def individualPostAsHtml(allowDownloads: bool, translate['Delete this post'] + \ ' |" title="' + translate['Delete this post'] + \ '" src="/' + iconsPath + '/delete.png"/>\n' - else: - if not isMuted: - muteStr = \ - ' \n' - muteStr += \ - ' ' + \ - '' + \
-                translate['Mute this post'] + \
-                ' |\n' - else: - muteStr = \ - ' \n' - muteStr += \ - ' ' + \ - '' + translate['Undo mute'] + \
-                ' |\n' # benchmark 13.1 if enableTimingLog: