Browse Source

Merge branch 'master' into voice_recorder

master
Jovan Gerodetti 9 years ago
parent
commit
e5d434ba31
  1. 2
      app/js/controllers.js
  2. 43
      app/js/directives.js
  3. 23
      app/js/lib/mtproto.js
  4. 2
      app/js/lib/mtproto_wrapper.js
  5. 2
      app/js/lib/ng_utils.js
  6. 9
      app/js/services.js
  7. 56
      app/less/app.less
  8. 1
      app/partials/desktop/error_modal.html
  9. 23
      app/partials/desktop/full_gif.html

2
app/js/controllers.js

@ -1495,7 +1495,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1495,7 +1495,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
updateChannelActions();
}, function () {
safeReplaceObject($scope.state, {error: true});
safeReplaceObject($scope.state, {error: true, loaded: true});
});
}

43
app/js/directives.js

@ -3316,6 +3316,49 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -3316,6 +3316,49 @@ angular.module('myApp.directives', ['myApp.filters'])
};
})
.directive('myArcProgress', function () {
var html = '<svg class="progress-arc" viewPort="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg"><circle class="progress-arc-circle" fill="transparent" stroke-dashoffset="0"></circle><circle class="progress-arc-bar" fill="transparent" stroke-dashoffset="0"></circle></svg>';
return {
scope: {
progress: '=myArcProgress'
},
link: function ($scope, element, attrs) {
element
.html(html)
.addClass('progress-arc-wrap');
var svgEl = element[0].firstChild;
var circle = $('.progress-arc-circle', element);
var bar = $('.progress-arc-bar', element);
var width = attrs.width || 40;
var radius = width * 0.86;
var stroke = width * 0.14;
var center = width / 2;
$(svgEl).attr('width', width);
$(svgEl).attr('height', width);
circle.attr('cx', center);
circle.attr('cy', center);
circle.attr('r', radius);
circle.css({strokeWidth: stroke});
bar.attr('cx', center);
bar.attr('cy', center);
bar.attr('r', radius);
bar.css({strokeWidth: stroke});
var fullLen = 2 * Math.PI * radius;
$scope.$watch('progress', function (newProgress) {
var progress = newProgress / 100.0;
progress = Math.max(0.0, Math.min(progress, 1.0));
bar.css({strokeDasharray: (progress * fullLen) + ', ' + ((1 - progress) * fullLen)});
});
}
}
})
.directive('myScrollToOn', function () {
return {

23
app/js/lib/mtproto.js

@ -208,18 +208,20 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) @@ -208,18 +208,20 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
var requestData = xhrSendBuffer ? resultBuffer : resultArray,
requestPromise;
var url = MtpDcConfigurator.chooseServer(dcID);
var baseError = {code: 406, type: 'NETWORK_BAD_RESPONSE', url: url};
try {
requestPromise = $http.post(MtpDcConfigurator.chooseServer(dcID), requestData, {
requestPromise = $http.post(url, requestData, {
responseType: 'arraybuffer',
transformRequest: null
});
} catch (e) {
requestPromise = $q.reject({code: 406, type: 'NETWORK_BAD_RESPONSE', originalError: e});
requestPromise = $q.reject(angular.extend(baseError, {originalError: e}));
}
return requestPromise.then(
function (result) {
if (!result.data || !result.data.byteLength) {
return $q.reject({code: 406, type: 'NETWORK_BAD_RESPONSE'});
return $q.reject(baseError);
}
try {
@ -230,14 +232,14 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) @@ -230,14 +232,14 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
var msg_len = deserializer.fetchInt('msg_len');
} catch (e) {
return $q.reject({code: 406, type: 'NETWORK_BAD_RESPONSE', originalError: e});
return $q.reject(angular.extend(baseError, {originalError: e}));
}
return deserializer;
},
function (error) {
if (!error.message && !error.type) {
error = {code: 406, type: 'NETWORK_BAD_REQUEST', originalError: error};
error = angular.extend(baseError, {originalError: error});
}
return $q.reject(error);
}
@ -286,7 +288,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) @@ -286,7 +288,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
deferred.reject(error);
});
}, function (error) {
console.log(dT(), 'req_pq error', error.message);
console.error(dT(), 'req_pq error', error.message);
deferred.reject(error);
});
@ -1201,19 +1203,22 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) @@ -1201,19 +1203,22 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
var requestData = xhrSendBuffer ? request.getBuffer() : request.getArray();
var requestPromise;
var url = MtpDcConfigurator.chooseServer(self.dcID, self.upload);
var baseError = {code: 406, type: 'NETWORK_BAD_RESPONSE', url: url};
try {
options = angular.extend(options || {}, {
responseType: 'arraybuffer',
transformRequest: null
});
requestPromise = $http.post(MtpDcConfigurator.chooseServer(self.dcID, self.upload), requestData, options);
requestPromise = $http.post(url, requestData, options);
} catch (e) {
requestPromise = $q.reject(e);
}
return requestPromise.then(
function (result) {
if (!result.data || !result.data.byteLength) {
return $q.reject({code: 406, type: 'NETWORK_BAD_RESPONSE'});
return $q.reject(baseError);
}
return result;
},
@ -1228,7 +1233,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils']) @@ -1228,7 +1233,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
});
}
if (!error.message && !error.type) {
error = {code: 406, type: 'NETWORK_BAD_REQUEST'};
error = angular.extend(baseError, {type: 'NETWORK_BAD_REQUEST', originalError: error});
}
return $q.reject(error);
}

