Browse Source

Offline mode bugfixes

master
Igor Zhukov 11 years ago
parent
commit
d689ef25cc
  1. 2
      app/css/app.css
  2. 35
      app/js/controllers.js
  3. 12
      app/js/lib/mtproto.js
  4. 16
      app/js/services.js

2
app/css/app.css

@ -1550,6 +1550,8 @@ img.img_fullsize { @@ -1550,6 +1550,8 @@ img.img_fullsize {
box-shadow: none;
-webkit-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
-webkit-user-select: text;
}
.emoji-wysiwyg-editor img {
width: 20px;

35
app/js/controllers.js

@ -505,6 +505,7 @@ angular.module('myApp.controllers', []) @@ -505,6 +505,7 @@ angular.module('myApp.controllers', [])
$scope.missedCount = 0;
}
$scope.mediaType = mediaType || false;
$scope.history = [];
loadHistory();
}
@ -719,9 +720,11 @@ angular.module('myApp.controllers', []) @@ -719,9 +720,11 @@ angular.module('myApp.controllers', [])
NotificationsManager.getPeerMuted($scope.userID).then(function (muted) {
$scope.settings.notifications = !muted;
});
$scope.$watch('settings.notifications', function(newValue) {
$scope.$watch('settings.notifications', function(newValue, oldValue) {
if (newValue === oldValue) {
return false;
}
NotificationsManager.getPeerSettings($scope.userID).then(function (settings) {
if (newValue) {
settings.mute_until = 0;
@ -731,6 +734,8 @@ angular.module('myApp.controllers', []) @@ -731,6 +734,8 @@ angular.module('myApp.controllers', [])
NotificationsManager.savePeerSettings($scope.userID, settings);
});
});
});
$scope.goToHistory = function () {
$rootScope.$broadcast('history_focus', {peerString: $scope.user.peerString});
@ -763,9 +768,11 @@ angular.module('myApp.controllers', []) @@ -763,9 +768,11 @@ angular.module('myApp.controllers', [])
NotificationsManager.getPeerMuted(-$scope.chatID).then(function (muted) {
$scope.settings.notifications = !muted;
});
$scope.$watch('settings.notifications', function(newValue) {
$scope.$watch('settings.notifications', function(newValue, oldValue) {
if (newValue === oldValue) {
return false;
}
NotificationsManager.getPeerSettings(-$scope.chatID).then(function (settings) {
if (newValue) {
settings.mute_until = 0;
@ -775,6 +782,8 @@ angular.module('myApp.controllers', []) @@ -775,6 +782,8 @@ angular.module('myApp.controllers', [])
NotificationsManager.savePeerSettings(-$scope.chatID, settings);
});
});
});
$scope.leaveGroup = function () {
MtpApiManager.invokeApi('messages.deleteChatUser', {
@ -843,9 +852,11 @@ angular.module('myApp.controllers', []) @@ -843,9 +852,11 @@ angular.module('myApp.controllers', [])
$scope.notify.desktop = !settings[0];
$scope.notify.sound = !settings[1];
$scope.send.enter = settings[2] ? '' : '1';
});
$scope.$watch('notify.sound', function(newValue) {
$scope.$watch('notify.sound', function(newValue, oldValue) {
if (newValue === oldValue) {
return false;
}
if (newValue) {
AppConfigManager.remove('notify_nosound');
} else {
@ -854,7 +865,10 @@ angular.module('myApp.controllers', []) @@ -854,7 +865,10 @@ angular.module('myApp.controllers', [])
}
});
$scope.$watch('notify.desktop', function(newValue) {
$scope.$watch('notify.desktop', function(newValue, oldValue) {
if (newValue === oldValue) {
return false;
}
if (newValue) {
AppConfigManager.remove('notify_nodesktop');
} else {
@ -862,7 +876,10 @@ angular.module('myApp.controllers', []) @@ -862,7 +876,10 @@ angular.module('myApp.controllers', [])
}
});
$scope.$watch('send.enter', function(newValue) {
$scope.$watch('send.enter', function(newValue, oldValue) {
if (newValue === oldValue) {
return false;
}
if (newValue) {
AppConfigManager.remove('send_ctrlenter');
} else {
@ -870,6 +887,8 @@ angular.module('myApp.controllers', []) @@ -870,6 +887,8 @@ angular.module('myApp.controllers', [])
}
$rootScope.$broadcast('settings_changed');
});
});
$scope.error = {};
$scope.save = function (profileForm) {

12
app/js/lib/mtproto.js

@ -1637,13 +1637,18 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato @@ -1637,13 +1637,18 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
if (!this.connectionInited) {
serializer.storeInt(962726977, 'InokeWithLayer10');
serializer.storeInt(0x69796de9, 'initConnection');
serializer.storeInt(777, 'api_id');
serializer.storeInt(2496, 'api_id');
serializer.storeString(navigator.userAgent || 'Unknown UserAgent', 'device_model');
serializer.storeString(navigator.platform || 'Unknown Platform', 'system_version');
serializer.storeString('0.1', 'app_version');
serializer.storeString(navigator.language || 'en', 'lang_code');
}
if (options.afterMessageID) {
serializer.storeInt(0xcb9f372d, 'invokeAfterMsg');
serializer.storeLong(options.afterMessageID, 'msg_id');
}
serializer.storeMethod(method, params);
var messageID = MtpMessageIdGenerator.generateID(),
@ -1656,7 +1661,7 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato @@ -1656,7 +1661,7 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
};
if (window._debugMode) {
console.log('Api call', method, params, messageID, seqNo)
console.log('Api call', method, params, messageID, seqNo, options);
} else {
console.log('Api call', method, messageID, seqNo);
}
@ -1711,6 +1716,9 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato @@ -1711,6 +1716,9 @@ factory('MtpNetworkerFactory', function (MtpDcConfigurator, MtpMessageIdGenerato
if (!options || !options.noShedule) {
this.sheduleRequest();
}
if (angular.isObject(options)) {
options.messageID = message.msg_id;
}
return deferred.promise;
};

16
app/js/services.js

@ -570,6 +570,7 @@ angular.module('myApp.services', []) @@ -570,6 +570,7 @@ angular.module('myApp.services', [])
var dialogsStorage = {count: null, dialogs: []};
var pendingByRandomID = {};
var pendingByMessageID = {};
var pendingAfterMsgs = {};
var tempID = -1;
@ -958,11 +959,18 @@ angular.module('myApp.services', []) @@ -958,11 +959,18 @@ angular.module('myApp.services', [])
message.send = function () {
toggleError(false);
var sentRequestOptions = {};
if (pendingAfterMsgs[peerID]) {
sentRequestOptions.afterMessageID = pendingAfterMsgs[peerID].messageID;
}
MtpApiManager.invokeApi('messages.sendMessage', {
peer: inputPeer,
message: text,
random_id: randomID
}).then(function (result) {
}, sentRequestOptions).then(function (result) {
if (pendingAfterMsgs[peerID] === sentRequestOptions) {
delete pendingAfterMsgs[peerID];
}
if (ApiUpdatesManager.saveSeq(result.seq)) {
ApiUpdatesManager.saveUpdate({
_: 'updateMessageID',
@ -981,6 +989,8 @@ angular.module('myApp.services', []) @@ -981,6 +989,8 @@ angular.module('myApp.services', [])
}, function (error) {
toggleError(true);
});
pendingAfterMsgs[peerID] = sentRequestOptions;
};
saveMessages([message]);
@ -1016,8 +1026,6 @@ angular.module('myApp.services', []) @@ -1016,8 +1026,6 @@ angular.module('myApp.services', [])
attachType = 'doc';
}
console.log(11, options.isMedia, file.type, attachType);
if (historyStorage === undefined) {
historyStorage = historiesStorage[peerID] = {count: null, history: [], pending: []};
}
@ -1347,7 +1355,9 @@ angular.module('myApp.services', []) @@ -1347,7 +1355,9 @@ angular.module('myApp.services', [])
}
$rootScope.$on('apiUpdate', function (e, update) {
// if (update._ != 'updateUserStatus') {
// console.log('on apiUpdate', update);
// }
switch (update._) {
case 'updateMessageID':
pendingByMessageID[update.id] = update.random_id;

Loading…
Cancel
Save