From c5be224add15398903ccc62d72de2eb600231626 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Mon, 23 Nov 2015 23:34:51 +0300 Subject: [PATCH] Bugfixes --- app/js/controllers.js | 5 +++++ app/js/lib/config.js | 1 + app/js/messages_manager.js | 16 +++++++--------- app/js/services.js | 18 +++++++++++++++--- app/manifest.webapp | 20 ++++++++++++++++---- gulpfile.js | 4 +++- 6 files changed, 47 insertions(+), 17 deletions(-) diff --git a/app/js/controllers.js b/app/js/controllers.js index 95b14850..b664ce43 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -2282,6 +2282,11 @@ angular.module('myApp.controllers', ['myApp.i18n']) forceDraft = $scope.curDialog.peer; $scope.draftMessage.fwdMessages = attachment.id; $scope.$broadcast('ui_peer_reply'); + var peerID = AppPeersManager.getPeerID($scope.curDialog.peer); + Storage.get('draft' + peerID).then(function (draftText) { + $scope.draftMessage.text = draftText || ''; + $scope.$broadcast('ui_peer_draft'); + }); } } diff --git a/app/js/lib/config.js b/app/js/lib/config.js index 57fc02e0..57cc215c 100644 --- a/app/js/lib/config.js +++ b/app/js/lib/config.js @@ -44,6 +44,7 @@ Config.Navigator = { (navigator.userAgent || '').toLowerCase().indexOf('mac') != -1, retina: window.devicePixelRatio > 1, ffos: navigator.userAgent.search(/mobi.+Gecko/i) != -1, + ffos2p: navigator.userAgent.search(/mobi.+Gecko\/[34567]/i) != -1, touch: screen.width <= 768 || ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch, mobile: screen.width && screen.width < 480 || navigator.userAgent.search(/iOS|iPhone OS|Android|BlackBerry|BB10|Series ?[64]0|J2ME|MIDP|opera mini|opera mobi|mobi.+Gecko|Windows Phone/i) != -1 }; diff --git a/app/js/messages_manager.js b/app/js/messages_manager.js index d6ad8397..b987f92a 100644 --- a/app/js/messages_manager.js +++ b/app/js/messages_manager.js @@ -9,7 +9,7 @@ angular.module('myApp.services') -.service('AppMessagesManager', function ($q, $rootScope, $location, $filter, $timeout, $sce, ApiUpdatesManager, AppUsersManager, AppChatsManager, AppPeersManager, AppPhotosManager, AppVideoManager, AppDocsManager, AppStickersManager, AppAudioManager, AppWebPagesManager, MtpApiManager, MtpApiFileManager, RichTextProcessor, NotificationsManager, PeersSelectService, Storage, AppProfileManager, FileManager, TelegramMeWebService, ErrorService, StatusManager, _) { +.service('AppMessagesManager', function ($q, $rootScope, $location, $filter, $timeout, $sce, ApiUpdatesManager, AppUsersManager, AppChatsManager, AppPeersManager, AppPhotosManager, AppVideoManager, AppDocsManager, AppStickersManager, AppAudioManager, AppWebPagesManager, MtpApiManager, MtpApiFileManager, RichTextProcessor, NotificationsManager, PeersSelectService, Storage, AppProfileManager, TelegramMeWebService, ErrorService, StatusManager, _) { var messagesStorage = {}; var messagesForHistory = {}; @@ -940,15 +940,14 @@ angular.module('myApp.services') function deleteMessages (messageIDs) { var splitted = splitMessageIDsByChannels(messageIDs); - debugger; var promises = []; angular.forEach(splitted.msgIDs, function (msgIDs, channelID) { var promise; if (channelID > 0) { var channel = AppChatsManager.getChat(channelID); - if (!channel.pFlags.creator) { + if (!channel.pFlags.creator && !(channel.pFlags.editor && channel.pFlags.megagroup)) { var goodMsgIDs = []; - if (channel.pFlags.editor) { + if (channel.pFlags.editor || channel.pFlags.megagroup) { angular.forEach(msgIDs, function (msgID, i) { var message = getMessage(splitted.mids[channelID][i]); if (message.pFlags.out) { @@ -2460,15 +2459,13 @@ angular.module('myApp.services') }; notification.message = notificationMessage; - notification.image = notificationPhoto.placeholder; notification.key = 'msg' + message.mid; notification.tag = peerString; if (notificationPhoto.location && !notificationPhoto.location.empty) { MtpApiFileManager.downloadSmallFile(notificationPhoto.location, notificationPhoto.size).then(function (blob) { - notification.image = FileManager.getUrl(blob, 'image/jpeg'); - if (message.pFlags.unread) { + notification.image = blob; NotificationsManager.notify(notification); } }); @@ -2478,6 +2475,7 @@ angular.module('myApp.services') } if (window.navigator.mozSetMessageHandler) { + console.warn('set message handler'); window.navigator.mozSetMessageHandler('activity', function(activityRequest) { var source = activityRequest.source; console.log(dT(), 'Received activity', source.name, source.data); @@ -2803,8 +2801,8 @@ angular.module('myApp.services') angular.forEach(historiesUpdated, function (updatedData, peerID) { var foundDialog = getDialogByPeerID(peerID); if (foundDialog) { - if (updatedData.pFlags.unread) { - foundDialog[0].unread_count -= updatedData.pFlags.unread; + if (updatedData.unread) { + foundDialog[0].unread_count -= updatedData.unread; $rootScope.$broadcast('dialog_unread', {peerID: peerID, count: foundDialog[0].unread_count}); } diff --git a/app/js/services.js b/app/js/services.js index d1e3a5b0..43e78b0f 100755 --- a/app/js/services.js +++ b/app/js/services.js @@ -2979,7 +2979,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) }) -.service('NotificationsManager', function ($rootScope, $window, $interval, $q, _, MtpApiManager, AppPeersManager, IdleManager, Storage, AppRuntimeManager) { +.service('NotificationsManager', function ($rootScope, $window, $interval, $q, _, MtpApiManager, AppPeersManager, IdleManager, Storage, AppRuntimeManager, FileManager) { navigator.vibrate = navigator.vibrate || navigator.mozVibrate || navigator.webkitVibrate; @@ -3204,12 +3204,24 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) // console.log('notify', $rootScope.idle.isIDLE, notificationsUiSupport); // FFOS Notification blob src bug workaround - if (Config.Navigator.ffos) { - data.image = 'https://raw.githubusercontent.com/zhukov/webogram/master/app/img/icons/icon60.png'; + if (Config.Navigator.ffos && !Config.Navigator.ffos2p) { + data.image = 'https://telegram.org/img/t_logo.png'; + } + else if (data.image && !angular.isString(data.image)) { + if (Config.Navigator.ffos2p) { + FileManager.getDataUrl(data.image, 'image/jpeg').then(function (url) { + data.image = url; + notify(data); + }); + return false; + } else { + data.image = FileManager.getUrl(data.image, 'image/jpeg'); + } } else if (!data.image) { data.image = 'img/icons/icon60.png'; } + console.log('notify image', data.image); notificationsCount++; diff --git a/app/manifest.webapp b/app/manifest.webapp index cdeb6bcd..7cc29de2 100644 --- a/app/manifest.webapp +++ b/app/manifest.webapp @@ -49,11 +49,23 @@ "activities": { "share": { "href": "/index.html", - "disposition": "window", "filters": { - "type": ["image/*","audio/*","video/*"] - }, - "returnValue": false + "type": ["image/*","audio/*","video/*", "url"], + "url": { + "required": true, + "regexp": "/^https?:/" + } + } + }, + "view": { + "href": "/index.html", + "filters": { + "type": "url", + "url": { + "required": true, + "regexp": "/^tg:/" + } + } } }, "orientation": "portrait-primary", diff --git a/gulpfile.js b/gulpfile.js index 74ac9834..4eef6acd 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -203,6 +203,8 @@ gulp.task('package-dev', function() { .pipe(gulp.dest('dist_package/img')), gulp.src('app/vendor/**/*') .pipe(gulp.dest('dist_package/vendor')), + gulp.src('app/**/*.json') + .pipe(gulp.dest('dist_package')), gulp.src('app/**/*.html') .pipe($.replace(/PRODUCTION_ONLY_BEGIN/g, 'PRODUCTION_ONLY_BEGIN-->')) @@ -210,7 +212,7 @@ gulp.task('package-dev', function() { .pipe(gulp.dest('dist_package')), gulp.src('app/**/*.js') - .pipe($.ngmin()) + .pipe($.ngAnnotate()) .pipe($.replace(/PRODUCTION_ONLY_BEGIN(\*\/)?/g, 'PRODUCTION_ONLY_BEGIN*/')) .pipe($.replace(/(\/\*)?PRODUCTION_ONLY_END/g, '/*PRODUCTION_ONLY_END')) .pipe(gulp.dest('dist_package'))