Browse Source

Added chat settings, bugfixes

master
Igor Zhukov 11 years ago
parent
commit
a4c219f518
  1. 63
      app/css/app.css
  2. 10
      app/index.html
  3. 117
      app/js/controllers.js
  4. 4
      app/js/directives.js
  5. 10
      app/js/lib/mtproto.js
  6. 133
      app/js/services.js
  7. 26
      app/partials/chat_modal.html
  8. 8
      app/partials/settings_modal.html
  9. 16
      app/partials/user_modal.html

63
app/css/app.css

@ -41,6 +41,7 @@ a:hover {
cursor: pointer; cursor: pointer;
} }
.form-control { .form-control {
color: #000;
border: 1px solid #d9dbde; border: 1px solid #d9dbde;
border-radius: 2px; border-radius: 2px;
-webkit-box-shadow: none; -webkit-box-shadow: none;
@ -405,7 +406,7 @@ fieldset[disabled] .btn-tg.active {
background-size: 42px 430px; background-size: 42px 430px;
border: 1px solid #F2F2F2; border: 1px solid #F2F2F2;
border-radius: 3px; border-radius: 3px;
padding: 6px 6px 6px 30px; padding: 6px 20px 6px 30px;
margin-bottom: 0; margin-bottom: 0;
margin: 0; margin: 0;
} }
@ -631,14 +632,14 @@ a.im_dialog:hover .im_dialog_date {
margin-left: 5px; margin-left: 5px;
} }
.im_history_panel_info_link { .im_history_panel_info_link {
color: #999; color: #3a6d99;
font-size: 13px; font-size: 13px;
font-weight: normal; font-weight: normal;
padding-top: 5px; padding-top: 5px;
line-height: 1; line-height: 1;
} }
.im_history_panel_info_link:hover { .im_history_panel_info_link:hover {
text-decoration: none; text-decoration: underline;
} }
@ -1067,10 +1068,10 @@ span.emoji {
.im_panel_fixed_bottom .im_send_form_wrap1 { .im_panel_fixed_bottom .im_send_form_wrap1 {
position: relative; position: relative;
} }
.im_panel_fixed_bottom .im_send_form_wrap { .im_panel_fixed_bottom .im_send_form {
width: 514px;
position: absolute; position: absolute;
bottom: 0; bottom: 0;
left: 62px;
} }
.im_send_form { .im_send_form {
width: 389px; width: 389px;
@ -1280,7 +1281,7 @@ img.img_fullsize {
max-width: 506px; max-width: 506px;
} }
.user_modal_wrap .modal-body { .user_modal_wrap .modal-body {
padding: 23px 25px 70px; padding: 23px 25px 30px;
} }
.user_modal_image_wrap { .user_modal_image_wrap {
width: 120px; width: 120px;
@ -1291,16 +1292,32 @@ img.img_fullsize {
height: 120px; height: 120px;
} }
.user_modal_header { .user_modal_header {
font-weight: bold;
margin: 0 0 5px; margin: 0 0 5px;
} }
.user_modal_status { .user_modal_status {
color: #999; color: #999;
} }
.user_modal_send_btn { .user_modal_send_btn {
padding-left: 0; border: 0;
padding-right: 0; background: #4E9CD8;
font-size: 12px; font-size: 12px;
margin-top: 8px; margin-top: 8px;
padding-left: 16px;
padding-right: 16px;
}
.user_modal_send_btn:hover {
background: #539BD1;
}
.user_modal_settings_wrap {
margin-top: 25px;
}
.user_modal_notifications {
font-weight: bold;
}
.user_modal_clear {
margin-top: 20px;
} }
@ -1324,6 +1341,20 @@ img.img_fullsize {
.chat_modal_members_count { .chat_modal_members_count {
color: #999; color: #999;
} }
.chat_modal_settings_wrap {
margin-top: 10px;
}
.chat_modal_notifications {
font-weight: bold;
}
.chat_modal_clear {
margin-top: 10px;
}
.chat_modal_leave {
margin-top: 10px;
}
.chat_modal_invite_btn { .chat_modal_invite_btn {
padding-left: 0; padding-left: 0;
padding-right: 0; padding-right: 0;
@ -1357,6 +1388,9 @@ img.img_fullsize {
margin-right: 10px; margin-right: 10px;
overflow: hidden; overflow: hidden;
} }
.chat_modal_members_forbidden {
color: #999;
}
@ -1380,6 +1414,7 @@ img.img_fullsize {
height: auto; height: auto;
max-height: 300px; max-height: 300px;
overflow: auto; overflow: auto;
line-height: 17px;
border: 1px solid #d9dbde; border: 1px solid #d9dbde;
border-radius: 2px; border-radius: 2px;
@ -1525,12 +1560,22 @@ img.img_fullsize {
} }
.settings_profile_first_name, .settings_profile_first_name,
.settings_profile_last_name { .settings_profile_last_name {
width: 210px; width: 180px;
float: left; float: left;
} }
.settings_profile_first_name { .settings_profile_first_name {
margin-right: 22px; margin-right: 22px;
} }
.settings_profile_last_name {
margin-right: 10px;
}
.settings_profile_save {
padding-top: 23px;
float: left;
}
.settings_profile_save_btn {
width: 50px;
}
.settings_profile_edit_form input { .settings_profile_edit_form input {
font-size: 12px; font-size: 12px;

10
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?23"/> <link rel="stylesheet" href="css/app.css?24"/>
<link rel="icon" href="favicon.ico" type="image/x-icon" /> <link rel="icon" href="favicon.ico" type="image/x-icon" />
<meta property="og:title" content="Webogram"> <meta property="og:title" content="Webogram">
@ -48,14 +48,14 @@
<script type="text/javascript" src="js/lib/config.js"></script> <script type="text/javascript" src="js/lib/config.js"></script>
<script type="text/javascript" src="js/lib/mtproto.js?18"></script> <script type="text/javascript" src="js/lib/mtproto.js?19"></script>
<script type="text/javascript" src="js/util.js?1"></script> <script type="text/javascript" src="js/util.js?1"></script>
<script type="text/javascript" src="js/app.js?15"></script> <script type="text/javascript" src="js/app.js?15"></script>
<script type="text/javascript" src="js/services.js?19"></script> <script type="text/javascript" src="js/services.js?20"></script>
<script type="text/javascript" src="js/controllers.js?27"></script> <script type="text/javascript" src="js/controllers.js?28"></script>
<script type="text/javascript" src="js/filters.js?3"></script> <script type="text/javascript" src="js/filters.js?3"></script>
<script type="text/javascript" src="js/directives.js?17"></script> <script type="text/javascript" src="js/directives.js?18"></script>
</body> </body>
</html> </html>

117
app/js/controllers.js

@ -162,7 +162,7 @@ angular.module('myApp.controllers', [])
$scope.isLoggedIn = true; $scope.isLoggedIn = true;
$scope.openSettings = function () { $scope.openSettings = function () {
$modal.open({ $modal.open({
templateUrl: 'partials/settings_modal.html?2', templateUrl: 'partials/settings_modal.html?3',
controller: 'SettingsModalController', controller: 'SettingsModalController',
scope: $rootScope.$new(), scope: $rootScope.$new(),
windowClass: 'settings_modal_window' windowClass: 'settings_modal_window'
@ -226,6 +226,15 @@ angular.module('myApp.controllers', [])
$scope.dialogs.unshift(wrappedDialog); $scope.dialogs.unshift(wrappedDialog);
}); });
$scope.$on('dialog_flush', function (e, dialog) {
for (var i = 0; i < $scope.dialogs.length; i++) {
if ($scope.dialogs[i].peerID == dialog.peerID) {
$scope.dialogs.splice(i, 1);
break;
}
}
});
$scope.$watch('search.query', loadDialogs); $scope.$watch('search.query', loadDialogs);
function loadDialogs () { function loadDialogs () {
@ -421,6 +430,12 @@ angular.module('myApp.controllers', [])
} }
}); });
$scope.$on('dialog_flush', function (e, dialog) {
if (dialog.peerID == $scope.curDialog.peerID) {
$scope.history = [];
}
});
$scope.$on('apiUpdate', function (e, update) { $scope.$on('apiUpdate', function (e, update) {
// console.log('on apiUpdate inline', update); // console.log('on apiUpdate inline', update);
switch (update._) { switch (update._) {
@ -571,14 +586,42 @@ angular.module('myApp.controllers', [])
$scope.video = AppVideoManager.wrapForFull($scope.videoID); $scope.video = AppVideoManager.wrapForFull($scope.videoID);
}) })
.controller('UserModalController', function ($scope, $location, $rootScope, $modalStack, AppUsersManager) { .controller('UserModalController', function ($scope, $location, $rootScope, $modalStack, AppUsersManager, NotificationsManager, AppMessagesManager, AppPeersManager) {
$scope.user = AppUsersManager.wrapForFull($scope.userID); $scope.user = AppUsersManager.wrapForFull($scope.userID);
$scope.settings = {notifications: true};
NotificationsManager.getPeerMuted($scope.userID).then(function (muted) {
$scope.settings.notifications = !muted;
});
$scope.$watch('settings.notifications', function(newValue) {
NotificationsManager.getPeerSettings($scope.userID).then(function (settings) {
if (newValue) {
settings.mute_until = 0;
} else {
settings.mute_until = 2000000000;
}
NotificationsManager.savePeerSettings($scope.userID, settings);
});
});
$scope.goToHistory = function () { $scope.goToHistory = function () {
$rootScope.$broadcast('history_focus', {peerString: $scope.user.peerString}); $rootScope.$broadcast('history_focus', {peerString: $scope.user.peerString});
}; };
$scope.flushHistory = function () {
if (confirm('Are you sure? This can not be undone!') !== true) {
return false;
}
AppMessagesManager.flushHistory(AppPeersManager.getInputPeerByID($scope.userID)).then(function () {
$scope.goToHistory();
});
};
}) })
.controller('ChatModalController', function ($scope, $timeout, AppUsersManager, AppChatsManager, MtpApiManager) { .controller('ChatModalController', function ($scope, $timeout, $rootScope, AppUsersManager, AppChatsManager, MtpApiManager, NotificationsManager, AppMessagesManager, AppPeersManager, ApiUpdatesManager) {
$scope.chatFull = AppChatsManager.wrapForFull($scope.chatID, {}); $scope.chatFull = AppChatsManager.wrapForFull($scope.chatID, {});
MtpApiManager.invokeApi('messages.getFullChat', { MtpApiManager.invokeApi('messages.getFullChat', {
@ -589,6 +632,70 @@ angular.module('myApp.controllers', [])
$scope.chatFull = AppChatsManager.wrapForFull($scope.chatID, result.full_chat); $scope.chatFull = AppChatsManager.wrapForFull($scope.chatID, result.full_chat);
}); });
$scope.settings = {notifications: true};
NotificationsManager.getPeerMuted(-$scope.chatID).then(function (muted) {
$scope.settings.notifications = !muted;
});
$scope.$watch('settings.notifications', function(newValue) {
NotificationsManager.getPeerSettings(-$scope.chatID).then(function (settings) {
if (newValue) {
settings.mute_until = 0;
} else {
settings.mute_until = 2000000000;
}
NotificationsManager.savePeerSettings(-$scope.chatID, settings);
});
});
$scope.leaveGroup = function () {
MtpApiManager.invokeApi('messages.deleteChatUser', {
chat_id: $scope.chatID,
user_id: {_: 'inputUserSelf'}
}).then(function (result) {
if (ApiUpdatesManager.saveSeq(result.seq)) {
ApiUpdatesManager.saveUpdate({
_: 'updateNewMessage',
message: result.message,
pts: result.pts
});
}
$rootScope.$broadcast('history_focus', {peerString: $scope.chatFull.peerString});
});
};
$scope.returnToGroup = function () {
MtpApiManager.invokeApi('messages.addChatUser', {
chat_id: $scope.chatID,
user_id: {_: 'inputUserSelf'}
}).then(function (result) {
if (ApiUpdatesManager.saveSeq(result.seq)) {
ApiUpdatesManager.saveUpdate({
_: 'updateNewMessage',
message: result.message,
pts: result.pts
});
}
$rootScope.$broadcast('history_focus', {peerString: $scope.chatFull.peerString});
});
};
$scope.flushHistory = function () {
if (confirm('Are you sure? This can not be undone!') !== true) {
return;
}
AppMessagesManager.flushHistory(AppPeersManager.getInputPeerByID(-$scope.chatID)).then(function () {
$rootScope.$broadcast('history_focus', {peerString: $scope.chatFull.peerString});
});
};
}) })
.controller('SettingsModalController', function ($rootScope, $scope, $timeout, AppUsersManager, AppChatsManager, MtpApiManager, AppConfigManager, NotificationsManager) { .controller('SettingsModalController', function ($rootScope, $scope, $timeout, AppUsersManager, AppChatsManager, MtpApiManager, AppConfigManager, NotificationsManager) {
@ -639,12 +746,14 @@ angular.module('myApp.controllers', [])
}); });
$scope.error = {}; $scope.error = {};
$scope.save = function () { $scope.save = function (profileForm) {
MtpApiManager.invokeApi('account.updateProfile', { MtpApiManager.invokeApi('account.updateProfile', {
first_name: $scope.profile.first_name || '', first_name: $scope.profile.first_name || '',
last_name: $scope.profile.last_name || '' last_name: $scope.profile.last_name || ''
}).then(function (user) { }).then(function (user) {
$scope.error = {}; $scope.error = {};
// console.log($scope.profileForm);
profileForm.$setPristine();
AppUsersManager.saveApiUser(user); AppUsersManager.saveApiUser(user);
}, function (error) { }, function (error) {
switch (error.type) { switch (error.type) {

4
app/js/directives.js

@ -421,7 +421,7 @@ angular.module('myApp.directives', ['myApp.filters'])
if (e.type == 'drop') { if (e.type == 'drop') {
scope.$apply(function () { scope.$apply(function () {
scope.draftMessage.files = Array.prototype.slice.call(e.originalEvent.dataTransfer.files); scope.draftMessage.files = Array.prototype.slice.call(e.originalEvent.dataTransfer.files);
scope.draftMessage.isMedia = false; scope.draftMessage.isMedia = true;
}); });
} }
dragTimeout = setTimeout(function () { dragTimeout = setTimeout(function () {
@ -631,7 +631,7 @@ angular.module('myApp.directives', ['myApp.filters'])
// } // }
// } // }
MtpApiFileManager.downloadFile(scope.video.dc_id, inputLocation, scope.video.size).then(function (url) { MtpApiFileManager.downloadFile(scope.video.dc_id, inputLocation, scope.video.size, null, {mime: 'video/mp4'}).then(function (url) {
scope.progress.enabled = false; scope.progress.enabled = false;
// scope.progress = {enabled: true, percent: 50}; // scope.progress = {enabled: true, percent: 50};
scope.player.quicktime = hasQt; scope.player.quicktime = hasQt;

10
app/js/lib/mtproto.js

@ -2586,7 +2586,9 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
return cachedDownloadPromises[fileName] = deferred.promise; return cachedDownloadPromises[fileName] = deferred.promise;
} }
function downloadFile (dcID, location, size, fileEntry) { function downloadFile (dcID, location, size, fileEntry, options) {
options = options || {};
console.log('dload file', dcID, location, size); console.log('dload file', dcID, location, size);
var fileName = getFileName(location), var fileName = getFileName(location),
cachedPromise = cachedSavePromises[fileName] || cachedDownloadPromises[fileName]; cachedPromise = cachedSavePromises[fileName] || cachedDownloadPromises[fileName];
@ -2638,7 +2640,7 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
}, errorHandler).then(function () { }, errorHandler).then(function () {
if (isFinal) { if (isFinal) {
deferred.resolve(cachedDownloads[fileName] = fileEntry.toURL('image/jpeg')); deferred.resolve(cachedDownloads[fileName] = fileEntry.toURL(options.mime || 'image/jpeg'));
} else { } else {
// console.log('notify', {done: offset + limit, total: size}); // console.log('notify', {done: offset + limit, total: size});
deferred.notify({done: offset + limit, total: size}); deferred.notify({done: offset + limit, total: size});
@ -2699,14 +2701,14 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
if (isFinal) { if (isFinal) {
try { try {
var blob = new Blob(blobParts, {type: 'image/jpeg'}); var blob = new Blob(blobParts, {type: options.mime || 'image/jpeg'});
} catch (e) { } catch (e) {
window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder; window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
var bb = new BlobBuilder; var bb = new BlobBuilder;
angular.forEach(blobParts, function(blobPart) { angular.forEach(blobParts, function(blobPart) {
bb.append(blobPart); bb.append(blobPart);
}); });
var blob = bb.getBlob('image/jpeg'); var blob = bb.getBlob(options.mime || 'image/jpeg');
} }

133
app/js/services.js

@ -208,7 +208,7 @@ angular.module('myApp.services', [])
scope.userID = userID; scope.userID = userID;
var modalInstance = $modal.open({ var modalInstance = $modal.open({
templateUrl: 'partials/user_modal.html?1', templateUrl: 'partials/user_modal.html?2',
controller: 'UserModalController', controller: 'UserModalController',
scope: scope, scope: scope,
windowClass: 'user_modal_window', windowClass: 'user_modal_window',
@ -330,7 +330,7 @@ angular.module('myApp.services', [])
scope.chatID = chatID; scope.chatID = chatID;
var modalInstance = $modal.open({ var modalInstance = $modal.open({
templateUrl: 'partials/chat_modal.html?3', templateUrl: 'partials/chat_modal.html?4',
controller: 'ChatModalController', controller: 'ChatModalController',
windowClass: 'chat_modal_window', windowClass: 'chat_modal_window',
scope: scope scope: scope
@ -688,7 +688,7 @@ angular.module('myApp.services', [])
return deferred.promise; return deferred.promise;
} }
function processAffectedHistory (inputPeer, affectedHistory) { function processAffectedHistory (inputPeer, affectedHistory, method) {
if (!ApiUpdatesManager.saveSeq(affectedHistory.seq)) { if (!ApiUpdatesManager.saveSeq(affectedHistory.seq)) {
return false; return false;
} }
@ -696,12 +696,12 @@ angular.module('myApp.services', [])
return $q.when(); return $q.when();
} }
return MtpApiManager.invokeApi('messages.readHistory', { return MtpApiManager.invokeApi(method, {
peer: inputPeer, peer: inputPeer,
offset: affectedHistory.offset, offset: affectedHistory.offset,
max_id: 0 max_id: 0
}).then(function (affectedHistory) { }).then(function (affectedHistory) {
return processAffectedHistory(inputPeer, affectedHistory); return processAffectedHistory(inputPeer, affectedHistory, method);
}); });
} }
@ -740,7 +740,7 @@ angular.module('myApp.services', [])
offset: 0, offset: 0,
max_id: 0 max_id: 0
}).then(function (affectedHistory) { }).then(function (affectedHistory) {
return processAffectedHistory(inputPeer, affectedHistory); return processAffectedHistory(inputPeer, affectedHistory, 'messages.readHistory');
}).then(function () { }).then(function () {
if (foundDialog[0]) { if (foundDialog[0]) {
foundDialog[0].unread_count = 0; foundDialog[0].unread_count = 0;
@ -767,6 +767,26 @@ angular.module('myApp.services', [])
return promise; return promise;
} }
function flushHistory (inputPeer) {
// console.log('start read');
var peerID = AppPeersManager.getPeerID(inputPeer),
historyStorage = historiesStorage[peerID];
return MtpApiManager.invokeApi('messages.deleteHistory', {
peer: inputPeer,
offset: 0
}).then(function (affectedHistory) {
return processAffectedHistory(inputPeer, affectedHistory, 'messages.deleteHistory');
}).then(function () {
var foundDialog = getDialogByPeerID(peerID);
if (foundDialog[0]) {
dialogsStorage.dialogs.splice(foundDialog[1], 1);
}
delete historiesStorage[peerID];
$rootScope.$broadcast('dialog_flush', {peerID: peerID});
});
}
function saveMessages (apiMessages) { function saveMessages (apiMessages) {
angular.forEach(apiMessages, function (apiMessage) { angular.forEach(apiMessages, function (apiMessage) {
messagesStorage[apiMessage.id] = apiMessage; messagesStorage[apiMessage.id] = apiMessage;
@ -1195,7 +1215,7 @@ angular.module('myApp.services', [])
' @ ' + ' @ ' +
(AppChatsManager.getChat(-peerID).title || 'Unknown chat'); (AppChatsManager.getChat(-peerID).title || 'Unknown chat');
notificationPhoto = AppChatsManager.getChatPhoto(-peerID, 'Chat'); notificationPhoto = AppChatsManager.getChatPhoto(-peerID, 'Group');
peerString = AppChatsManager.getChatString(-peerID); peerString = AppChatsManager.getChatString(-peerID);
} }
@ -1286,7 +1306,7 @@ angular.module('myApp.services', [])
if ($rootScope.idle.isIDLE && !message.out && message.unread) { if ($rootScope.idle.isIDLE && !message.out && message.unread) {
NotificationsManager.getPeerSettings(peerID).then(function (muted) { NotificationsManager.getPeerMuted(peerID).then(function (muted) {
if (!message.unread || muted) { if (!message.unread || muted) {
return; return;
} }
@ -1326,6 +1346,61 @@ angular.module('myApp.services', [])
$rootScope.$broadcast('dialog_unread', {peerID: peerID, count: count}); $rootScope.$broadcast('dialog_unread', {peerID: peerID, count: count});
}); });
break; break;
case 'updateDeleteMessages':
var dialogsUpdated = {},
historiesUpdated = {},
messageID, message, i, peerID, foundDialog, dialog, history;
for (i = 0; i < update.messages.length; i++) {
messageID = update.messages[i];
message = messagesStorage[messageID];
if (message) {
peerID = getMessagePeer(message);
history = historiesUpdated[peer] || (historiesUpdated[peer] = {count: 0, unread: 0, msgs: {}});
if (!message.out && message.unread) {
history.unread++;
NotificationsManager.cancel('msg' + messageID);
}
history.count++;
history.msgs[messageID] = true;
if (messagesForHistory[messageID]) {
messagesForHistory[messageID].DELETED = true;
delete messagesForHistory[messageID];
}
if (messagesForDialogs[messageID]) {
messagesForDialogs[messageID].DELETED = true;
delete messagesForDialogs[messageID];
}
message.DELETED = true;
delete messagesStorage[messageID];
}
}
angular.forEach(historiesUpdated, function (updatedData, peerID) {
var foundDialog = getDialogByPeerID(peerID);
if (foundDialog) {
if (updatedData.unread) {
foundDialog[0].unread_count -= updatedData.unread;
$rootScope.$broadcast('dialog_unread', {peerID: peerID, count: foundDialog[0].unread_count});
}
}
var historyStorage = historiesStorage[peerID];
if (historyStorage !== undefined) {
var newHistory = [];
for (var i = 0; i < historyStorage.history.length; i++) {
if (!updatedData.msgs[historyStorage.history[i]]) {
newHistory.push(historyStorage.history[i]);
}
}
historyStorage.history = newHistory;
}
});
break;
} }
}); });
@ -1333,6 +1408,7 @@ angular.module('myApp.services', [])
getDialogs: getDialogs, getDialogs: getDialogs,
getHistory: getHistory, getHistory: getHistory,
readHistory: readHistory, readHistory: readHistory,
flushHistory: flushHistory,
saveMessages: saveMessages, saveMessages: saveMessages,
sendText: sendText, sendText: sendText,
sendFile: sendFile, sendFile: sendFile,
@ -1516,15 +1592,20 @@ angular.module('myApp.services', [])
height: fullHeight, height: fullHeight,
}; };
if (video.w > video.h) { if (!video.w || !video.h) {
full.height = full.width = Math.min(fullWidth, fullHeight);
}
else if (video.w > video.h) {
full.height = parseInt(video.h * fullWidth / video.w); full.height = parseInt(video.h * fullWidth / video.w);
} else { }
else {
full.width = parseInt(video.w * fullHeight / video.h); full.width = parseInt(video.w * fullHeight / video.h);
if (full.width > fullWidth) { if (full.width > fullWidth) {
full.height = parseInt(full.height * fullWidth / full.width); full.height = parseInt(full.height * fullWidth / full.width);
full.width = fullWidth; full.width = fullWidth;
} }
} }
// console.log(222, video.w, video.h, full.width, full.height);
video.full = full; video.full = full;
video.fromUser = AppUsersManager.getUser(video.user_id); video.fromUser = AppUsersManager.getUser(video.user_id);
@ -1625,17 +1706,17 @@ angular.module('myApp.services', [])
if (window.chrome && chrome.fileSystem && chrome.fileSystem.chooseEntry) { if (window.chrome && chrome.fileSystem && chrome.fileSystem.chooseEntry) {
var ext = (doc.file_name.split('.', 2) || [])[1] || '', var ext = (doc.file_name.split('.', 2) || [])[1] || '';
mime = doc.mime_type;
chrome.fileSystem.chooseEntry({ chrome.fileSystem.chooseEntry({
type: 'saveFile', type: 'saveFile',
suggestedName: doc.file_name, suggestedName: doc.file_name,
accepts: [{ accepts: [{
mimeTypes: [mime], mimeTypes: [doc.mime_type],
extensions: [ext] extensions: [ext]
}] }]
}, function (writableFileEntry) { }, function (writableFileEntry) {
MtpApiFileManager.downloadFile(doc.dc_id, inputFileLocation, doc.size, writableFileEntry).then(function (url) { MtpApiFileManager.downloadFile(doc.dc_id, inputFileLocation, doc.size, writableFileEntry, {mime: doc.mime_type}).then(function (url) {
delete historyDoc.progress; delete historyDoc.progress;
console.log('file save done'); console.log('file save done');
}, function (e) { }, function (e) {
@ -1644,7 +1725,7 @@ angular.module('myApp.services', [])
}, updateDownloadProgress); }, updateDownloadProgress);
}); });
} else { } else {
MtpApiFileManager.downloadFile(doc.dc_id, inputFileLocation, doc.size).then(function (url) { MtpApiFileManager.downloadFile(doc.dc_id, inputFileLocation, doc.size, null, {mime: doc.mime_type}).then(function (url) {
delete historyDoc.progress; delete historyDoc.progress;
var a = $('<a>Download</a>').css({position: 'absolute', top: 1, left: 1}).attr('href', url).attr('target', '_blank').attr('download', doc.file_name).appendTo('body'); var a = $('<a>Download</a>').css({position: 'absolute', top: 1, left: 1}).attr('href', url).attr('target', '_blank').attr('download', doc.file_name).appendTo('body');
@ -1705,7 +1786,7 @@ angular.module('myApp.services', [])
$rootScope.$broadcast('history_update'); $rootScope.$broadcast('history_update');
} }
MtpApiFileManager.downloadFile(audio.dc_id, inputFileLocation, audio.size).then(function (url) { MtpApiFileManager.downloadFile(audio.dc_id, inputFileLocation, audio.size, null, {mime: 'audio/mpeg'}).then(function (url) {
delete historyAudio.progress; delete historyAudio.progress;
historyAudio.url = $sce.trustAsResourceUrl(url); historyAudio.url = $sce.trustAsResourceUrl(url);
historyAudio.autoplay = true; historyAudio.autoplay = true;
@ -2172,7 +2253,7 @@ angular.module('myApp.services', [])
}) })
.service('NotificationsManager', function ($rootScope, $window, $timeout, $interval, MtpApiManager, AppPeersManager, IdleManager, AppConfigManager) { .service('NotificationsManager', function ($rootScope, $window, $timeout, $interval, $q, MtpApiManager, AppPeersManager, IdleManager, AppConfigManager) {
var notificationsUiSupport = 'Notification' in window; var notificationsUiSupport = 'Notification' in window;
var notificationsShown = {}; var notificationsShown = {};
@ -2220,7 +2301,8 @@ angular.module('myApp.services', [])
cancel: notificationCancel, cancel: notificationCancel,
clear: notificationsClear, clear: notificationsClear,
getPeerSettings: getPeerSettings, getPeerSettings: getPeerSettings,
getPeerMuted: getPeerMuted getPeerMuted: getPeerMuted,
savePeerSettings: savePeerSettings
}; };
function getPeerSettings (peerID) { function getPeerSettings (peerID) {
@ -2236,6 +2318,21 @@ angular.module('myApp.services', [])
}); });
} }
function savePeerSettings (peerID, settings) {
var inputSettings = angular.copy(settings);
inputSettings._ = 'inputPeerNotifySettings';
peerSettings[peerID] = $q.when(settings);
return MtpApiManager.invokeApi('account.updateNotifySettings', {
peer: {
_: 'inputNotifyPeer',
peer: AppPeersManager.getInputPeerByID(peerID)
},
settings: inputSettings
});
}
function getPeerMuted (peerID) { function getPeerMuted (peerID) {
return getPeerSettings(peerID).then(function (peerNotifySettings) { return getPeerSettings(peerID).then(function (peerNotifySettings) {
return peerNotifySettings._ == 'peerNotifySettings' && return peerNotifySettings._ == 'peerNotifySettings' &&

26
app/partials/chat_modal.html

@ -22,7 +22,27 @@
</ng-pluralize> </ng-pluralize>
</p> </p>
<!--button class="btn btn-link chat_modal_invite_btn">Add member</button--> <div class="chat_modal_settings_wrap">
<div class="chat_modal_notifications">
Notifications:
<a ng-click="settings.notifications = !settings.notifications">
{{settings.notifications ? 'ON' : 'OFF'}}
</a>
</div>
<div class="chat_modal_clear">
<a href="" ng-click="flushHistory()">Clear History</a>
</div>
<div class="chat_modal_leave_join" ng-if="chatFull.chat._ != 'chatForbidden'">
<div class="chat_modal_leave" ng-if="!chatFull.chat.left">
<a href="" ng-click="leaveGroup()">Leave group</a>
</div>
<div class="chat_modal_leave" ng-if="chatFull.chat.left">
<a href="" ng-click="returnToGroup()">Return to group</a>
</div>
</div>
</div>
</div> </div>
<h5 class="chat_modal_members_header">Members</h5> <h5 class="chat_modal_members_header">Members</h5>
@ -45,6 +65,10 @@
</div> </div>
<div class="chat_modal_members_forbidden" ng-if="chatFull.chat._ == 'chatForbidden' || chatFull.chat.left">
Group members list is unavailable.
</div>
</div> </div>
</div> </div>

8
app/partials/settings_modal.html

@ -1,14 +1,12 @@
<div class="settings_modal_wrap"> <div class="settings_modal_wrap">
<div class="modal-header"> <div class="modal-header">
<a class="modal-close-link" ng-click="$close()">Close</a>
<a class="modal-save-link" ng-click="save()">Save</a>
<h4 class="modal-title">Settings</h4> <h4 class="modal-title">Settings</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<form class="settings_profile_edit_form clearfix"> <form name="profileForm" class="settings_profile_edit_form clearfix">
<div class="form-group settings_profile_first_name" ng-class="{'has-error': error.field == 'first_name'}"> <div class="form-group settings_profile_first_name" ng-class="{'has-error': error.field == 'first_name'}">
<label class="control-label" for="first_name"> <label class="control-label" for="first_name">
<span ng-if="error.field == 'first_name'">Invalid First Name</span> <span ng-if="error.field == 'first_name'">Invalid First Name</span>
@ -24,6 +22,10 @@
</label> </label>
<input type="text" class="form-control" name="last_name" ng-model="profile.last_name" /> <input type="text" class="form-control" name="last_name" ng-model="profile.last_name" />
</div> </div>
<div class="settings_profile_save">
<button class="btn btn-link settings_profile_save_btn" ng-click="save(profileForm)" ng-disabled="profileForm.$invalid || (!profileForm.last_name.$dirty &amp;&amp; !profileForm.first_name.$dirty)">Save</button>
</div>
</form> </form>
<form class="settings_send_choose_form"> <form class="settings_send_choose_form">

16
app/partials/user_modal.html

@ -1,7 +1,6 @@
<div class="user_modal_wrap"> <div class="user_modal_wrap">
<div class="modal-header"> <div class="modal-header">
<!-- <a class="modal-close-link" ng-click="$close()">Close</a> -->
<h4 class="modal-title">Info</h4> <h4 class="modal-title">Info</h4>
</div> </div>
@ -21,7 +20,20 @@
<p class="user_modal_status" ng-if="user.status">{{user | userStatus}}</p> <p class="user_modal_status" ng-if="user.status">{{user | userStatus}}</p>
<p class="user_modal_phone" ng-if="user.phone">{{user.phone | phoneNumber}}</p> <p class="user_modal_phone" ng-if="user.phone">{{user.phone | phoneNumber}}</p>
<button class="btn btn-link user_modal_send_btn" ng-click="goToHistory()">Send message</button> <button class="btn btn-primary user_modal_send_btn" ng-click="goToHistory()">Send message</button>
</div>
<div class="user_modal_settings_wrap">
<div class="user_modal_notifications">
Notifications:
<a ng-click="settings.notifications = !settings.notifications">
{{settings.notifications ? 'ON' : 'OFF'}}
</a>
</div>
<div class="user_modal_clear">
<a href="" ng-click="flushHistory()">Clear Chat History</a>
</div>
</div> </div>
</div> </div>

Loading…
Cancel
Save