Browse Source

Bugfixes

master
Igor Zhukov 9 years ago
parent
commit
c5be224add
  1. 5
      app/js/controllers.js
  2. 1
      app/js/lib/config.js
  3. 16
      app/js/messages_manager.js
  4. 18
      app/js/services.js
  5. 20
      app/manifest.webapp
  6. 4
      gulpfile.js

5
app/js/controllers.js

@ -2282,6 +2282,11 @@ angular.module('myApp.controllers', ['myApp.i18n'])
forceDraft = $scope.curDialog.peer; forceDraft = $scope.curDialog.peer;
$scope.draftMessage.fwdMessages = attachment.id; $scope.draftMessage.fwdMessages = attachment.id;
$scope.$broadcast('ui_peer_reply'); $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');
});
} }
} }

1
app/js/lib/config.js

@ -44,6 +44,7 @@ Config.Navigator = {
(navigator.userAgent || '').toLowerCase().indexOf('mac') != -1, (navigator.userAgent || '').toLowerCase().indexOf('mac') != -1,
retina: window.devicePixelRatio > 1, retina: window.devicePixelRatio > 1,
ffos: navigator.userAgent.search(/mobi.+Gecko/i) != -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, 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 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
}; };

16
app/js/messages_manager.js

@ -9,7 +9,7 @@
angular.module('myApp.services') 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 messagesStorage = {};
var messagesForHistory = {}; var messagesForHistory = {};
@ -940,15 +940,14 @@ angular.module('myApp.services')
function deleteMessages (messageIDs) { function deleteMessages (messageIDs) {
var splitted = splitMessageIDsByChannels(messageIDs); var splitted = splitMessageIDsByChannels(messageIDs);
debugger;
var promises = []; var promises = [];
angular.forEach(splitted.msgIDs, function (msgIDs, channelID) { angular.forEach(splitted.msgIDs, function (msgIDs, channelID) {
var promise; var promise;
if (channelID > 0) { if (channelID > 0) {
var channel = AppChatsManager.getChat(channelID); var channel = AppChatsManager.getChat(channelID);
if (!channel.pFlags.creator) { if (!channel.pFlags.creator && !(channel.pFlags.editor && channel.pFlags.megagroup)) {
var goodMsgIDs = []; var goodMsgIDs = [];
if (channel.pFlags.editor) { if (channel.pFlags.editor || channel.pFlags.megagroup) {
angular.forEach(msgIDs, function (msgID, i) { angular.forEach(msgIDs, function (msgID, i) {
var message = getMessage(splitted.mids[channelID][i]); var message = getMessage(splitted.mids[channelID][i]);
if (message.pFlags.out) { if (message.pFlags.out) {
@ -2460,15 +2459,13 @@ angular.module('myApp.services')
}; };
notification.message = notificationMessage; notification.message = notificationMessage;
notification.image = notificationPhoto.placeholder;
notification.key = 'msg' + message.mid; notification.key = 'msg' + message.mid;
notification.tag = peerString; notification.tag = peerString;
if (notificationPhoto.location && !notificationPhoto.location.empty) { if (notificationPhoto.location && !notificationPhoto.location.empty) {
MtpApiFileManager.downloadSmallFile(notificationPhoto.location, notificationPhoto.size).then(function (blob) { MtpApiFileManager.downloadSmallFile(notificationPhoto.location, notificationPhoto.size).then(function (blob) {
notification.image = FileManager.getUrl(blob, 'image/jpeg');
if (message.pFlags.unread) { if (message.pFlags.unread) {
notification.image = blob;
NotificationsManager.notify(notification); NotificationsManager.notify(notification);
} }
}); });
@ -2478,6 +2475,7 @@ angular.module('myApp.services')
} }
if (window.navigator.mozSetMessageHandler) { if (window.navigator.mozSetMessageHandler) {
console.warn('set message handler');
window.navigator.mozSetMessageHandler('activity', function(activityRequest) { window.navigator.mozSetMessageHandler('activity', function(activityRequest) {
var source = activityRequest.source; var source = activityRequest.source;
console.log(dT(), 'Received activity', source.name, source.data); console.log(dT(), 'Received activity', source.name, source.data);
@ -2803,8 +2801,8 @@ angular.module('myApp.services')
angular.forEach(historiesUpdated, function (updatedData, peerID) { angular.forEach(historiesUpdated, function (updatedData, peerID) {
var foundDialog = getDialogByPeerID(peerID); var foundDialog = getDialogByPeerID(peerID);
if (foundDialog) { if (foundDialog) {
if (updatedData.pFlags.unread) { if (updatedData.unread) {
foundDialog[0].unread_count -= updatedData.pFlags.unread; foundDialog[0].unread_count -= updatedData.unread;
$rootScope.$broadcast('dialog_unread', {peerID: peerID, count: foundDialog[0].unread_count}); $rootScope.$broadcast('dialog_unread', {peerID: peerID, count: foundDialog[0].unread_count});
} }

18
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; 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); // console.log('notify', $rootScope.idle.isIDLE, notificationsUiSupport);
// FFOS Notification blob src bug workaround // FFOS Notification blob src bug workaround
if (Config.Navigator.ffos) { if (Config.Navigator.ffos && !Config.Navigator.ffos2p) {
data.image = 'https://raw.githubusercontent.com/zhukov/webogram/master/app/img/icons/icon60.png'; 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) { else if (!data.image) {
data.image = 'img/icons/icon60.png'; data.image = 'img/icons/icon60.png';
} }
console.log('notify image', data.image);
notificationsCount++; notificationsCount++;

20
app/manifest.webapp

@ -49,11 +49,23 @@
"activities": { "activities": {
"share": { "share": {
"href": "/index.html", "href": "/index.html",
"disposition": "window",
"filters": { "filters": {
"type": ["image/*","audio/*","video/*"] "type": ["image/*","audio/*","video/*", "url"],
}, "url": {
"returnValue": false "required": true,
"regexp": "/^https?:/"
}
}
},
"view": {
"href": "/index.html",
"filters": {
"type": "url",
"url": {
"required": true,
"regexp": "/^tg:/"
}
}
} }
}, },
"orientation": "portrait-primary", "orientation": "portrait-primary",

4
gulpfile.js

@ -203,6 +203,8 @@ gulp.task('package-dev', function() {
.pipe(gulp.dest('dist_package/img')), .pipe(gulp.dest('dist_package/img')),
gulp.src('app/vendor/**/*') gulp.src('app/vendor/**/*')
.pipe(gulp.dest('dist_package/vendor')), .pipe(gulp.dest('dist_package/vendor')),
gulp.src('app/**/*.json')
.pipe(gulp.dest('dist_package')),
gulp.src('app/**/*.html') gulp.src('app/**/*.html')
.pipe($.replace(/PRODUCTION_ONLY_BEGIN/g, 'PRODUCTION_ONLY_BEGIN-->')) .pipe($.replace(/PRODUCTION_ONLY_BEGIN/g, 'PRODUCTION_ONLY_BEGIN-->'))
@ -210,7 +212,7 @@ gulp.task('package-dev', function() {
.pipe(gulp.dest('dist_package')), .pipe(gulp.dest('dist_package')),
gulp.src('app/**/*.js') gulp.src('app/**/*.js')
.pipe($.ngmin()) .pipe($.ngAnnotate())
.pipe($.replace(/PRODUCTION_ONLY_BEGIN(\*\/)?/g, 'PRODUCTION_ONLY_BEGIN*/')) .pipe($.replace(/PRODUCTION_ONLY_BEGIN(\*\/)?/g, 'PRODUCTION_ONLY_BEGIN*/'))
.pipe($.replace(/(\/\*)?PRODUCTION_ONLY_END/g, '/*PRODUCTION_ONLY_END')) .pipe($.replace(/(\/\*)?PRODUCTION_ONLY_END/g, '/*PRODUCTION_ONLY_END'))
.pipe(gulp.dest('dist_package')) .pipe(gulp.dest('dist_package'))

Loading…
Cancel
Save