Function to generate mute icon html

main
Bob Mottram 2020-11-30 17:48:35 +00:00
parent bd6509875b
commit 3294c6e928
1 changed files with 57 additions and 26 deletions

View File

@ -497,6 +497,51 @@ def getBookmarkIconHtml(nickname: str, domainFull: str,
return bookmarkStr 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 = \
' <a class="imageAnchor" href="/users/' + nickname + \
'?mute=' + messageId + pageNumberParam + '?tl=' + boxName + \
'?bm=' + timelinePostBookmark + \
'" title="' + translate['Mute this post'] + '">\n'
muteStr += \
' ' + \
'<img loading="lazy" alt="' + \
translate['Mute this post'] + \
' |" title="' + translate['Mute this post'] + \
'" src="/' + iconsPath + '/mute.png"/></a>\n'
else:
muteStr = \
' <a class="imageAnchor" href="/users/' + \
nickname + '?unmute=' + messageId + \
pageNumberParam + '?tl=' + boxName + '?bm=' + \
timelinePostBookmark + '" title="' + \
translate['Undo mute'] + '">\n'
muteStr += \
' ' + \
'<img loading="lazy" alt="' + translate['Undo mute'] + \
' |" title="' + translate['Undo mute'] + \
'" src="/' + iconsPath + '/unmute.png"/></a>\n'
return muteStr
def individualPostAsHtml(allowDownloads: bool, def individualPostAsHtml(allowDownloads: bool,
recentPostsCache: {}, maxRecentPosts: int, recentPostsCache: {}, maxRecentPosts: int,
iconsPath: str, translate: {}, iconsPath: str, translate: {},
@ -833,8 +878,19 @@ def individualPostAsHtml(allowDownloads: bool,
if timeDiff > 100: if timeDiff > 100:
print('TIMING INDIV ' + boxName + ' 13 = ' + str(timeDiff)) print('TIMING INDIV ' + boxName + ' 13 = ' + str(timeDiff))
muteStr = \
getMuteIconHtml(isMuted,
postActor,
messageId,
nickname, domainFull,
allowDeletion,
pageNumberParam,
iconsPath,
boxName,
timelinePostBookmark,
translate)
deleteStr = '' deleteStr = ''
muteStr = ''
if (allowDeletion or if (allowDeletion or
('/' + domainFull + '/' in postActor and ('/' + domainFull + '/' in postActor and
messageId.startswith(postActor))): messageId.startswith(postActor))):
@ -851,31 +907,6 @@ def individualPostAsHtml(allowDownloads: bool,
translate['Delete this post'] + \ translate['Delete this post'] + \
' |" title="' + translate['Delete this post'] + \ ' |" title="' + translate['Delete this post'] + \
'" src="/' + iconsPath + '/delete.png"/></a>\n' '" src="/' + iconsPath + '/delete.png"/></a>\n'
else:
if not isMuted:
muteStr = \
' <a class="imageAnchor" href="/users/' + nickname + \
'?mute=' + messageId + pageNumberParam + '?tl=' + boxName + \
'?bm=' + timelinePostBookmark + \
'" title="' + translate['Mute this post'] + '">\n'
muteStr += \
' ' + \
'<img loading="lazy" alt="' + \
translate['Mute this post'] + \
' |" title="' + translate['Mute this post'] + \
'" src="/' + iconsPath + '/mute.png"/></a>\n'
else:
muteStr = \
' <a class="imageAnchor" href="/users/' + \
nickname + '?unmute=' + messageId + \
pageNumberParam + '?tl=' + boxName + '?bm=' + \
timelinePostBookmark + '" title="' + \
translate['Undo mute'] + '">\n'
muteStr += \
' ' + \
'<img loading="lazy" alt="' + translate['Undo mute'] + \
' |" title="' + translate['Undo mute'] + \
'" src="/' + iconsPath+'/unmute.png"/></a>\n'
# benchmark 13.1 # benchmark 13.1
if enableTimingLog: if enableTimingLog: