diff --git a/app/CHANGELOG.md b/app/CHANGELOG.md new file mode 100644 index 00000000..c0bc0fcd --- /dev/null +++ b/app/CHANGELOG.md @@ -0,0 +1,25 @@ +What's new? +=========== + + + + +version 2.0 +----------- + +* Updated settings + + +version 0.1.3, June 3rd, 2014 +----------------------------- + +* Added this welcome message +* Improved messages grouping +* Fixed video modal position bug +* Fixed mobile focus issues + + +version 0.0.1 +------------- + +* some very old stuff \ No newline at end of file diff --git a/app/css/app.css b/app/css/app.css index 4916de8a..7247b51c 100644 --- a/app/css/app.css +++ b/app/css/app.css @@ -3373,3 +3373,8 @@ ce671b orange } } + + +.changelog_new_version { + font-weight: bold; +} \ No newline at end of file diff --git a/app/js/controllers.js b/app/js/controllers.js index ec3df507..94192add 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -220,7 +220,7 @@ angular.module('myApp.controllers', []) }; }) - .controller('AppIMController', function ($scope, $location, $routeParams, $modal, $rootScope, $modalStack, MtpApiManager, AppUsersManager, ContactsSelectService, ErrorService) { + .controller('AppIMController', function ($scope, $location, $routeParams, $modal, $rootScope, $modalStack, MtpApiManager, AppUsersManager, ContactsSelectService, ChangelogNotifyService, ErrorService) { $scope.$on('$routeUpdate', updateCurDialog); @@ -289,6 +289,8 @@ angular.module('myApp.controllers', []) peer: $routeParams.p || false }; } + + ChangelogNotifyService.checkUpdate(); }) .controller('AppImDialogsController', function ($scope, $location, MtpApiManager, AppUsersManager, AppChatsManager, AppMessagesManager, AppPeersManager, ErrorService) { diff --git a/app/js/services.js b/app/js/services.js index abd20bca..09deec8c 100644 --- a/app/js/services.js +++ b/app/js/services.js @@ -3397,3 +3397,76 @@ angular.module('myApp.services', []) }, } }) + + +.service('ChangelogNotifyService', function (AppConfigManager, $rootScope, $http, $modal) { + + function versionCompare (ver1, ver2) { + if (typeof ver1 !== 'string') { + ver1 = ''; + } + if (typeof ver2 !== 'string') { + ver2 = ''; + } + // console.log('ss', ver1, ver2); + ver1 = ver1.replace(/^\s+|\s+$/g, '').split('.'); + ver2 = ver2.replace(/^\s+|\s+$/g, '').split('.'); + + var a = Math.max(ver1.length, ver2.length), i; + + for (i = 0; i < a; i++) { + if (ver1[i] == ver2[i]) { + continue; + } + if (ver1[i] > ver2[i]) { + return 1; + } else { + return -1; + } + } + + return 0; + } + + function checkUpdate () { + AppConfigManager.get('last_version').then(function (lastVersion) { + if (lastVersion != Config.App.version) { + $http.get('CHANGELOG.md').then(function (response) { + var changeLogText = response.data; + var matchesStart = changeLogText.match(/^([\s\S]+?\n)(?=version)/i), + changelog = []; + + changeLogText.replace(/(version ([\d\.]+)[\s\S]+?)(?=\nversion|$)/gi, function (whole, versionP, version) { + if (versionCompare(version, lastVersion) > 0) { + var contents = versionP.split(/\n\s*-{3,}\s*\n/); + + changelog.push({ + title: contents[0], + changes: contents[1].split(/\n?\s*\*\s*/g) + }); + } + }); + + if (changelog.length) { + var $scope = $rootScope.$new(); + + $scope.version = Config.App.version; + $scope.changelog = changelog; + + $modal.open({ + templateUrl: 'partials/changelog_modal.html', + scope: $scope, + windowClass: 'error_modal_window' + }); + } + + AppConfigManager.set({last_version: Config.App.version}); + }) + } + }) + } + + return { + checkUpdate: checkUpdate + } +}) diff --git a/app/partials/changelog_modal.html b/app/partials/changelog_modal.html new file mode 100644 index 00000000..6b627c18 --- /dev/null +++ b/app/partials/changelog_modal.html @@ -0,0 +1,29 @@ +<div class="error_modal_wrap" my-modal-position> + + <a class="modal-close-button" ng-click="$close()"><i></i></a> + + <div class="modal-body"> + + <h4 class="modal_simple_header"> + Telegram Web was updated + </h4> + + <div ng-repeat="versionChanges in changelog"> + <h4 ng-bind="versionChanges.title"></h4> + <ul ng-repeat="feature in versionChanges.changes"> + <li ng-bind="feature" ng-if="feature.length"></li> + </ul> + </div> + + </div> + + <div class="modal-footer"> + <div> + <div class="pull-left"> + New version is <span class="changelog_new_version" ng-bind="version"></span>. + </div> + <button type="button" class="btn btn-primary" ng-click="$dismiss()">Done</button> + </div> + </div> + +</div> \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 6d8fe6e3..39e84c1f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -41,7 +41,7 @@ gulp.task('copy-images', function() { gulp.task('copy', function() { return es.concat( - gulp.src(['app/favicon.ico', 'app/favicon_unread.ico', 'app/manifest.webapp', 'app/manifest.json', 'app/**/*worker.js']) + gulp.src(['app/favicon.ico', 'app/favicon_unread.ico', 'app/manifest.webapp', 'app/manifest.json', 'app/**/*worker.js', 'CHANGELOG.mdown']) .pipe(gulp.dest('dist')), gulp.src(['app/img/**/*.wav']) .pipe(gulp.dest('dist/img')),