Browse Source

Update 2016-12-16T13:55:50.746Z

gh-pages
Igor Zhukov 8 years ago
parent
commit
1f92445d0a
  1. 3
      css/mobile.css
  2. 26
      js/app.js
  3. 72
      js/lib/push_worker.js
  4. 2
      js/locales/de-de.json
  5. 6
      js/locales/en-us.json
  6. 2
      js/locales/es-es.json
  7. 2
      js/locales/it-it.json
  8. 2
      js/locales/nl-nl.json
  9. 2
      js/locales/pt-br.json
  10. 2
      js/locales/ru-ru.json
  11. 2
      service_worker.js
  12. 2
      webogram.appcache

3
css/mobile.css

@ -881,6 +881,9 @@ a.im_dialog_selected .im_dialog_date {
font-size: 12px; font-size: 12px;
margin-right: 3px; margin-right: 3px;
} }
.im_dialog_message_wrap {
height: 51px;
}
.im_dialog_unread, .im_dialog_unread,
.active .im_dialog_unread, .active .im_dialog_unread,
a.im_dialog:hover .im_dialog_unread, a.im_dialog:hover .im_dialog_unread,

26
js/app.js

File diff suppressed because one or more lines are too long

72
js/lib/push_worker.js

@ -8,6 +8,9 @@ var lastAliveTime = false
var pendingNotification = false var pendingNotification = false
var muteUntil = false var muteUntil = false
var baseUrl var baseUrl
var settings
var lang = {}
switch (location.hostname) { switch (location.hostname) {
case 'localhost': case 'localhost':
baseUrl = 'http://localhost:8000/app/index.html#/im' baseUrl = 'http://localhost:8000/app/index.html#/im'
@ -24,7 +27,9 @@ self.addEventListener('push', function(event) {
var obj = event.data.json() var obj = event.data.json()
console.log('[SW] push', obj) console.log('[SW] push', obj)
if (!obj.badge) { if (!obj.badge) {
closeAllNotifications(obj, event) event.waitUntil(self.registration.showNotification('Telegram').then(function () {
return closeAllNotifications(obj)
}))
} else { } else {
fireNotification(obj, event) fireNotification(obj, event)
} }
@ -37,19 +42,30 @@ self.addEventListener('activate', function(event) {
self.addEventListener('message', function(event) { self.addEventListener('message', function(event) {
console.log('[SW] on message', event.data) console.log('[SW] on message', event.data)
port = event.ports[0] || event.source var client = event.ports[0] || event.source
if (event.data.type == 'alive') { if (event.data.type == 'ping') {
lastAliveTime = +(new Date()) if (event.data.localNotifications) {
lastAliveTime = +(new Date())
}
if (pendingNotification && if (pendingNotification &&
port && client &&
'postMessage' in port) { 'postMessage' in client) {
port.postMessage(pendingNotification) client.postMessage(pendingNotification)
pendingNotification = false pendingNotification = false
} }
if (event.data.lang) {
lang = event.data.lang
IDBManager.setItem('push_lang', lang)
}
if (event.data.settings) {
settings = event.data.settings
IDBManager.setItem('push_settings', settings)
}
} }
if (event.data.type == 'notifications_clear') { if (event.data.type == 'notifications_clear') {
closeAllNotifications(event.data, event) closeAllNotifications(event.data)
} }
if (event.data.baseUrl) { if (event.data.baseUrl) {
baseUrl = event.data.baseUrl baseUrl = event.data.baseUrl
@ -60,7 +76,7 @@ function fireNotification(obj, event) {
var nowTime = +(new Date()) var nowTime = +(new Date())
if (nowTime - lastAliveTime < 60000) { if (nowTime - lastAliveTime < 60000) {
console.log('Supress notification because some instance is alive') console.log('Supress notification because some instance is alive')
return false // return false
} }
if (muteUntil && nowTime < muteUntil) { if (muteUntil && nowTime < muteUntil) {
console.log('Supress notification because mute for ', (muteUntil - nowTime) / 60000, 'min') console.log('Supress notification because mute for ', (muteUntil - nowTime) / 60000, 'min')
@ -82,20 +98,27 @@ function fireNotification(obj, event) {
peerID = obj.custom && obj.custom.from_id || 0 peerID = obj.custom && obj.custom.from_id || 0
} }
obj.custom.peerID = peerID obj.custom.peerID = peerID
var tag = 'peer' + peerID
if (settings && settings.nopreview) {
title = 'Telegram'
body = lang.push_message_nopreview || 'You have a new message'
tag = 'unknown_peer'
}
var notificationPromise = self.registration.showNotification(title, { var notificationPromise = self.registration.showNotification(title, {
body: body, body: body,
icon: icon, icon: icon,
tag: 'peer' + peerID, tag: tag,
data: obj, data: obj,
actions: [ actions: [
{ {
action: 'mute1d', action: 'mute1d',
title: 'Mute background alerts for 1 day' title: lang.push_action_mute1d || 'Mute for 1D'
}, },
{ {
action: 'push_settings', action: 'push_settings',
title: 'Background alerts settings' title: lang.push_action_settings || 'Settings'
} }
] ]
}) })
@ -133,22 +156,24 @@ function removeFromNotifications(notification) {
} }
} }
function closeAllNotifications(obj, event) { function closeAllNotifications(obj) {
for (var i = 0, len = notifications.length; i < len; i++) { for (var i = 0, len = notifications.length; i < len; i++) {
try { try {
notifications[i].close() notifications[i].close()
} catch (e) {} } catch (e) {}
} }
event.waitUntil(self.registration.getNotifications({}).then(function(notifications) { var p = self.registration.getNotifications({}).then(function(notifications) {
for (var i = 0, len = notifications.length; i < len; i++) { for (var i = 0, len = notifications.length; i < len; i++) {
try { try {
notifications[i].close() notifications[i].close()
} catch (e) {} } catch (e) {}
} }
})) })
notifications = [] notifications = []
return p
} }
@ -161,7 +186,10 @@ self.addEventListener('notificationclick', function(event) {
if (action == 'mute1d') { if (action == 'mute1d') {
console.log('[SW] mute for 1d') console.log('[SW] mute for 1d')
muteUntil = +(new Date()) + 86400000 muteUntil = +(new Date()) + 86400000
IDBManager.setItem('mute_until', muteUntil.toString()) IDBManager.setItem('push_mute_until', muteUntil.toString())
return
}
if (!notification.data) {
return return
} }
@ -174,7 +202,7 @@ self.addEventListener('notificationclick', function(event) {
var client = clientList[i] var client = clientList[i]
if ('focus' in client) { if ('focus' in client) {
client.focus() client.focus()
;(port || client).postMessage(pendingNotification) client.postMessage(pendingNotification)
pendingNotification = false pendingNotification = false
return return
} }
@ -318,6 +346,14 @@ self.addEventListener('notificationclose', onCloseNotification)
IDBManager.getItem('mute_until').then(function (newMuteUntil) { IDBManager.getItem('push_mute_until').then(function (newMuteUntil) {
muteUntil = Math.max(muteUntil || 0, newMuteUntil || 0) || false muteUntil = Math.max(muteUntil || 0, newMuteUntil || 0) || false
})
IDBManager.getItem('push_lang').then(function (newLang) {
lang = newLang || {}
})
IDBManager.getItem('push_settings').then(function (newSettings) {
settings = newSettings || {}
}) })

2
js/locales/de-de.json

@ -55,10 +55,12 @@
"settings_modal_active_sessions": "Sitzungen", "settings_modal_active_sessions": "Sitzungen",
"settings_modal_settings": "Einstellungen", "settings_modal_settings": "Einstellungen",
"settings_modal_notification_alert": "Benachrichtigungen", "settings_modal_notification_alert": "Benachrichtigungen",
"settings_modal_notification_push": "Push-Mitteilungen",
"settings_modal_vibrate": "Vibrieren", "settings_modal_vibrate": "Vibrieren",
"settings_modal_sounds": "Töne", "settings_modal_sounds": "Töne",
"settings_modal_language": "Sprache", "settings_modal_language": "Sprache",
"settings_modal_notifications": "Desktopbenachrichtigungen", "settings_modal_notifications": "Desktopbenachrichtigungen",
"settings_modal_pushes": "Hintergrund-Benachrichtigungen",
"settings_modal_message_preview": "Nachrichtenvorschau", "settings_modal_message_preview": "Nachrichtenvorschau",
"settings_modal_sound": "Ton", "settings_modal_sound": "Ton",
"settings_modal_enter_send_description_md": "**Enter** - Nachricht senden, **Shift + Enter** - Zeilenumbruch", "settings_modal_enter_send_description_md": "**Enter** - Nachricht senden, **Shift + Enter** - Zeilenumbruch",

6
js/locales/en-us.json

@ -601,6 +601,12 @@
"inactive_description_md": "Telegram supports only one active tab with the app.\nPlease reload this page to continue using this tab or close it.", "inactive_description_md": "Telegram supports only one active tab with the app.\nPlease reload this page to continue using this tab or close it.",
"inactive_reload_btn": "Reload App", "inactive_reload_btn": "Reload App",
"push_action_mute1d": "Mute background alerts for 1 day",
"push_action_settings": "Background alerts settings",
"push_action_mute1d_mobile": "Mute for 24H",
"push_action_settings_mobile": "Alerts settings",
"push_message_nopreview": "You have a new message",
"country_select_modal_country_ab": "Abkhazia", "country_select_modal_country_ab": "Abkhazia",
"country_select_modal_country_af": "Afghanistan", "country_select_modal_country_af": "Afghanistan",

2
js/locales/es-es.json

@ -55,10 +55,12 @@
"settings_modal_active_sessions": "Sesiones activas", "settings_modal_active_sessions": "Sesiones activas",
"settings_modal_settings": "Ajustes", "settings_modal_settings": "Ajustes",
"settings_modal_notification_alert": "Alertas de notificaciones", "settings_modal_notification_alert": "Alertas de notificaciones",
"settings_modal_notification_push": "Notificaciones PUSH",
"settings_modal_vibrate": "Vibración", "settings_modal_vibrate": "Vibración",
"settings_modal_sounds": "Sonidos", "settings_modal_sounds": "Sonidos",
"settings_modal_language": "Idioma", "settings_modal_language": "Idioma",
"settings_modal_notifications": "Notificaciones de escritorio", "settings_modal_notifications": "Notificaciones de escritorio",
"settings_modal_pushes": "Notificaciones en segundo plano",
"settings_modal_message_preview": "Vista previa del mensaje", "settings_modal_message_preview": "Vista previa del mensaje",
"settings_modal_sound": "Sonido", "settings_modal_sound": "Sonido",
"settings_modal_enter_send_description_md": "**Intro** - enviar mensaje, **Shift + Intro** - nueva línea", "settings_modal_enter_send_description_md": "**Intro** - enviar mensaje, **Shift + Intro** - nueva línea",

2
js/locales/it-it.json

@ -55,10 +55,12 @@
"settings_modal_active_sessions": "Sessioni attive", "settings_modal_active_sessions": "Sessioni attive",
"settings_modal_settings": "Impostazioni", "settings_modal_settings": "Impostazioni",
"settings_modal_notification_alert": "Avvisi di notifica", "settings_modal_notification_alert": "Avvisi di notifica",
"settings_modal_notification_push": "Notifiche push",
"settings_modal_vibrate": "Vibra", "settings_modal_vibrate": "Vibra",
"settings_modal_sounds": "Suoni", "settings_modal_sounds": "Suoni",
"settings_modal_language": "Lingua", "settings_modal_language": "Lingua",
"settings_modal_notifications": "Notifiche desktop", "settings_modal_notifications": "Notifiche desktop",
"settings_modal_pushes": "Notifiche in background",
"settings_modal_message_preview": "Anteprima messaggio", "settings_modal_message_preview": "Anteprima messaggio",
"settings_modal_sound": "Suono", "settings_modal_sound": "Suono",
"settings_modal_enter_send_description_md": "**Invio** - invia messaggio, **Shift + Invio** - a capo", "settings_modal_enter_send_description_md": "**Invio** - invia messaggio, **Shift + Invio** - a capo",

2
js/locales/nl-nl.json

@ -55,10 +55,12 @@
"settings_modal_active_sessions": "Actieve sessies", "settings_modal_active_sessions": "Actieve sessies",
"settings_modal_settings": "Instellingen", "settings_modal_settings": "Instellingen",
"settings_modal_notification_alert": "Meldingswaarschuwingen", "settings_modal_notification_alert": "Meldingswaarschuwingen",
"settings_modal_notification_push": "PUSH-berichtgeving.",
"settings_modal_vibrate": "Trillen", "settings_modal_vibrate": "Trillen",
"settings_modal_sounds": "Geluiden", "settings_modal_sounds": "Geluiden",
"settings_modal_language": "Taal", "settings_modal_language": "Taal",
"settings_modal_notifications": "Desktopmeldingen", "settings_modal_notifications": "Desktopmeldingen",
"settings_modal_pushes": "Achtergrondberichtgeving",
"settings_modal_message_preview": "Voorvertoning", "settings_modal_message_preview": "Voorvertoning",
"settings_modal_sound": "Geluid", "settings_modal_sound": "Geluid",
"settings_modal_enter_send_description_md": "**Enter** - bericht versturen, **Shift + Enter** - nieuwe regel", "settings_modal_enter_send_description_md": "**Enter** - bericht versturen, **Shift + Enter** - nieuwe regel",

2
js/locales/pt-br.json

@ -55,10 +55,12 @@
"settings_modal_active_sessions": "Sessões ativas", "settings_modal_active_sessions": "Sessões ativas",
"settings_modal_settings": "Configurações", "settings_modal_settings": "Configurações",
"settings_modal_notification_alert": "Alertas de notificação", "settings_modal_notification_alert": "Alertas de notificação",
"settings_modal_notification_push": "Notificações PUSH",
"settings_modal_vibrate": "Vibrar", "settings_modal_vibrate": "Vibrar",
"settings_modal_sounds": "Sons", "settings_modal_sounds": "Sons",
"settings_modal_language": "Idioma", "settings_modal_language": "Idioma",
"settings_modal_notifications": "Notificações na área de trabalho", "settings_modal_notifications": "Notificações na área de trabalho",
"settings_modal_pushes": "Notificações em segundo plano",
"settings_modal_message_preview": "Pré-Visualização", "settings_modal_message_preview": "Pré-Visualização",
"settings_modal_sound": "Som", "settings_modal_sound": "Som",
"settings_modal_enter_send_description_md": "**Enter** - enviar mensagem, **Shift + Enter** - nova linha", "settings_modal_enter_send_description_md": "**Enter** - enviar mensagem, **Shift + Enter** - nova linha",

2
js/locales/ru-ru.json

@ -55,10 +55,12 @@
"settings_modal_active_sessions": "Активные сеансы", "settings_modal_active_sessions": "Активные сеансы",
"settings_modal_settings": "Настройки", "settings_modal_settings": "Настройки",
"settings_modal_notification_alert": "Сигналы уведомлений", "settings_modal_notification_alert": "Сигналы уведомлений",
"settings_modal_notification_push": "PUSH notifications",
"settings_modal_vibrate": "Вибросигнал", "settings_modal_vibrate": "Вибросигнал",
"settings_modal_sounds": "Звук", "settings_modal_sounds": "Звук",
"settings_modal_language": "Язык", "settings_modal_language": "Язык",
"settings_modal_notifications": "Уведомления на рабочем столе", "settings_modal_notifications": "Уведомления на рабочем столе",
"settings_modal_pushes": "Background notifications",
"settings_modal_message_preview": "Предпросмотр сообщений", "settings_modal_message_preview": "Предпросмотр сообщений",
"settings_modal_sound": "Звук", "settings_modal_sound": "Звук",
"settings_modal_enter_send_description_md": "**Enter** — отправить сообщение, **Shift + Enter** — новая строка", "settings_modal_enter_send_description_md": "**Enter** — отправить сообщение, **Shift + Enter** — новая строка",

2
service_worker.js

File diff suppressed because one or more lines are too long

2
webogram.appcache

@ -1,5 +1,5 @@
CACHE MANIFEST CACHE MANIFEST
# Time: Thu Dec 15 2016 22:13:46 GMT+0300 (MSK) # Time: Fri Dec 16 2016 16:53:27 GMT+0300 (MSK)
CACHE: CACHE:

Loading…
Cancel
Save