mirror of https://gitlab.com/bashrc2/epicyon
Set indicator status based on web interface
parent
6fca7fb234
commit
a3506e4cec
|
@ -402,7 +402,8 @@ def _readLocalBoxPost(boxName: str, index: int,
|
||||||
def _showLocalBox(notifyJson: {}, boxName: str,
|
def _showLocalBox(notifyJson: {}, boxName: str,
|
||||||
screenreader: str, systemLanguage: str, espeak,
|
screenreader: str, systemLanguage: str, espeak,
|
||||||
startPostIndex=0, noOfPosts=10,
|
startPostIndex=0, noOfPosts=10,
|
||||||
newReplies=False) -> bool:
|
newReplies=False,
|
||||||
|
newDMs=False) -> bool:
|
||||||
"""Shows locally stored posts for a given subdirectory
|
"""Shows locally stored posts for a given subdirectory
|
||||||
"""
|
"""
|
||||||
indent = ' '
|
indent = ' '
|
||||||
|
@ -504,7 +505,10 @@ def _showLocalBox(notifyJson: {}, boxName: str,
|
||||||
# say the post number range
|
# say the post number range
|
||||||
sayStr = indent + boxName + ' posts ' + str(startPostIndex + 1) + \
|
sayStr = indent + boxName + ' posts ' + str(startPostIndex + 1) + \
|
||||||
' to ' + str(startPostIndex + ctr) + '. '
|
' to ' + str(startPostIndex + ctr) + '. '
|
||||||
if newReplies and boxName != 'replies':
|
if newDMs and boxName != 'dm':
|
||||||
|
sayStr += \
|
||||||
|
'Use \33[3mshow dm\33[0m to view DM posts.'
|
||||||
|
elif newReplies and boxName != 'replies':
|
||||||
sayStr += \
|
sayStr += \
|
||||||
'Use \33[3mshow replies\33[0m to view reply posts.'
|
'Use \33[3mshow replies\33[0m to view reply posts.'
|
||||||
else:
|
else:
|
||||||
|
@ -788,6 +792,7 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
|
||||||
currRepliesIndex = 0
|
currRepliesIndex = 0
|
||||||
currSentIndex = 0
|
currSentIndex = 0
|
||||||
newRepliesExist = False
|
newRepliesExist = False
|
||||||
|
newDMsExist = False
|
||||||
currPostId = ''
|
currPostId = ''
|
||||||
while (1):
|
while (1):
|
||||||
session = createSession(proxyType)
|
session = createSession(proxyType)
|
||||||
|
@ -809,8 +814,19 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
|
||||||
speakerJson['notify']['theme'] + '/sounds'
|
speakerJson['notify']['theme'] + '/sounds'
|
||||||
if not os.path.isdir(soundsDir):
|
if not os.path.isdir(soundsDir):
|
||||||
soundsDir = 'theme/default/sounds'
|
soundsDir = 'theme/default/sounds'
|
||||||
if speakerJson['notify'].get('direct'):
|
|
||||||
if speakerJson['notify']['direct'] is True:
|
# If new DM has not been viewed via web interface
|
||||||
|
if not speakerJson.get('direct'):
|
||||||
|
if speakerJson['notify']['dm']:
|
||||||
|
speakerJson['direct'] = True
|
||||||
|
|
||||||
|
# If new reply has not been viewed via web interface
|
||||||
|
if not speakerJson.get('replyToYou'):
|
||||||
|
if speakerJson['notify']['reply']:
|
||||||
|
speakerJson['replyToYou'] = True
|
||||||
|
|
||||||
|
if speakerJson.get('direct'):
|
||||||
|
if speakerJson['direct'] is True:
|
||||||
if currPostId != speakerJson['id']:
|
if currPostId != speakerJson['id']:
|
||||||
if notificationSounds:
|
if notificationSounds:
|
||||||
_playNotificationSound(soundsDir + '/' +
|
_playNotificationSound(soundsDir + '/' +
|
||||||
|
@ -915,16 +931,27 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
|
||||||
newRepliesExist = True
|
newRepliesExist = True
|
||||||
_storeMessage(speakerJson, 'replies')
|
_storeMessage(speakerJson, 'replies')
|
||||||
if speakerJson.get('direct'):
|
if speakerJson.get('direct'):
|
||||||
|
newDMsExist = True
|
||||||
_storeMessage(speakerJson, 'dm')
|
_storeMessage(speakerJson, 'dm')
|
||||||
if storeInboxPosts:
|
if storeInboxPosts:
|
||||||
_storeMessage(speakerJson, 'inbox')
|
_storeMessage(speakerJson, 'inbox')
|
||||||
|
|
||||||
|
# DM has been viewed via the web interface
|
||||||
|
if newDMsExist and \
|
||||||
|
not speakerJson['notify']['dm']:
|
||||||
|
newDMsExist = False
|
||||||
|
# Reply has been viewed via the web interface
|
||||||
|
if newRepliesExist and \
|
||||||
|
not speakerJson['notify']['reply']:
|
||||||
|
newRepliesExist = False
|
||||||
|
|
||||||
if not showNewPosts:
|
if not showNewPosts:
|
||||||
_clearScreen()
|
_clearScreen()
|
||||||
_showLocalBox(notifyJson, currTimeline,
|
_showLocalBox(notifyJson, currTimeline,
|
||||||
None, systemLanguage, espeak,
|
None, systemLanguage, espeak,
|
||||||
currInboxIndex, 10,
|
currInboxIndex, 10,
|
||||||
newRepliesExist)
|
newRepliesExist,
|
||||||
|
newDMsExist)
|
||||||
else:
|
else:
|
||||||
print('')
|
print('')
|
||||||
|
|
||||||
|
@ -951,13 +978,16 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
|
||||||
currDMIndex = 0
|
currDMIndex = 0
|
||||||
_showLocalBox(notifyJson, 'dm',
|
_showLocalBox(notifyJson, 'dm',
|
||||||
screenreader, systemLanguage, espeak,
|
screenreader, systemLanguage, espeak,
|
||||||
currDMIndex, 10, newRepliesExist)
|
currDMIndex, 10,
|
||||||
|
newRepliesExist, newDMsExist)
|
||||||
currTimeline = 'dm'
|
currTimeline = 'dm'
|
||||||
|
newDMsExist = False
|
||||||
elif keyPress.startswith('show rep'):
|
elif keyPress.startswith('show rep'):
|
||||||
currRepliesIndex = 0
|
currRepliesIndex = 0
|
||||||
_showLocalBox(notifyJson, 'replies',
|
_showLocalBox(notifyJson, 'replies',
|
||||||
screenreader, systemLanguage, espeak,
|
screenreader, systemLanguage, espeak,
|
||||||
currRepliesIndex, 10, newRepliesExist)
|
currRepliesIndex, 10,
|
||||||
|
newRepliesExist, newDMsExist)
|
||||||
currTimeline = 'replies'
|
currTimeline = 'replies'
|
||||||
# Turn off the replies indicator
|
# Turn off the replies indicator
|
||||||
newRepliesExist = False
|
newRepliesExist = False
|
||||||
|
@ -965,36 +995,42 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
|
||||||
currSentIndex = 0
|
currSentIndex = 0
|
||||||
_showLocalBox(notifyJson, 'sent',
|
_showLocalBox(notifyJson, 'sent',
|
||||||
screenreader, systemLanguage, espeak,
|
screenreader, systemLanguage, espeak,
|
||||||
currSentIndex, 10, newRepliesExist)
|
currSentIndex, 10,
|
||||||
|
newRepliesExist, newDMsExist)
|
||||||
currTimeline = 'sent'
|
currTimeline = 'sent'
|
||||||
elif (keyPress == 'show' or keyPress.startswith('show in') or
|
elif (keyPress == 'show' or keyPress.startswith('show in') or
|
||||||
keyPress == 'clear'):
|
keyPress == 'clear'):
|
||||||
currInboxIndex = 0
|
currInboxIndex = 0
|
||||||
_showLocalBox(notifyJson, 'inbox',
|
_showLocalBox(notifyJson, 'inbox',
|
||||||
screenreader, systemLanguage, espeak,
|
screenreader, systemLanguage, espeak,
|
||||||
currInboxIndex, 10, newRepliesExist)
|
currInboxIndex, 10,
|
||||||
|
newRepliesExist, newDMsExist)
|
||||||
currTimeline = 'inbox'
|
currTimeline = 'inbox'
|
||||||
elif keyPress.startswith('next'):
|
elif keyPress.startswith('next'):
|
||||||
if currTimeline == 'dm':
|
if currTimeline == 'dm':
|
||||||
currDMIndex += 10
|
currDMIndex += 10
|
||||||
_showLocalBox(notifyJson, 'dm',
|
_showLocalBox(notifyJson, 'dm',
|
||||||
screenreader, systemLanguage, espeak,
|
screenreader, systemLanguage, espeak,
|
||||||
currDMIndex, 10, newRepliesExist)
|
currDMIndex, 10,
|
||||||
|
newRepliesExist, newDMsExist)
|
||||||
elif currTimeline == 'replies':
|
elif currTimeline == 'replies':
|
||||||
currRepliesIndex += 10
|
currRepliesIndex += 10
|
||||||
_showLocalBox(notifyJson, 'replies',
|
_showLocalBox(notifyJson, 'replies',
|
||||||
screenreader, systemLanguage, espeak,
|
screenreader, systemLanguage, espeak,
|
||||||
currRepliesIndex, 10, newRepliesExist)
|
currRepliesIndex, 10,
|
||||||
|
newRepliesExist, newDMsExist)
|
||||||
elif currTimeline == 'sent':
|
elif currTimeline == 'sent':
|
||||||
currSentIndex += 10
|
currSentIndex += 10
|
||||||
_showLocalBox(notifyJson, 'sent',
|
_showLocalBox(notifyJson, 'sent',
|
||||||
screenreader, systemLanguage, espeak,
|
screenreader, systemLanguage, espeak,
|
||||||
currSentIndex, 10, newRepliesExist)
|
currSentIndex, 10,
|
||||||
|
newRepliesExist, newDMsExist)
|
||||||
elif currTimeline == 'inbox':
|
elif currTimeline == 'inbox':
|
||||||
currInboxIndex += 10
|
currInboxIndex += 10
|
||||||
_showLocalBox(notifyJson, 'inbox',
|
_showLocalBox(notifyJson, 'inbox',
|
||||||
screenreader, systemLanguage, espeak,
|
screenreader, systemLanguage, espeak,
|
||||||
currInboxIndex, 10, newRepliesExist)
|
currInboxIndex, 10,
|
||||||
|
newRepliesExist, newDMsExist)
|
||||||
elif keyPress.startswith('prev'):
|
elif keyPress.startswith('prev'):
|
||||||
if currTimeline == 'dm':
|
if currTimeline == 'dm':
|
||||||
currDMIndex -= 10
|
currDMIndex -= 10
|
||||||
|
@ -1002,28 +1038,32 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str,
|
||||||
currDMIndex = 0
|
currDMIndex = 0
|
||||||
_showLocalBox(notifyJson, 'dm',
|
_showLocalBox(notifyJson, 'dm',
|
||||||
screenreader, systemLanguage, espeak,
|
screenreader, systemLanguage, espeak,
|
||||||
currDMIndex, 10, newRepliesExist)
|
currDMIndex, 10,
|
||||||
|
newRepliesExist, newDMsExist)
|
||||||
elif currTimeline == 'replies':
|
elif currTimeline == 'replies':
|
||||||
currRepliesIndex -= 10
|
currRepliesIndex -= 10
|
||||||
if currRepliesIndex < 0:
|
if currRepliesIndex < 0:
|
||||||
currRepliesIndex = 0
|
currRepliesIndex = 0
|
||||||
_showLocalBox(notifyJson, 'replies',
|
_showLocalBox(notifyJson, 'replies',
|
||||||
screenreader, systemLanguage, espeak,
|
screenreader, systemLanguage, espeak,
|
||||||
currRepliesIndex, 10, newRepliesExist)
|
currRepliesIndex, 10,
|
||||||
|
newRepliesExist, newDMsExist)
|
||||||
elif currTimeline == 'sent':
|
elif currTimeline == 'sent':
|
||||||
currSentIndex -= 10
|
currSentIndex -= 10
|
||||||
if currSentIndex < 0:
|
if currSentIndex < 0:
|
||||||
currSentIndex = 0
|
currSentIndex = 0
|
||||||
_showLocalBox(notifyJson, 'sent',
|
_showLocalBox(notifyJson, 'sent',
|
||||||
screenreader, systemLanguage, espeak,
|
screenreader, systemLanguage, espeak,
|
||||||
currSentIndex, 10, newRepliesExist)
|
currSentIndex, 10,
|
||||||
|
newRepliesExist, newDMsExist)
|
||||||
elif currTimeline == 'inbox':
|
elif currTimeline == 'inbox':
|
||||||
currInboxIndex -= 10
|
currInboxIndex -= 10
|
||||||
if currInboxIndex < 0:
|
if currInboxIndex < 0:
|
||||||
currInboxIndex = 0
|
currInboxIndex = 0
|
||||||
_showLocalBox(notifyJson, 'inbox',
|
_showLocalBox(notifyJson, 'inbox',
|
||||||
screenreader, systemLanguage, espeak,
|
screenreader, systemLanguage, espeak,
|
||||||
currInboxIndex, 10, newRepliesExist)
|
currInboxIndex, 10,
|
||||||
|
newRepliesExist, newDMsExist)
|
||||||
elif keyPress.startswith('read ') or keyPress == 'read':
|
elif keyPress.startswith('read ') or keyPress == 'read':
|
||||||
if keyPress == 'read':
|
if keyPress == 'read':
|
||||||
postIndexStr = '1'
|
postIndexStr = '1'
|
||||||
|
|
Loading…
Reference in New Issue