Browse Source

Offline mode bugfixes

master
Igor Zhukov 11 years ago
parent
commit
d689ef25cc
  1. 2
      app/css/app.css
  2. 97
      app/js/controllers.js
  3. 12
      app/js/lib/mtproto.js
  4. 18
      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;

97
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,19 +720,23 @@ angular.module('myApp.controllers', []) @@ -719,19 +720,23 @@ angular.module('myApp.controllers', [])
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;
$scope.$watch('settings.notifications', function(newValue, oldValue) {
if (newValue === oldValue) {
return false;
}
NotificationsManager.savePeerSettings($scope.userID, settings);
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 () {
$rootScope.$broadcast('history_focus', {peerString: $scope.user.peerString});
};
@ -763,19 +768,23 @@ angular.module('myApp.controllers', []) @@ -763,19 +768,23 @@ angular.module('myApp.controllers', [])
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;
$scope.$watch('settings.notifications', function(newValue, oldValue) {
if (newValue === oldValue) {
return false;
}
NotificationsManager.savePeerSettings(-$scope.chatID, settings);
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,
@ -843,34 +852,44 @@ angular.module('myApp.controllers', []) @@ -843,34 +852,44 @@ 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) {
if (newValue) {
AppConfigManager.remove('notify_nosound');
} else {
AppConfigManager.set({notify_nosound: true});
NotificationsManager.clear();
}
});
$scope.$watch('notify.sound', function(newValue, oldValue) {
if (newValue === oldValue) {
return false;
}
if (newValue) {
AppConfigManager.remove('notify_nosound');
} else {
AppConfigManager.set({notify_nosound: true});
NotificationsManager.clear();
}
});
$scope.$watch('notify.desktop', function(newValue) {
if (newValue) {
AppConfigManager.remove('notify_nodesktop');
} else {
AppConfigManager.set({notify_nodesktop: true});
}
});
$scope.$watch('notify.desktop', function(newValue, oldValue) {
if (newValue === oldValue) {
return false;
}
if (newValue) {
AppConfigManager.remove('notify_nodesktop');
} else {
AppConfigManager.set({notify_nodesktop: true});
}
});
$scope.$watch('send.enter', function(newValue) {
if (newValue) {
AppConfigManager.remove('send_ctrlenter');
} else {
AppConfigManager.set({send_ctrlenter: true});
}
$rootScope.$broadcast('settings_changed');
$scope.$watch('send.enter', function(newValue, oldValue) {
if (newValue === oldValue) {
return false;
}
if (newValue) {
AppConfigManager.remove('send_ctrlenter');
} else {
AppConfigManager.set({send_ctrlenter: true});
}
$rootScope.$broadcast('settings_changed');
});
});
$scope.error = {};
$scope.save = function (profileForm) {
MtpApiManager.invokeApi('account.updateProfile', {

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;
};

18
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) {
// console.log('on apiUpdate', update);
// if (update._ != 'updateUserStatus') {
// console.log('on apiUpdate', update);
// }
switch (update._) {
case 'updateMessageID':
pendingByMessageID[update.id] = update.random_id;

Loading…
Cancel
Save