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

avoid using SVG for Sandstorm #2334

Merged
merged 1 commit into from
Feb 24, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Template.accountPreferences.events
KonchatNotification.getDesktopPermission()

'click .test-notifications': ->
KonchatNotification._showDesktop
KonchatNotification.notify
payload:
sender:
username: 'rocket.cat'
Expand Down
37 changes: 20 additions & 17 deletions packages/rocketchat-ui/lib/notification.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,31 @@
if Notification.permission != status
Notification.permission = status

# notificacoes HTML5
_showDesktop: (notification) ->
notify: (notification) ->
if window.Notification && Notification.permission == "granted"
getAvatarAsPng notification.payload.sender.username, (avatarImage) ->
n = new Notification notification.title,
icon: avatarImage
body: _.stripTags(notification.text)
n = new Notification notification.title,
icon: notification.icon or getAvatarUrlFromUsername notification.payload.sender.username
body: _.stripTags(notification.text)

if notification.payload?.rid?
n.onclick = ->
window.focus()
switch notification.payload.type
when 'd'
FlowRouter.go 'direct', {username: notification.payload.sender.username}
when 'c'
FlowRouter.go 'channel', {name: notification.payload.name}
when 'p'
FlowRouter.go 'group', {name: notification.payload.name}
if notification.payload?.rid?
n.onclick = ->
window.focus()
switch notification.payload.type
when 'd'
FlowRouter.go 'direct', {username: notification.payload.sender.username}
when 'c'
FlowRouter.go 'channel', {name: notification.payload.name}
when 'p'
FlowRouter.go 'group', {name: notification.payload.name}

showDesktop: (notification) ->
if not window.document.hasFocus?() and Meteor.user().status isnt 'busy'
KonchatNotification._showDesktop(notification)
if Meteor.settings.public.sandstorm
KonchatNotification.notify(notification)
else
getAvatarAsPng notification.payload.sender.username, (avatarAsPng) ->
notification.icon = avatarAsPng
KonchatNotification.notify(notification)

newMessage: ->
unless Session.equals('user_' + Meteor.userId() + '_status', 'busy') or Meteor.user()?.settings?.preferences?.disableNewMessageNotification
Expand Down