mirror of https://gitlab.com/bashrc2/epicyon
Limit the number of reaction types which can be shown on a post
parent
bdd63be131
commit
af69491fe9
|
@ -502,7 +502,7 @@ def updateReactionCollection(recentPostsCache: {},
|
||||||
|
|
||||||
|
|
||||||
def htmlEmojiReactions(postJsonObject: {}, interactive: bool,
|
def htmlEmojiReactions(postJsonObject: {}, interactive: bool,
|
||||||
actor: str) -> str:
|
actor: str, maxReactionTypes: int) -> str:
|
||||||
"""html containing row of emoji reactions
|
"""html containing row of emoji reactions
|
||||||
"""
|
"""
|
||||||
if not hasObjectDict(postJsonObject):
|
if not hasObjectDict(postJsonObject):
|
||||||
|
@ -515,6 +515,7 @@ def htmlEmojiReactions(postJsonObject: {}, interactive: bool,
|
||||||
for item in postJsonObject['object']['reactions']['items']:
|
for item in postJsonObject['object']['reactions']['items']:
|
||||||
emojiContent = item['content']
|
emojiContent = item['content']
|
||||||
if not reactions.get(emojiContent):
|
if not reactions.get(emojiContent):
|
||||||
|
if len(reactions.items()) < maxReactionTypes:
|
||||||
reactions[emojiContent] = 1
|
reactions[emojiContent] = 1
|
||||||
else:
|
else:
|
||||||
reactions[emojiContent] += 1
|
reactions[emojiContent] += 1
|
||||||
|
|
|
@ -1304,6 +1304,10 @@ def individualPostAsHtml(signingPrivateKeyPem: str,
|
||||||
if not postJsonObject:
|
if not postJsonObject:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
# maximum number of different emoji reactions which can
|
||||||
|
# be added to a post
|
||||||
|
maxReactionTypes = 5
|
||||||
|
|
||||||
# benchmark
|
# benchmark
|
||||||
postStartTime = time.time()
|
postStartTime = time.time()
|
||||||
|
|
||||||
|
@ -1882,7 +1886,9 @@ def individualPostAsHtml(signingPrivateKeyPem: str,
|
||||||
if boxName != 'tlmedia':
|
if boxName != 'tlmedia':
|
||||||
reactionStr = ''
|
reactionStr = ''
|
||||||
if showIcons:
|
if showIcons:
|
||||||
reactionStr = htmlEmojiReactions(postJsonObject, True, personUrl)
|
reactionStr = \
|
||||||
|
htmlEmojiReactions(postJsonObject, True, personUrl,
|
||||||
|
maxReactionTypes)
|
||||||
if postIsSensitive and reactionStr:
|
if postIsSensitive and reactionStr:
|
||||||
reactionStr = '<br>' + reactionStr
|
reactionStr = '<br>' + reactionStr
|
||||||
postHtml = ' <div id="' + timelinePostBookmark + \
|
postHtml = ' <div id="' + timelinePostBookmark + \
|
||||||
|
|
Loading…
Reference in New Issue