2
app/js/lib/mtproto_wrapper.js

@ -216,7 +216,7 @@ angular.module('izhukov.mtproto.wrapper', ['izhukov.utils', 'izhukov.mtproto']) @@ -216,7 +216,7 @@ angular.module('izhukov.mtproto.wrapper', ['izhukov.utils', 'izhukov.mtproto'])
networker.wrapApiCall(method, params, options).then(function (result) {
deferred.resolve(result);
}, rejectPromise);
});
}, rejectPromise);
}
}
else if (!options.rawError && error.code == 420) {

2
app/js/lib/ng_utils.js

@ -1165,7 +1165,7 @@ angular.module('izhukov.utils', []) @@ -1165,7 +1165,7 @@ angular.module('izhukov.utils', [])
var usernameRegExp = "[a-zA-Z\\d_]{5,32}";
var botCommandRegExp = "\\/([a-zA-Z\\d_]{1,32})(?:@(" + usernameRegExp + "))?(\\b|$)"
var fullRegExp = new RegExp('(^| )(@)(' + usernameRegExp + ')|(' + urlRegExp + ')|(\\n)|(' + emojiRegExp + ')|(^|\\s)(#[' + alphaNumericRegExp + ']{2,64})|(^|\\s)' + botCommandRegExp, 'i');
var fullRegExp = new RegExp('(^| )(@)(' + usernameRegExp + ')|(' + urlRegExp + ')|(\\n)|(' + emojiRegExp + ')|(^|[\\s\\(\\]])(#[' + alphaNumericRegExp + ']{2,64})|(^|\\s)' + botCommandRegExp, 'i');
var emailRegExp = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
var youtubeRegExp = /^(?:https?:\/\/)?(?:www\.)?youtu(?:|\.be|be\.com|\.b)(?:\/v\/|\/watch\\?v=|e\/|(?:\/\??#)?\/watch(?:.+)v=)(.{11})(?:\&[^\s]*)?/;

9
app/js/services.js

@ -14,6 +14,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -14,6 +14,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
.service('AppUsersManager', function ($rootScope, $modal, $modalStack, $filter, $q, qSync, MtpApiFileManager, MtpApiManager, RichTextProcessor, ErrorService, Storage, _) {
var users = {},
usernames = {},
userAccess = {},
cachedPhotoLocations = {},
contactsFillPromise,
contactsList,
@ -151,6 +152,10 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -151,6 +152,10 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
}
};
function saveUserAccess (id, accessHash) {
userAccess[id] = accessHash;
}
function getUserStatusForSort(status) {
if (status) {
var expires = status.expires || status.was_online;
@ -175,7 +180,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -175,7 +180,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
if (angular.isObject(id)) {
return id;
}
return users[id] || {id: id, deleted: true, num: 1};
return users[id] || {id: id, deleted: true, num: 1, access_hash: userAccess[id]};
}
function getSelf() {
@ -464,6 +469,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -464,6 +469,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
getContacts: getContacts,
saveApiUsers: saveApiUsers,
saveApiUser: saveApiUser,
saveUserAccess: saveUserAccess,
getUser: getUser,
getSelf: getSelf,
getUserInput: getUserInput,
@ -834,6 +840,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -834,6 +840,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
peerParams = peerString.substr(1).split('_');
if (firstChar == 'u') {
AppUsersManager.saveUserAccess(peerParams[0], peerParams[1]);
return {
_: 'inputPeerUser',
user_id: peerParams[0],

56
app/less/app.less

@ -416,6 +416,62 @@ a { @@ -416,6 +416,62 @@ a {
}
}
.progress-arc-wrap {
display: block;
border-radius: 100%;
}
.progress-arc circle {
stroke-dashoffset: 0;
stroke: rgba(0,0,0,0.3);
stroke-width: 3px;
}
.progress-arc .progress-arc-bar {
stroke: #FFF;
transform-origin: center center;
transition: stroke-dasharray 500ms linear;
-webkit-animation: infinite_rotation 2s linear infinite;
-moz-animation: infinite_rotation 2s linear infinite;
-ms-animation: infinite_rotation 2s linear infinite;
animation: infinite_rotation 2s linear infinite;
}
/* Infinite rotation */
@-webkit-keyframes infinite_rotation {
0% {
transform: rotate(0);
}
100% {
transform: rotate(360deg);
}
}
@-moz-keyframes infinite_rotation {
0% {
transform: rotate(0);
}
100% {
transform: rotate(360deg);
}
}
@-ms-keyframes infinite_rotation {
0% {
transform: rotate(0);
}
100% {
transform: rotate(360deg);
}
}
@keyframes infinite_rotation {
0% {
transform: rotate(0);
}
100% {
transform: rotate(360deg);
}
}
.dropdown-menu {
border-radius: 2px;
padding: 0;

1
app/partials/desktop/error_modal.html

@ -63,6 +63,7 @@ @@ -63,6 +63,7 @@
<div ng-if="error" class="error_modal_details" ng-switch="error.detailsShown">
<textarea ng-switch-when="true" rows="3" onclick="this.select()">Method: {{error.input || 'N/A'}}
Url: {{error.url || 'N/A'}}
Result: {{error.originalError ? error.originalError : (error.stack ? (error.name || '') + ' ' + (error.description || error.message) : error)}}
Stack: {{error.originalError.stack || error.stack}}</textarea>
<div ng-switch-default>

23
app/partials/desktop/full_gif.html

@ -2,6 +2,14 @@ @@ -2,6 +2,14 @@
<div class="img_gif_image_wrap">
<div class="img_gif_meta" ng-show="!isActive" ng-switch="document.progress.enabled">
<div ng-switch-when="true" my-arc-progress="document.progress.percent"></div>
<div ng-switch-default class="img_gif_info_wrap">
<div class="img_gif_label pull-left">GIF</div>
<div ng-if="!document.downloaded" class="img_gif_size pull-right" ng-bind="::document.size | formatSize"></div>
</div>
</div>
<div ng-if="document.url" ng-show="document.downloaded &amp;&amp; isActive" ng-switch="document.mime_type == 'video/mp4'">
<video ng-switch-when="true" width="{{document.thumb.width}}" height="{{document.thumb.height}}" loop autoplay class="img_gif_video">
<source ng-src="{{document.url}}" type="video/mp4">
@ -12,19 +20,4 @@ @@ -12,19 +20,4 @@
</div>
<div ng-show="!isActive" ng-switch="document.progress.enabled">
<div ng-switch-when="true" class="img_gif_progress_wrap">
<div class="img_gif_progress progress tg_progress">
<div class="progress-bar progress-bar-success" ng-style="{width: document.progress.percent + '%'}"></div>
</div>
</div>
<div ng-switch-default class="img_gif_info_wrap">
<div class="img_gif_label pull-left">GIF</div>
<div ng-if="!document.downloaded" class="img_gif_size pull-right" ng-bind="::document.size | formatSize"></div>
</div>
</div>
</a>
Loading…
Cancel
Save