Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEED HELP] Shows who has seen each message group #429

Merged
merged 7 commits into from
Nov 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/ui/css/yakyak/messages.less
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,31 @@
position: relative;
width: 66%;
margin-left: 25px;
.seen {
text-decoration: none;
font-size: 11px;
color: var(--darkgrey);
display: inline-block;
margin-right: 25px;
img, .initials {
object-fit: cover;
border-radius: 50%;
width: 25px;
height: 25px;
border: 5px solid var(--lightgrey);
color: var(--white);
background: var(--grey);
position: absolute;
bottom: 0px;
text-align: center;
font-size: 10px;
line-height: 41px;
text-transform: uppercase;
display: flex;
justify-content: center;
align-items: center;
}
}
.sender {
text-decoration: none;
font-size: 11px;
Expand Down
3 changes: 3 additions & 0 deletions src/ui/dispatcher.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ handle 'sendmessage', (txt = '') ->
handle 'toggleshowtray', ->
viewstate.setShowTray(not viewstate.showtray)

handle 'toggleshowseenstatus', ->
viewstate.setShowSeenStatus(not viewstate.showseenstatus)

handle 'togglemenu', ->
mainWindow = remote.getCurrentWindow()
if mainWindow.isMenuBarVisible() then mainWindow.setMenuBarVisibility(false) else mainWindow.setMenuBarVisibility(true)
Expand Down
7 changes: 6 additions & 1 deletion src/ui/models/viewstate.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = exp = {
startminimizedtotray: tryparse(localStorage.startminimizedtotray) or false
closetotray: tryparse(localStorage.closetotray) or false
showDockOnce: true
showseenstatus: tryparse(localStorage.showseenstatus) or false

setState: (state) ->
return if @state == state
Expand Down Expand Up @@ -114,6 +115,10 @@ module.exports = exp = {
@loggedin = val
updated 'viewstate'

setShowSeenStatus: (val) ->
@showseenstatus = localStorage.showseenstatus = !!val
updated 'viewstate'

setLastKeyDown: do ->
{TYPING, PAUSED, STOPPED} = Client.TypingStatus
lastEmitted = 0
Expand All @@ -138,7 +143,7 @@ module.exports = exp = {
action 'settyping', STOPPED
, 6000
, 6000

setShowConvMin: (doshow) ->
return if @showConvMin == doshow
@showConvMin = localStorage.showConvMin = doshow
Expand Down
12 changes: 12 additions & 0 deletions src/ui/views/menu.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,18 @@ templateView = (viewstate) ->
checked: viewstate.hidedockicon
click: -> action 'togglehidedockicon'
}
, {
label: 'Experimental'
submenu: [
{
label: 'Show seen status in messages'
type: 'checkbox'
enabled: viewstate.loggedin
checked: viewstate.showseenstatus
click: -> action 'toggleshowseenstatus'
}
]
}
].filter (n) -> n != undefined

templateWindow = (viewstate) -> [
Expand Down
30 changes: 30 additions & 0 deletions src/ui/views/messages.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,31 @@ module.exports = view (models) ->
clz.push 'self' if entity.isSelf(u.cid)
div class:clz.join(' '), ->
drawAvatar u, sender, viewstate, entity
if entity.isSelf(u.cid)
drawSeenElement(c, u, entity, events, viewstate)
div class:'umessages', ->
drawMessage(e, entity) for e in events
, onDOMSubtreeModified: (e) ->
window.twemoji?.parse e.target if process.platform == 'win32'
unless entity.isSelf(u.cid)
drawSeenElement(c, u, entity, events)

if lastConv != conv_id
lastConv = conv_id
later atTopIfSmall

drawSeenElement = (c, u, entity, events, viewstate) ->
if viewstate?.showseenstatus
temp_set = new Set()
for contacts in c.read_state
other = contacts.participant_id.chat_id
if other != u.cid &&
!entity.isSelf(other) &&
# only add "seen" avatar if last message from group is seen
contacts.latest_read_timestamp >= events[events.length - 1].timestamp
if !temp_set.has(entity[other].id)
temp_set.add entity[other].id
drawSeenAvatar entity[other]

groupEventsByMessageType = (event) ->
res = []
Expand All @@ -149,6 +165,20 @@ groupEventsByMessageType = (event) ->
isMeMessage = (e) ->
e?.chat_message?.annotation?[0]?[0] == HANGOUT_ANNOTATION_TYPE.me_message

drawSeenAvatar = (u) ->
initials = initialsof u
span class: "seen"
, "data-id": u.id
, title: u.display_name
, ->
purl = u?.photo_url
if purl and !viewstate?.showAnimatedThumbs
purl += "?sz=25"
if purl
img src:fixlink(purl)
else
div class:'initials', initials

drawAvatar = (u, sender, viewstate, entity) ->
initials = initialsof entity[u.cid]
a href:linkto(u.cid), title:sender, {onclick}, class:'sender', ->
Expand Down