From 829be1817f32b9057bbc240d6f3f8d01f650310d Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Mon, 4 Jul 2016 22:16:08 +0300 Subject: [PATCH] Bugfixes --- Makefile | 2 +- app/badbrowser.html | 3 +- app/index.html | 8 +---- app/js/directives.js | 36 +++++++++---------- app/js/lib/ng_utils.js | 4 --- app/js/lib/push_worker.js | 2 +- app/js/messages_manager.js | 17 ++++++--- app/partials/desktop/message.html | 2 +- app/partials/desktop/message_service.html | 2 +- app/partials/mobile/message.html | 2 +- app/partials/mobile/message_service.html | 2 +- .../jquery.nanoscroller/nanoscroller.js | 2 +- gulpfile.js | 36 +++++++++++-------- 13 files changed, 59 insertions(+), 59 deletions(-) diff --git a/Makefile b/Makefile index 6d326a8e..fa592d8c 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ ghdist: cd dist && git checkout gh-pages publish: - ./node_modules/gulp/bin/gulp.js build + ./node_modules/gulp/bin/gulp.js publish echo -n "Please open http://localhost:8000/dist/index.html and check if everything works fine." && read -e ./node_modules/gulp/bin/gulp.js deploy diff --git a/app/badbrowser.html b/app/badbrowser.html index f5e0acfc..d2af7f05 100644 --- a/app/badbrowser.html +++ b/app/badbrowser.html @@ -5,8 +5,7 @@ Telegram Web - - + diff --git a/app/index.html b/app/index.html index 3a51073e..9db2902e 100644 --- a/app/index.html +++ b/app/index.html @@ -1,5 +1,5 @@ - + diff --git a/app/js/directives.js b/app/js/directives.js index c167a681..92c5bc64 100755 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -501,28 +501,24 @@ angular.module('myApp.directives', ['myApp.filters']) .directive('myReplyMessage', function (AppMessagesManager, AppPeersManager, $rootScope) { return { templateUrl: templateUrl('reply_message'), - scope: { - 'replyMessage': '=myReplyMessage' - }, + scope: {}, link: link } function link ($scope, element, attrs) { if (attrs.watch) { - $scope.$watch('replyMessage', function () { - checkMessage($scope, element) + $scope.$parent.$watch(attrs.myReplyMessage, function (mid) { + checkMessage($scope, element, mid) }) } else { - checkMessage($scope, element) + var mid = $scope.$parent.$eval(attrs.myReplyMessage) + checkMessage($scope, element, mid) } } - function checkMessage ($scope, element) { - var message = $scope.replyMessage - if (!message.loading) { - updateMessage($scope, element) - } else { - var mid = message.mid + function checkMessage ($scope, element, mid) { + var message = $scope.replyMessage = AppMessagesManager.wrapSingleMessage(mid) + if (message.loading) { var stopWaiting = $scope.$on('messages_downloaded', function (e, mids) { if (mids.indexOf(mid) != -1) { $scope.replyMessage = AppMessagesManager.wrapForDialog(mid) @@ -530,6 +526,8 @@ angular.module('myApp.directives', ['myApp.filters']) stopWaiting() } }) + } else { + updateMessage($scope, element) } } @@ -559,18 +557,14 @@ angular.module('myApp.directives', ['myApp.filters']) .directive('myPinnedMessage', function (AppMessagesManager, AppPeersManager, $rootScope) { return { templateUrl: templateUrl('pinned_message'), - scope: { - 'pinnedMessage': '=myPinnedMessage' - }, + scope: {}, link: link } function link ($scope, element, attrs) { - var message = $scope.pinnedMessage - if (!message.loading) { - updateMessage($scope, element) - } else { - var mid = message.mid + var mid = $scope.$parent.$eval(attrs.myPinnedMessage) + var message = $scope.pinnedMessage = AppMessagesManager.wrapSingleMessage(mid) + if (message.loading) { var stopWaiting = $scope.$on('messages_downloaded', function (e, mids) { if (mids.indexOf(mid) != -1) { $scope.pinnedMessage = AppMessagesManager.wrapForDialog(mid) @@ -578,6 +572,8 @@ angular.module('myApp.directives', ['myApp.filters']) stopWaiting() } }) + } else { + updateMessage($scope, element) } } diff --git a/app/js/lib/ng_utils.js b/app/js/lib/ng_utils.js index 86857dc8..fa377bd4 100644 --- a/app/js/lib/ng_utils.js +++ b/app/js/lib/ng_utils.js @@ -1455,8 +1455,6 @@ angular.module('izhukov.utils', []) if (!entities.length) { newText = newText.trim() } - console.warn(dT(), newText, entities); - // throw new Error(11); return newText } @@ -1819,8 +1817,6 @@ angular.module('izhukov.utils', []) code.push(text.substr(lastOffset)) - console.log(code, entities) - return code.join('') } diff --git a/app/js/lib/push_worker.js b/app/js/lib/push_worker.js index bfddf08c..4b322000 100644 --- a/app/js/lib/push_worker.js +++ b/app/js/lib/push_worker.js @@ -1 +1 @@ -console.log('push worker') +console.log('push worker placeholder') diff --git a/app/js/messages_manager.js b/app/js/messages_manager.js index c4e47291..604b9e29 100644 --- a/app/js/messages_manager.js +++ b/app/js/messages_manager.js @@ -213,8 +213,10 @@ angular.module('myApp.services') var offsetDate = 0 var offsetID = 0 var offsetPeerID = 0 + var offsetIndex = 0 if (dialogsOffsetDate) { offsetDate = dialogsOffsetDate + ServerTimeManager.serverTimeOffset + offsetIndex = dialogsOffsetDate * 0x10000 } return MtpApiManager.invokeApi('messages.getDialogs', { offset_date: offsetDate, @@ -233,8 +235,13 @@ angular.module('myApp.services') saveMessages(dialogsResult.messages) var maxSeenIdIncremented = offsetDate ? true : false + var hasPrepend = false angular.forEach(dialogsResult.dialogs, function (dialog) { saveConversation(dialog) + if (offsetIndex && dialog.index > offsetIndex) { + newDialogsToHandle[dialog.peerID] = dialog + hasPrepend = true + } if (!maxSeenIdIncremented && !AppPeersManager.isChannel(AppPeersManager.getPeerID(dialog.peer))) { @@ -248,6 +255,11 @@ angular.module('myApp.services') dialogs.length >= dialogsResult.count) { allDialogsLoaded = true } + + if (hasPrepend && + !newDialogsHandlePromise) { + newDialogsHandlePromise = $timeout(handleNewDialogs, 0) + } }) } @@ -2143,11 +2155,6 @@ angular.module('myApp.services') } } - var replyToMsgID = message.reply_to_mid - if (replyToMsgID) { - message.reply_to_msg = wrapSingleMessage(replyToMsgID) - } - return messagesForHistory[msgID] = message } diff --git a/app/partials/desktop/message.html b/app/partials/desktop/message.html index f89e1f1f..456e7d64 100644 --- a/app/partials/desktop/message.html +++ b/app/partials/desktop/message.html @@ -48,7 +48,7 @@ - +
diff --git a/app/partials/desktop/message_service.html b/app/partials/desktop/message_service.html index 53a85f58..c48a7ab7 100644 --- a/app/partials/desktop/message_service.html +++ b/app/partials/desktop/message_service.html @@ -31,7 +31,7 @@ - + diff --git a/app/partials/mobile/message.html b/app/partials/mobile/message.html index 25c9948f..3754a7df 100644 --- a/app/partials/mobile/message.html +++ b/app/partials/mobile/message.html @@ -46,7 +46,7 @@ - +
diff --git a/app/partials/mobile/message_service.html b/app/partials/mobile/message_service.html index f9e5410f..9256633e 100644 --- a/app/partials/mobile/message_service.html +++ b/app/partials/mobile/message_service.html @@ -31,7 +31,7 @@ - + diff --git a/app/vendor/jquery.nanoscroller/nanoscroller.js b/app/vendor/jquery.nanoscroller/nanoscroller.js index 9359f817..7fec87b5 100644 --- a/app/vendor/jquery.nanoscroller/nanoscroller.js +++ b/app/vendor/jquery.nanoscroller/nanoscroller.js @@ -1,7 +1,7 @@ /*! nanoScrollerJS - v0.8.4 - 2014 * http://jamesflorentino.github.com/nanoScrollerJS/ * Copyright (c) 2014 James Florentino; Licensed MIT */ -(function($, window, document) { +;(function($, window, document) { "use strict"; var BROWSER_IS_IE7, BROWSER_SCROLLBAR_WIDTH, DOMSCROLL, DOWN, DRAG, ENTER, KEYDOWN, KEYUP, MOUSEDOWN, MOUSEENTER, MOUSEMOVE, MOUSEUP, MOUSEWHEEL, NanoScroll, PANEDOWN, RESIZE, SCROLL, SCROLLBAR, TOUCHMOVE, UP, WHEEL, cAF, defaults, getBrowserScrollbarWidth, hasTransform, isFFWithBuggyScrollbar, rAF, transform, _elementStyle, _prefixStyle, _vendor; defaults = { diff --git a/gulpfile.js b/gulpfile.js index dd1aed53..248320c1 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -7,6 +7,8 @@ var http = require('http') var st = require('st') var del = require('del') var runSequence = require('run-sequence') +var swPrecache = require('sw-precache') + // The generated file is being created at src // so it can be fetched by usemin. @@ -19,6 +21,19 @@ gulp.task('templates', function () { })) .pipe(gulp.dest('app/js')) }) +gulp.task('clean-templates', function () { + return del(['app/js/templates.js']) +}) + +gulp.task('usemin-index', function () { + return gulp.src('app/index.html') + .pipe($.usemin({ + html: [$.minifyHtml({empty: true})], + js: ['concat', $.ngAnnotate()/*, $.uglify({outSourceMap: false})*/], + css: ['concat', $.minifyCss({compatibility: true, keepBreaks: true})] + })) + .pipe(gulp.dest('dist')) +}) gulp.task('usemin-badbrowser', function() { return gulp.src('app/badbrowser.html') @@ -29,16 +44,6 @@ gulp.task('usemin-badbrowser', function() { .pipe(gulp.dest('dist')); }); -gulp.task('usemin', function () { - return gulp.src('app/index.html') - .pipe($.usemin({ - html: [$.minifyHtml({empty: true})], - js: ['concat', $.ngAnnotate(), $.uglify({outSourceMap: false})], - css: ['concat', $.minifyCss({compatibility: true, keepBreaks: true})] - })) - .pipe(gulp.dest('dist')) -}) - // ulimit -n 10240 on OS X gulp.task('imagemin', function () { return gulp.src(['app/img/**/*', '!app/img/screenshot*', '!app/img/*.wav']) @@ -172,7 +177,8 @@ var fileGlobs = [ '!dist/*.html', '!dist/fonts/*', '!dist/img/icons/icon*.png', - '!dist/js/background.js' + '!dist/js/background.js', + '!dist/css/badbrowser.css' ] function writeServiceWorkerFile (rootDir, handleFetch, callback) { @@ -181,7 +187,8 @@ function writeServiceWorkerFile (rootDir, handleFetch, callback) { handleFetch: handleFetch, logger: $.util.log, staticFileGlobs: fileGlobs, - stripPrefix: rootDir + '/', + stripPrefix: './' + rootDir + '/', + importScripts: ['js/lib/push_worker.js'], verbose: true } swPrecache.write(path.join(rootDir, 'service_worker.js'), config, callback) @@ -272,16 +279,17 @@ gulp.task('build', ['clean'], function (callback) { runSequence( ['less', 'templates'], 'enable-production', - 'usemin', + 'usemin-index', 'usemin-badbrowser', ['copy', 'copy-locales', 'copy-images', 'disable-production'], + 'clean-templates', callback ) }) gulp.task('package', ['cleanup-dist']) -gulp.task('offline', ['add-appcache-manifest', 'generate-service-worker']) +gulp.task('publish', ['add-appcache-manifest', 'generate-service-worker']) gulp.task('deploy', function () { return gulp.src('./dist/**/*')