Highlight button when a new reply arrives

main2
Bob Mottram 2019-10-03 17:37:25 +01:00
parent e6c2fc11a3
commit d26610b6da
2 changed files with 30 additions and 1 deletions

View File

@ -45,6 +45,7 @@ from httpsig import messageContentDigest
from blocking import isBlockedDomain
from posts import downloadAnnounce
from posts import isDM
from posts import isReply
def validInbox(baseDir: str,nickname: str,domain: str) -> bool:
"""Checks whether files were correctly saved to the inbox
@ -1230,6 +1231,17 @@ def dmNotify(baseDir: str,handle: str) -> None:
with open(dmFile, 'w') as fp:
fp.write('\n')
def replyNotify(baseDir: str,handle: str) -> None:
"""Creates a notification that a new reply has arrived
"""
accountDir=baseDir+'/accounts/'+handle
if not os.path.isdir(accountDir):
return
replyFile=accountDir+'/.newReply'
if not os.path.isfile(replyFile):
with open(replyFile, 'w') as fp:
fp.write('\n')
def inboxAfterCapabilities(session,keyId: str,handle: str,messageJson: {}, \
baseDir: str,httpPrefix: str,sendThreads: [], \
postLog: [],cachedWebfingers: {},personCache: {}, \
@ -1322,6 +1334,8 @@ def inboxAfterCapabilities(session,keyId: str,handle: str,messageJson: {}, \
if validPostContent(messageJson['post'],maxMentions):
if isDM(messageJson['post']):
dmNotify(baseDir,handle)
if isReply(messageJson['post'],actor):
replyNotify(baseDir,handle)
obtainAvatarForReplyPost(session,baseDir,httpPrefix,domain,personCache,messageJson['post'],debug)
try:
with open(destinationFilename, 'w+') as fp:
@ -1332,6 +1346,8 @@ def inboxAfterCapabilities(session,keyId: str,handle: str,messageJson: {}, \
if validPostContent(messageJson,maxMentions):
if isDM(messageJson):
dmNotify(baseDir,handle)
if isReply(messageJson,actor):
replyNotify(baseDir,handle)
obtainAvatarForReplyPost(session,baseDir,httpPrefix,domain,personCache,messageJson,debug)
try:
with open(destinationFilename, 'w+') as fp:

View File

@ -2032,12 +2032,21 @@ def htmlTimeline(translate: {},pageNumber: int, \
"""
# should the DM button be highlighted?
newDM=False
dmFile=baseDir+'/accounts/'+nickname+'@'+domain+'/.newDM'
accountDir=baseDir+'/accounts/'+nickname+'@'+domain
dmFile=accountDir+'/.newDM'
if os.path.isfile(dmFile):
newDM=True
if boxName=='dm':
os.remove(dmFile)
# should the Replies button be highlighted?
newReply=False
replyFile=accountDir+'/.newReply'
if os.path.isfile(replyFile):
newReply=True
if boxName=='tlreplies':
os.remove(replyFile)
iconsDir=getIconsDir(baseDir)
cssFilename=baseDir+'/epicyon-profile.css'
if os.path.isfile(baseDir+'/epicyon.css'):
@ -2054,6 +2063,8 @@ def htmlTimeline(translate: {},pageNumber: int, \
if newDM:
dmButton='buttonhighlighted'
repliesButton='button'
if newReply:
repliesButton='buttonhighlighted'
mediaButton='button'
sentButton='button'
moderationButton='button'
@ -2065,6 +2076,8 @@ def htmlTimeline(translate: {},pageNumber: int, \
dmButton='buttonselectedhighlighted'
elif boxName=='tlreplies':
repliesButton='buttonselected'
if newReply:
repliesButton='buttonselectedhighlighted'
elif boxName=='tlmedia':
mediaButton='buttonselected'
elif boxName=='outbox':