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 {
overflow-y: auto; overflow-y: auto;
} }
.modal-content { .modal-content {
border: 0;
border-radius: 4px; border-radius: 4px;
-webkit-box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1); -webkit-box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
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 @@
<link rel="stylesheet" href="vendor/angular/angular-csp.css"/> <link rel="stylesheet" href="vendor/angular/angular-csp.css"/>
<link rel="stylesheet" href="vendor/bootstrap/css/bootstrap.css"/> <link rel="stylesheet" href="vendor/bootstrap/css/bootstrap.css"/>
<link rel="stylesheet" href="vendor/jquery.nanoscroller/nanoscroller.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"> <link rel="icon" href="favicon.ico" type="image/x-icon">
</head> </head>
<body> <body>
@ -36,9 +36,9 @@
<script type="text/javascript" src="js/lib/mtproto.js?1"></script> <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/util.js"></script>
<script type="text/javascript" src="js/app.js?1"></script> <script type="text/javascript" src="js/app.js?2"></script>
<script type="text/javascript" src="js/services.js?4"></script> <script type="text/javascript" src="js/services.js?5"></script>
<script type="text/javascript" src="js/controllers.js?3"></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/filters.js?2"></script>
<script type="text/javascript" src="js/directives.js?4"></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
// $locationProvider.html5Mode(true); // $locationProvider.html5Mode(true);
$routeProvider.when('/', {templateUrl: 'partials/welcome.html', controller: 'AppWelcomeController'}); $routeProvider.when('/', {templateUrl: 'partials/welcome.html', controller: 'AppWelcomeController'});
$routeProvider.when('/login', {templateUrl: 'partials/login.html?1', controller: 'AppLoginController'}); $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: '/'}); $routeProvider.otherwise({redirectTo: '/'});
}]); }]);

2
app/js/controllers.js

@ -359,7 +359,7 @@ angular.module('myApp.controllers', [])
// dLog('on apiUpdate inline', update); // dLog('on apiUpdate inline', update);
switch (update._) { switch (update._) {
case 'updateUserTyping': 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)}; $scope.typing = {user: AppUsersManager.getUser(update.user_id)};
$timeout.cancel(typingTimeouts[update.user_id]); $timeout.cancel(typingTimeouts[update.user_id]);

43
app/js/services.js

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

2
app/partials/im.html

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

Loading…
Cancel
Save