Browse Source

Fixed short updates, improved styles

master
Igor Zhukov 11 years ago
parent
commit
deae4717a6
  1. 1
      app/css/app.css
  2. 8
      app/index.html
  3. 2
      app/js/app.js
  4. 2
      app/js/controllers.js
  5. 43
      app/js/services.js
  6. 2
      app/partials/im.html

1
app/css/app.css

@ -172,6 +172,7 @@ fieldset[disabled] .btn-tg.active { @@ -172,6 +172,7 @@ fieldset[disabled] .btn-tg.active {
overflow-y: auto;
}
.modal-content {
border: 0;
border-radius: 4px;
-webkit-box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);

8
app/index.html

@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
<link rel="stylesheet" href="vendor/angular/angular-csp.css"/>
<link rel="stylesheet" href="vendor/bootstrap/css/bootstrap.css"/>
<link rel="stylesheet" href="vendor/jquery.nanoscroller/nanoscroller.css"/>
<link rel="stylesheet" href="css/app.css?2"/>
<link rel="stylesheet" href="css/app.css?3"/>
<link rel="icon" href="favicon.ico" type="image/x-icon">
</head>
<body>
@ -36,9 +36,9 @@ @@ -36,9 +36,9 @@
<script type="text/javascript" src="js/lib/mtproto.js?1"></script>
<script type="text/javascript" src="js/util.js"></script>
<script type="text/javascript" src="js/app.js?1"></script>
<script type="text/javascript" src="js/services.js?4"></script>
<script type="text/javascript" src="js/controllers.js?3"></script>
<script type="text/javascript" src="js/app.js?2"></script>
<script type="text/javascript" src="js/services.js?5"></script>
<script type="text/javascript" src="js/controllers.js?4"></script>
<script type="text/javascript" src="js/filters.js?2"></script>
<script type="text/javascript" src="js/directives.js?4"></script>

2
app/js/app.js

@ -49,7 +49,7 @@ config(['$locationProvider', '$routeProvider', '$compileProvider', function($loc @@ -49,7 +49,7 @@ config(['$locationProvider', '$routeProvider', '$compileProvider', function($loc
// $locationProvider.html5Mode(true);
$routeProvider.when('/', {templateUrl: 'partials/welcome.html', controller: 'AppWelcomeController'});
$routeProvider.when('/login', {templateUrl: 'partials/login.html?1', controller: 'AppLoginController'});
$routeProvider.when('/im', {templateUrl: 'partials/im.html?1', controller: 'AppIMController', reloadOnSearch: false});
$routeProvider.when('/im', {templateUrl: 'partials/im.html?2', controller: 'AppIMController', reloadOnSearch: false});
$routeProvider.otherwise({redirectTo: '/'});
}]);

2
app/js/controllers.js

@ -359,7 +359,7 @@ angular.module('myApp.controllers', []) @@ -359,7 +359,7 @@ angular.module('myApp.controllers', [])
// dLog('on apiUpdate inline', update);
switch (update._) {
case 'updateUserTyping':
if (update.user_id == $scope.curDialog.peerID) {
if (update.user_id == $scope.curDialog.peerID && AppUsersManager.hasUser(update.user_id)) {
$scope.typing = {user: AppUsersManager.getUser(update.user_id)};
$timeout.cancel(typingTimeouts[update.user_id]);

43
app/js/services.js

@ -157,6 +157,10 @@ angular.module('myApp.services', []) @@ -157,6 +157,10 @@ angular.module('myApp.services', [])
return users[id] || {id: id, deleted: true};
}
function hasUser(id) {
return angular.isObject(users[id]);
}
function getUserPhoto(id, placeholder) {
var user = getUser(id);
@ -254,6 +258,7 @@ angular.module('myApp.services', []) @@ -254,6 +258,7 @@ angular.module('myApp.services', [])
getUser: getUser,
getUserPhoto: getUserPhoto,
getUserString: getUserString,
hasUser: hasUser,
wrapForFull: wrapForFull,
openUser: openUser
}
@ -282,6 +287,10 @@ angular.module('myApp.services', []) @@ -282,6 +287,10 @@ angular.module('myApp.services', [])
return chats[id] || {id: id, deleted: true};
}
function hasChat (id) {
return angular.isObject(chats[id]);
}
function getChatPhoto(id, placeholder) {
var chat = getChat(id);
@ -353,6 +362,7 @@ angular.module('myApp.services', []) @@ -353,6 +362,7 @@ angular.module('myApp.services', [])
getChat: getChat,
getChatPhoto: getChatPhoto,
getChatString: getChatString,
hasChat: hasChat,
wrapForFull: wrapForFull,
openChat: openChat
}
@ -1511,14 +1521,34 @@ angular.module('myApp.services', []) @@ -1511,14 +1521,34 @@ angular.module('myApp.services', [])
AppUsersManager.saveApiUsers(updateMessage.users);
AppChatsManager.saveApiChats(updateMessage.chats);
var i, update, message;
for (var i = 0; i < updateMessage.updates.length; i++) {
update = updateMessage.updates[i];
switch (update._) {
case 'updateNewMessage':
message = update.message;
if (message.from_id && !AppUsersManager.hasUser(message.from_id)) {
dLog('User not found', message.from_id, 'getDiff');
getDifference();
return false;
}
if (message.to_id.chat_id && !AppChatsManager.hasChat(message.to_id.chat_id)) {
dLog('Chat not found', message.to_id.chat_id, 'getDiff');
getDifference();
return false;
}
break;
}
}
angular.forEach(updateMessage.updates, function (update) {
saveUpdate(update);
});
break;
case 'updateShortMessage':
var fromUser = AppUsersManager.getUser(updateMessage.from_id);
if (!fromUser || fromUser.deleted) {
if (!AppUsersManager.hasUser(updateMessage.from_id)) {
dLog('User not found', updateMessage.from_id, 'getDiff');
getDifference();
break;
}
@ -1540,10 +1570,9 @@ angular.module('myApp.services', []) @@ -1540,10 +1570,9 @@ angular.module('myApp.services', [])
break;
case 'updateShortChatMessage':
var fromUser = AppUsersManager.getUser(updateMessage.from_id),
chat = AppChatsManager.getChat(updateMessage.chat_id);
if (!fromUser || fromUser.deleted || !chat || chat.deleted) {
if (!AppUsersManager.hasUser(updateMessage.from_id) ||
!AppChatsManager.hasChat(updateMessage.chat_id)) {
dLog('User or chat not found', updateMessage.from_id, updateMessage.chat_id, 'getDiff');
getDifference();
break;
}
@ -1564,6 +1593,8 @@ angular.module('myApp.services', []) @@ -1564,6 +1593,8 @@ angular.module('myApp.services', [])
});
break;
}
return true;
}
function getDifference (force) {

2
app/partials/im.html

@ -116,7 +116,7 @@ @@ -116,7 +116,7 @@
</div>
<div class="im_page_footer font-light">
<div class="im_page_footer">
<a class="im_page_footer_brand" target="_blank" href="https://github.com/zhukov/webogram">Telegram alpha</a> by izhukov &amp; toberg
</div>

Loading…
Cancel
Save