Browse Source

Various bug fixes

master
Igor Zhukov 10 years ago
parent
commit
2a6dcc1cd0
  1. 2
      README.md
  2. 20
      app/css/app.css
  3. 14
      app/css/desktop.css
  4. 32
      app/js/controllers.js
  5. 1
      app/js/locales/en-us.json
  6. 63
      app/js/services.js
  7. 2
      app/partials/desktop/error_modal.html
  8. 2
      app/partials/desktop/im.html
  9. 4
      app/partials/mobile/im.html
  10. 6
      app/partials/mobile/peer_select.html
  11. 2
      app/partials/mobile/user_modal.html

2
README.md

@ -22,7 +22,7 @@ Here are some screenshots of the interface:
### Unsupported at the moment ### Unsupported at the moment
* Secret chats * Secret chats
* Black list and blocking user * Black list
* ... * ...

20
app/css/app.css

@ -1467,6 +1467,10 @@ div.im_message_video_thumb {
background-position: -2px -542px; background-position: -2px -542px;
} }
.im_history_selectable a[ng-click] {
pointer-events: none;
}
.im_message_document_link_disabled { .im_message_document_link_disabled {
cursor: default; cursor: default;
pointer-events: none; pointer-events: none;
@ -2545,14 +2549,14 @@ ce671b orange
.user_color_8, .user_color_8,
.user_color_8:hover {color: #c07844;} .user_color_8:hover {color: #c07844;}
.user_bgcolor_1 {background: #e57979;} .user_bgcolor_1 {background: #cc90e2;}
.user_bgcolor_2 {background: #fba76f;} .user_bgcolor_2 {background: #80d066;}
.user_bgcolor_3 {background: #ecd074;} .user_bgcolor_3 {background: #ecd074;}
.user_bgcolor_4 {background: #80d066;} .user_bgcolor_4 {background: #6fb1e4;}
.user_bgcolor_5 {background: #73cdd0;} .user_bgcolor_5 {background: #e57979;}
.user_bgcolor_6 {background: #6fb1e4;} .user_bgcolor_6 {background: #f98bae;}
.user_bgcolor_7 {background: #cc90e2;} .user_bgcolor_7 {background: #73cdd0;}
.user_bgcolor_8 {background: #f98bae;} .user_bgcolor_8 {background: #fba76f;}
a.peer_photo_init:hover, a.peer_photo_init:hover,
a.peer_photo_init:active, a.peer_photo_init:active,
@ -2970,7 +2974,7 @@ div.peer_modal_photo {
} }
.peer_modal_photo .peer_initials { .peer_modal_photo .peer_initials {
line-height: 72px; line-height: 72px;
font-size: 17px; font-size: 22px;
} }
.peer_modal_profile_name { .peer_modal_profile_name {
font-size: 17px; font-size: 17px;

14
app/css/desktop.css

@ -545,9 +545,16 @@ a.im_panel_peer_photo {
margin-left: 12px; margin-left: 12px;
height: 55px; height: 55px;
} }
div.im_panel_own_photo { a.im_panel_own_photo {
display: block;
margin-right: 12px; margin-right: 12px;
} }
a.im_panel_own_photo .peer_initials,
div.im_panel_peer_photo .peer_initials,
a.im_panel_peer_photo .peer_initials {
font-size: 18px;
line-height: 50px;
}
.im_panel_peer_online { .im_panel_peer_online {
background: #6ec26d; background: #6ec26d;
@ -996,6 +1003,11 @@ div.im_panel_own_photo {
div.im_dialog_photo { div.im_dialog_photo {
margin-right: 12px; margin-right: 12px;
} }
div.im_dialog_photo .peer_initials {
line-height: 48px;
font-size: 18px;
}
.im_dialog_message { .im_dialog_message {
margin-top: 4px; margin-top: 4px;
} }

32
app/js/controllers.js

@ -307,7 +307,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
LayoutSwitchService.start(); LayoutSwitchService.start();
}) })
.controller('AppIMController', function ($scope, $location, $routeParams, $modal, $rootScope, $modalStack, MtpApiManager, AppUsersManager, AppChatsManager, ContactsSelectService, ChangelogNotifyService, ErrorService, AppRuntimeManager, HttpsMigrateService, LayoutSwitchService) { .controller('AppIMController', function ($scope, $location, $routeParams, $modal, $rootScope, $modalStack, MtpApiManager, AppUsersManager, AppChatsManager, AppPeersManager, ContactsSelectService, ChangelogNotifyService, ErrorService, AppRuntimeManager, HttpsMigrateService, LayoutSwitchService) {
$scope.$on('$routeUpdate', updateCurDialog); $scope.$on('$routeUpdate', updateCurDialog);
@ -316,7 +316,15 @@ angular.module('myApp.controllers', ['myApp.i18n'])
if (peerData.peerString == $scope.curDialog.peer && peerData.messageID == $scope.curDialog.messageID) { if (peerData.peerString == $scope.curDialog.peer && peerData.messageID == $scope.curDialog.messageID) {
$scope.$broadcast(peerData.messageID ? 'ui_history_change_scroll' : 'ui_history_focus'); $scope.$broadcast(peerData.messageID ? 'ui_history_change_scroll' : 'ui_history_focus');
} else { } else {
$location.url('/im?p=' + peerData.peerString + (peerData.messageID ? '&m=' + peerData.messageID : '')); var peerID = AppPeersManager.getPeerID(peerData.peerString);
var peer = peerData.peerString;
if (peerID > 0) {
var username = AppUsersManager.getUser(peerID).username;
if (username) {
peer = '@' + username;
}
}
$location.url('/im?p=' + peer + (peerData.messageID ? '&m=' + peerData.messageID : ''));
} }
}); });
@ -428,10 +436,22 @@ angular.module('myApp.controllers', ['myApp.i18n'])
} else { } else {
lastSearch = false; lastSearch = false;
} }
$scope.curDialog = { if ($routeParams.p && $routeParams.p.charAt(0) == '@') {
peer: $routeParams.p || false, if ($scope.curDialog === undefined) {
messageID: $routeParams.m || false $scope.curDialog = {};
}; }
AppUsersManager.resolveUsername($routeParams.p.substr(1)).then(function (userID) {
$scope.curDialog = {
peer: AppUsersManager.getUserString(userID),
messageID: $routeParams.m || false
};
});
} else {
$scope.curDialog = {
peer: $routeParams.p || false,
messageID: $routeParams.m || false
};
}
} }
ChangelogNotifyService.checkUpdate(); ChangelogNotifyService.checkUpdate();

1
app/js/locales/en-us.json

@ -240,6 +240,7 @@
"error_modal_phonebook_required_description": "Telegram needs access to phonebook to import contacts.", "error_modal_phonebook_required_description": "Telegram needs access to phonebook to import contacts.",
"error_modal_username_occupied_description": "Sorry, this username is already taken.", "error_modal_username_occupied_description": "Sorry, this username is already taken.",
"error_modal_media_not_supported_description": "Your browser cannot play this media file. Try downloading the file and opening it in a standalone player.", "error_modal_media_not_supported_description": "Your browser cannot play this media file. Try downloading the file and opening it in a standalone player.",
"error_modal_username_not_found_description": "There is no Telegram account with the username you provided.",
"error_modal_bad_request_description": "One of the params is missing or invalid.", "error_modal_bad_request_description": "One of the params is missing or invalid.",
"error_modal_unauthorized_description": "This action requires authorization access. Please {login-link: log in}.", "error_modal_unauthorized_description": "This action requires authorization access. Please {login-link: log in}.",

63
app/js/services.js

@ -11,8 +11,9 @@
angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
.service('AppUsersManager', function ($rootScope, $modal, $modalStack, $filter, $q, MtpApiFileManager, MtpApiManager, RichTextProcessor, SearchIndexManager, ErrorService, Storage, _) { .service('AppUsersManager', function ($rootScope, $modal, $modalStack, $filter, $q, qSync, MtpApiFileManager, MtpApiManager, RichTextProcessor, SearchIndexManager, ErrorService, Storage, _) {
var users = {}, var users = {},
usernames = {},
cachedPhotoLocations = {}, cachedPhotoLocations = {},
contactsFillPromise, contactsFillPromise,
contactsList, contactsList,
@ -73,6 +74,23 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
}); });
}; };
function userNameClean (username) {
return username && username.toLowerCase() || '';
}
function resolveUsername (username) {
var searchUserName = userNameClean(username);
var foundUserID = usernames[searchUserName];
if (foundUserID &&
userNameClean(users[foundUserID].username) == searchUserName) {
return qSync.when(foundUserID);
}
return MtpApiManager.invokeApi('contacts.resolveUsername', {username: username}).then(function (resolveResult) {
saveApiUser(resolveResult);
return resolveResult.id;
});
}
function saveApiUsers (apiUsers) { function saveApiUsers (apiUsers) {
angular.forEach(apiUsers, saveApiUser); angular.forEach(apiUsers, saveApiUser);
}; };
@ -83,11 +101,13 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
return; return;
} }
var userID = apiUser.id;
if (apiUser.phone) { if (apiUser.phone) {
apiUser.rPhone = $filter('phoneNumber')(apiUser.phone); apiUser.rPhone = $filter('phoneNumber')(apiUser.phone);
} }
apiUser.num = (Math.abs(apiUser.id) % 8) + 1; apiUser.num = (Math.abs(userID) % 8) + 1;
if (apiUser.first_name) { if (apiUser.first_name) {
apiUser.rFirstName = RichTextProcessor.wrapRichText(apiUser.first_name, {noLinks: true, noLinebreaks: true}); apiUser.rFirstName = RichTextProcessor.wrapRichText(apiUser.first_name, {noLinks: true, noLinebreaks: true});
@ -97,6 +117,10 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
apiUser.rFullName = RichTextProcessor.wrapRichText(apiUser.last_name, {noLinks: true, noLinebreaks: true}) || apiUser.rPhone || _('user_name_deleted'); apiUser.rFullName = RichTextProcessor.wrapRichText(apiUser.last_name, {noLinks: true, noLinebreaks: true}) || apiUser.rPhone || _('user_name_deleted');
} }
if (apiUser.username) {
usernames[userNameClean(apiUser.username)] = userID;
}
apiUser.sortName = SearchIndexManager.cleanSearchText(apiUser.first_name + ' ' + (apiUser.last_name || '')); apiUser.sortName = SearchIndexManager.cleanSearchText(apiUser.first_name + ' ' + (apiUser.last_name || ''));
var nameWords = apiUser.sortName.split(' '); var nameWords = apiUser.sortName.split(' ');
@ -107,15 +131,16 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
apiUser.sortStatus = getUserStatusForSort(apiUser.status); apiUser.sortStatus = getUserStatusForSort(apiUser.status);
if (users[apiUser.id] === undefined) { var result = users[userID];
users[apiUser.id] = apiUser; if (result === undefined) {
result = users[userID] = apiUser;
} else { } else {
safeReplaceObject(users[apiUser.id], apiUser); safeReplaceObject(result, apiUser);
} }
$rootScope.$broadcast('user_update', apiUser.id); $rootScope.$broadcast('user_update', userID);
if (cachedPhotoLocations[apiUser.id] !== undefined) { if (cachedPhotoLocations[userID] !== undefined) {
safeReplaceObject(cachedPhotoLocations[apiUser.id], apiUser && apiUser.photo && apiUser.photo.photo_small || {empty: true}); safeReplaceObject(cachedPhotoLocations[userID], apiUser && apiUser.photo && apiUser.photo.photo_small || {empty: true});
} }
}; };
@ -392,6 +417,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
deleteContacts: deleteContacts, deleteContacts: deleteContacts,
wrapForFull: wrapForFull, wrapForFull: wrapForFull,
openUser: openUser, openUser: openUser,
resolveUsername: resolveUsername,
openImportContact: openImportContact openImportContact: openImportContact
} }
}) })
@ -500,7 +526,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
var lastWord = titleWords.pop(); var lastWord = titleWords.pop();
apiChat.initials = firstWord.charAt(0) + (lastWord ? lastWord.charAt(0) : firstWord.charAt(1)); apiChat.initials = firstWord.charAt(0) + (lastWord ? lastWord.charAt(0) : firstWord.charAt(1));
apiChat.num = (Math.abs(apiChat.id) % 4) + 1; apiChat.num = (Math.abs(apiChat.id >> 1) % (Config.Mobile ? 4 : 8)) + 1;
if (chats[apiChat.id] === undefined) { if (chats[apiChat.id] === undefined) {
chats[apiChat.id] = apiChat; chats[apiChat.id] = apiChat;
@ -592,7 +618,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
} }
}) })
.service('AppPeersManager', function (AppUsersManager, AppChatsManager) { .service('AppPeersManager', function (AppUsersManager, AppChatsManager, MtpApiManager) {
return { return {
getInputPeer: function (peerString) { getInputPeer: function (peerString) {
var isUser = peerString.charAt(0) == 'u', var isUser = peerString.charAt(0) == 'u',
@ -4075,3 +4101,20 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
switchLayout: switchLayout switchLayout: switchLayout
} }
}) })
// .service('LocationParamsService', function ($routeParams) {
// var started = false;
// function start () {
// if (started) {
// return;
// }
// started = true;
// navigator.registerProtocolHandler('web+tg', '#im?tgaddr=%s', 'Telegram Web');
// };
// return {
// start: start
// };
// })

2
app/partials/desktop/error_modal.html

@ -4,6 +4,7 @@
<h4 ng-if="error" class="md_simple_header" ng-switch="error.type"> <h4 ng-if="error" class="md_simple_header" ng-switch="error.type">
<span ng-switch-when="MEDIA_TYPE_NOT_SUPPORTED" my-i18n="error_modal_media_not_supported_title"></span> <span ng-switch-when="MEDIA_TYPE_NOT_SUPPORTED" my-i18n="error_modal_media_not_supported_title"></span>
<span ng-switch-when="USERNAME_NOT_OCCUPIED" my-i18n="error_modal_not_found_title"></span>
<span ng-switch-default ng-switch="error.code"> <span ng-switch-default ng-switch="error.code">
<span ng-switch-when="400" my-i18n="error_modal_bad_request_title"></span> <span ng-switch-when="400" my-i18n="error_modal_bad_request_title"></span>
<span ng-switch-when="401" my-i18n="error_modal_unauthorized_title"></span> <span ng-switch-when="401" my-i18n="error_modal_unauthorized_title"></span>
@ -35,6 +36,7 @@
<span ng-switch-when="USERNAME_INVALID" my-i18n="error_modal_username_invalid_description"></span> <span ng-switch-when="USERNAME_INVALID" my-i18n="error_modal_username_invalid_description"></span>
<span ng-switch-when="USERNAME_OCCUPIED" my-i18n="error_modal_username_occupied_description"></span> <span ng-switch-when="USERNAME_OCCUPIED" my-i18n="error_modal_username_occupied_description"></span>
<span ng-switch-when="MEDIA_TYPE_NOT_SUPPORTED" my-i18n="error_modal_media_not_supported_description"></span> <span ng-switch-when="MEDIA_TYPE_NOT_SUPPORTED" my-i18n="error_modal_media_not_supported_description"></span>
<span ng-switch-when="USERNAME_NOT_OCCUPIED" my-i18n="error_modal_username_not_found_description"></span>
<div ng-switch-default ng-switch="error.code"> <div ng-switch-default ng-switch="error.code">

2
app/partials/desktop/im.html

@ -233,7 +233,7 @@
<a class="pull-right im_panel_peer_photo" my-peer-photolink="historyPeer.id" img-class="im_panel_peer_photo" watch="true"> <a class="pull-right im_panel_peer_photo" my-peer-photolink="historyPeer.id" img-class="im_panel_peer_photo" watch="true">
<i class="icon im_panel_peer_online" ng-show="historyPeer.id > 0 &amp;&amp; historyPeer.data.status._ == 'userStatusOnline'"></i> <i class="icon im_panel_peer_online" ng-show="historyPeer.id > 0 &amp;&amp; historyPeer.data.status._ == 'userStatusOnline'"></i>
</a> </a>
<div class="pull-left im_panel_own_photo" my-peer-photolink="ownID" img-class="im_panel_own_photo" watch="true"></div> <a class="pull-left im_panel_own_photo" my-peer-photolink="ownID" img-class="im_panel_own_photo" watch="true" ng-click="openSettings()" no-open="true"></a>
<form my-send-form draft-message="draftMessage" class="im_send_form" ng-class="{im_send_form_empty: !draftMessage.text.length}"> <form my-send-form draft-message="draftMessage" class="im_send_form" ng-class="{im_send_form_empty: !draftMessage.text.length}">

4
app/partials/mobile/im.html

@ -8,7 +8,9 @@
<div class="im_dialogs_panel"> <div class="im_dialogs_panel">
<div class="im_dialogs_search"> <div class="im_dialogs_search">
<input class="form-control im_dialogs_search_field no_outline" type="search" placeholder="{{'modal_search' | i18n}}" ng-model="search.query"/> <input class="form-control im_dialogs_search_field no_outline" type="search" placeholder="{{'modal_search' | i18n}}" ng-model="search.query"/>
<a class="im_dialogs_search_clear" ng-click="searchClear()" ng-show="search.query.length"></a> <a class="im_dialogs_search_clear" ng-click="searchClear()" ng-show="search.query.length">
<i class="im_dialogs_search_clear"></i>
</a>
</div> </div>
<div class="im_dialogs_tabs_wrap"> <div class="im_dialogs_tabs_wrap">

6
app/partials/mobile/peer_select.html

@ -32,8 +32,10 @@
<div class="im_dialogs_modal_col_wrap" ng-controller="AppImDialogsController" my-dialogs> <div class="im_dialogs_modal_col_wrap" ng-controller="AppImDialogsController" my-dialogs>
<div class="im_dialogs_panel"> <div class="im_dialogs_panel">
<div class="im_dialogs_search"> <div class="im_dialogs_search">
<input my-focused class="form-control im_dialogs_search_field" type="search" placeholder="{{'modal_search' | i18n}}" ng-model="search.query"/> <input my-focused class="form-control im_dialogs_search_field no_outline" type="search" placeholder="{{'modal_search' | i18n}}" ng-model="search.query"/>
<a class="im_dialogs_search_clear" ng-click="search.query = ''" ng-show="search.query.length"></a> <a class="im_dialogs_search_clear" ng-click="search.query = ''" ng-show="search.query.length">
<i class="im_dialogs_search_clear"></i>
</a>
</div> </div>
</div> </div>
<div my-dialogs-list-mobile modal="true" class="im_dialogs_modal_col im_dialogs_scrollable_wrap mobile_scrollable_wrap"> <div my-dialogs-list-mobile modal="true" class="im_dialogs_modal_col im_dialogs_scrollable_wrap mobile_scrollable_wrap">

2
app/partials/mobile/user_modal.html

@ -79,7 +79,7 @@
</a> </a>
</div> </div>
<div class="mobile_modal_section"> <div class="mobile_modal_section" ng-if="user.phone.length > 0">
<h4 class="mobile_modal_section_header" my-i18n="user_modal_phone"></h4> <h4 class="mobile_modal_section_header" my-i18n="user_modal_phone"></h4>
<div class="mobile_modal_section_value" ng-bind="user.phone | phoneNumber"></div> <div class="mobile_modal_section_value" ng-bind="user.phone | phoneNumber"></div>
</div> </div>

Loading…
Cancel
Save