Browse Source

Notifications settings sync layer 14

master
Igor Zhukov 11 years ago
parent
commit
8a78e69487
  1. 4
      app/css/app.css
  2. 4
      app/js/controllers.js
  3. 2
      app/js/lib/mtproto.js
  4. 34
      app/js/lib/schema.tl.txt
  5. 26
      app/js/services.js

4
app/css/app.css

@ -618,7 +618,7 @@ a.tg_radio_on:hover i.icon-radio {
height: 100%; height: 100%;
} }
.img_fullsize_progress_wrap { .img_fullsize_progress_wrap {
background: rgba(0,0,0, .1); /*background: rgba(0,0,0, .1);*/
position: relative; position: relative;
} }
.img_fullsize_progress { .img_fullsize_progress {
@ -1879,7 +1879,7 @@ img.img_fullsize {
margin: 0 auto; margin: 0 auto;
} }
.media_modal_info { .media_modal_info {
color: #777; color: #999;
margin: 20px 0 0; margin: 20px 0 0;
} }
.media_modal_actions { .media_modal_actions {

4
app/js/controllers.js

@ -1050,7 +1050,7 @@ angular.module('myApp.controllers', [])
} else { } else {
settings.mute_until = 2000000000; settings.mute_until = 2000000000;
} }
NotificationsManager.savePeerSettings($scope.userID, settings); NotificationsManager.updatePeerSettings($scope.userID, settings);
}); });
}); });
}); });
@ -1142,7 +1142,7 @@ angular.module('myApp.controllers', [])
} else { } else {
settings.mute_until = 2000000000; settings.mute_until = 2000000000;
} }
NotificationsManager.savePeerSettings(-$scope.chatID, settings); NotificationsManager.updatePeerSettings(-$scope.chatID, settings);
}); });
}); });
}); });

2
app/js/lib/mtproto.js

@ -732,7 +732,7 @@ function TLDeserialization (buffer, options) {
TLDeserialization.prototype.readInt = function (field) { TLDeserialization.prototype.readInt = function (field) {
if (this.offset >= this.intView.length * 4) { if (this.offset >= this.intView.length * 4) {
throw new Error('Nothing to fetch'); throw new Error('Nothing to fetch: ' + field);
} }
var i = this.intView[this.offset / 4]; var i = this.intView[this.offset / 4];

34
app/js/lib/schema.tl.txt

@ -27,8 +27,8 @@ inputMediaUploadedPhoto#2dc53a7d file:InputFile = InputMedia;
inputMediaPhoto#8f2ab2ec id:InputPhoto = InputMedia; inputMediaPhoto#8f2ab2ec id:InputPhoto = InputMedia;
inputMediaGeoPoint#f9c44144 geo_point:InputGeoPoint = InputMedia; inputMediaGeoPoint#f9c44144 geo_point:InputGeoPoint = InputMedia;
inputMediaContact#a6e45987 phone_number:string first_name:string last_name:string = InputMedia; inputMediaContact#a6e45987 phone_number:string first_name:string last_name:string = InputMedia;
inputMediaUploadedVideo#4847d92a file:InputFile duration:int w:int h:int = InputMedia; inputMediaUploadedVideo#133ad6f6 file:InputFile duration:int w:int h:int mime_type:string = InputMedia;
inputMediaUploadedThumbVideo#e628a145 file:InputFile thumb:InputFile duration:int w:int h:int = InputMedia; inputMediaUploadedThumbVideo#9912dabf file:InputFile thumb:InputFile duration:int w:int h:int mime_type:string = InputMedia;
inputMediaVideo#7f023ae6 id:InputVideo = InputMedia; inputMediaVideo#7f023ae6 id:InputVideo = InputMedia;
inputChatPhotoEmpty#1ca48f57 = InputChatPhoto; inputChatPhotoEmpty#1ca48f57 = InputChatPhoto;
@ -117,7 +117,7 @@ messageActionChatDeletePhoto#95e3fbef = MessageAction;
messageActionChatAddUser#5e3cfc4b user_id:int = MessageAction; messageActionChatAddUser#5e3cfc4b user_id:int = MessageAction;
messageActionChatDeleteUser#b2ae9b0c user_id:int = MessageAction; messageActionChatDeleteUser#b2ae9b0c user_id:int = MessageAction;
dialog#214a8cdf peer:Peer top_message:int unread_count:int = Dialog; dialog#ab3a99ac peer:Peer top_message:int unread_count:int notify_settings:PeerNotifySettings = Dialog;
photoEmpty#2331b22d id:long = Photo; photoEmpty#2331b22d id:long = Photo;
photo#22b56751 id:long access_hash:long user_id:int date:int caption:string geo:GeoPoint sizes:Vector<PhotoSize> = Photo; photo#22b56751 id:long access_hash:long user_id:int date:int caption:string geo:GeoPoint sizes:Vector<PhotoSize> = Photo;
@ -127,7 +127,7 @@ photoSize#77bfb61b type:string location:FileLocation w:int h:int size:int = Phot
photoCachedSize#e9a734fa type:string location:FileLocation w:int h:int bytes:bytes = PhotoSize; photoCachedSize#e9a734fa type:string location:FileLocation w:int h:int bytes:bytes = PhotoSize;
videoEmpty#c10658a8 id:long = Video; videoEmpty#c10658a8 id:long = Video;
video#5a04a49f id:long access_hash:long user_id:int date:int caption:string duration:int size:int thumb:PhotoSize dc_id:int w:int h:int = Video; video#388fa391 id:long access_hash:long user_id:int date:int caption:string duration:int mime_type:string size:int thumb:PhotoSize dc_id:int w:int h:int = Video;
geoPointEmpty#1117dd5f = GeoPoint; geoPointEmpty#1117dd5f = GeoPoint;
geoPoint#2049d70c long:double lat:double = GeoPoint; geoPoint#2049d70c long:double lat:double = GeoPoint;
@ -187,7 +187,7 @@ contacts.link#eccea3f5 my_link:contacts.MyLink foreign_link:contacts.ForeignLink
contacts.contacts#6f8b8cb2 contacts:Vector<Contact> users:Vector<User> = contacts.Contacts; contacts.contacts#6f8b8cb2 contacts:Vector<Contact> users:Vector<User> = contacts.Contacts;
contacts.contactsNotModified#b74ba9d2 = contacts.Contacts; contacts.contactsNotModified#b74ba9d2 = contacts.Contacts;
contacts.importedContacts#d1cd0a4c imported:Vector<ImportedContact> users:Vector<User> = contacts.ImportedContacts; contacts.importedContacts#ad524315 imported:Vector<ImportedContact> retry_contacts:Vector<long> users:Vector<User> = contacts.ImportedContacts;
contacts.blocked#1c138d15 blocked:Vector<ContactBlocked> users:Vector<User> = contacts.Blocked; contacts.blocked#1c138d15 blocked:Vector<ContactBlocked> users:Vector<User> = contacts.Blocked;
contacts.blockedSlice#900802a1 count:int blocked:Vector<ContactBlocked> users:Vector<User> = contacts.Blocked; contacts.blockedSlice#900802a1 count:int blocked:Vector<ContactBlocked> users:Vector<User> = contacts.Blocked;
@ -334,7 +334,7 @@ decryptedMessageService#aa48327d random_id:long random_bytes:bytes action:Decryp
decryptedMessageMediaEmpty#89f5c4a = DecryptedMessageMedia; decryptedMessageMediaEmpty#89f5c4a = DecryptedMessageMedia;
decryptedMessageMediaPhoto#32798a8c thumb:bytes thumb_w:int thumb_h:int w:int h:int size:int key:bytes iv:bytes = DecryptedMessageMedia; decryptedMessageMediaPhoto#32798a8c thumb:bytes thumb_w:int thumb_h:int w:int h:int size:int key:bytes iv:bytes = DecryptedMessageMedia;
decryptedMessageMediaVideo#4cee6ef3 thumb:bytes thumb_w:int thumb_h:int duration:int w:int h:int size:int key:bytes iv:bytes = DecryptedMessageMedia; decryptedMessageMediaVideo#524a415d thumb:bytes thumb_w:int thumb_h:int duration:int mime_type:string w:int h:int size:int key:bytes iv:bytes = DecryptedMessageMedia;
decryptedMessageMediaGeoPoint#35480a59 lat:double long:double = DecryptedMessageMedia; decryptedMessageMediaGeoPoint#35480a59 lat:double long:double = DecryptedMessageMedia;
decryptedMessageMediaContact#588a0a97 phone_number:string first_name:string last_name:string user_id:int = DecryptedMessageMedia; decryptedMessageMediaContact#588a0a97 phone_number:string first_name:string last_name:string user_id:int = DecryptedMessageMedia;
@ -354,7 +354,7 @@ updateChatParticipantAdd#3a0eeb22 chat_id:int user_id:int inviter_id:int version
updateChatParticipantDelete#6e5f8c22 chat_id:int user_id:int version:int = Update; updateChatParticipantDelete#6e5f8c22 chat_id:int user_id:int version:int = Update;
updateDcOptions#8e5e9873 dc_options:Vector<DcOption> = Update; updateDcOptions#8e5e9873 dc_options:Vector<DcOption> = Update;
inputMediaUploadedAudio#61a6d436 file:InputFile duration:int = InputMedia; inputMediaUploadedAudio#4e498cab file:InputFile duration:int mime_type:string = InputMedia;
inputMediaAudio#89938781 id:InputAudio = InputMedia; inputMediaAudio#89938781 id:InputAudio = InputMedia;
inputMediaUploadedDocument#34e794bd file:InputFile file_name:string mime_type:string = InputMedia; inputMediaUploadedDocument#34e794bd file:InputFile file_name:string mime_type:string = InputMedia;
inputMediaUploadedThumbDocument#3e46de5d file:InputFile thumb:InputFile file_name:string mime_type:string = InputMedia; inputMediaUploadedThumbDocument#3e46de5d file:InputFile thumb:InputFile file_name:string mime_type:string = InputMedia;
@ -373,16 +373,30 @@ inputAudioFileLocation#74dc404d id:long access_hash:long = InputFileLocation;
inputDocumentFileLocation#4e45abe9 id:long access_hash:long = InputFileLocation; inputDocumentFileLocation#4e45abe9 id:long access_hash:long = InputFileLocation;
decryptedMessageMediaDocument#b095434b thumb:bytes thumb_w:int thumb_h:int file_name:string mime_type:string size:int key:bytes iv:bytes = DecryptedMessageMedia; decryptedMessageMediaDocument#b095434b thumb:bytes thumb_w:int thumb_h:int file_name:string mime_type:string size:int key:bytes iv:bytes = DecryptedMessageMedia;
decryptedMessageMediaAudio#6080758f duration:int size:int key:bytes iv:bytes = DecryptedMessageMedia; decryptedMessageMediaAudio#57e0a9cb duration:int mime_type:string size:int key:bytes iv:bytes = DecryptedMessageMedia;
audioEmpty#586988d8 id:long = Audio; audioEmpty#586988d8 id:long = Audio;
audio#427425e7 id:long access_hash:long user_id:int date:int duration:int size:int dc_id:int = Audio; audio#c7ac6496 id:long access_hash:long user_id:int date:int duration:int mime_type:string size:int dc_id:int = Audio;
documentEmpty#36f8c871 id:long = Document; documentEmpty#36f8c871 id:long = Document;
document#9efc6326 id:long access_hash:long user_id:int date:int file_name:string mime_type:string size:int thumb:PhotoSize dc_id:int = Document; document#9efc6326 id:long access_hash:long user_id:int date:int file_name:string mime_type:string size:int thumb:PhotoSize dc_id:int = Document;
help.support#17c6b5f6 phone_number:string user:User = help.Support; help.support#17c6b5f6 phone_number:string user:User = help.Support;
decryptedMessageActionReadMessages#c4f40be random_ids:Vector<long> = DecryptedMessageAction;
decryptedMessageActionDeleteMessages#65614304 random_ids:Vector<long> = DecryptedMessageAction;
decryptedMessageActionScreenshotMessages#8ac1f475 random_ids:Vector<long> = DecryptedMessageAction;
decryptedMessageActionFlushHistory#6719e45c = DecryptedMessageAction;
decryptedMessageActionNotifyLayer#f3048883 layer:int = DecryptedMessageAction;
notifyPeer#9fd40bd8 peer:Peer = NotifyPeer;
notifyUsers#b4c83b4c = NotifyPeer;
notifyChats#c007cec3 = NotifyPeer;
notifyAll#74d07c60 = NotifyPeer;
updateUserBlocked#80ece81a user_id:int blocked:Bool = Update;
updateNotifySettings#bec268ef peer:NotifyPeer notify_settings:PeerNotifySettings = Update;
---functions--- ---functions---
invokeAfterMsg#cb9f372d msg_id:long query:!X = X; invokeAfterMsg#cb9f372d msg_id:long query:!X = X;
@ -494,4 +508,4 @@ initConnection#69796de9 api_id:int device_model:string system_version:string app
help.getSupport#9cdf08cd = help.Support; help.getSupport#9cdf08cd = help.Support;
invokeWithLayer12#dda60d3c query:!X = X; invokeWithLayer14#2b9b08fa query:!X = X;

26
app/js/services.js

@ -770,6 +770,8 @@ angular.module('myApp.services', [])
if (historiesStorage[peerID] === undefined) { if (historiesStorage[peerID] === undefined) {
historiesStorage[peerID] = {count: null, history: [dialog.top_message], pending: []} historiesStorage[peerID] = {count: null, history: [dialog.top_message], pending: []}
} }
NotificationsManager.savePeerSettings(peerID, dialog.notify_settings);
}); });
return { return {
@ -2992,6 +2994,18 @@ angular.module('myApp.services', [])
} }
}); });
$rootScope.$on('apiUpdate', function (e, update) {
// console.log('on apiUpdate', update);
switch (update._) {
case 'updateNotifySettings':
if (update.peer._ == 'notifyPeer') {
var peerID = AppPeersManager.getPeerID(update.peer.peer);
savePeerSettings(peerID, update.notify_settings);
}
break;
}
});
return { return {
start: start, start: start,
notify: notify, notify: notify,
@ -2999,7 +3013,8 @@ angular.module('myApp.services', [])
clear: notificationsClear, clear: notificationsClear,
getPeerSettings: getPeerSettings, getPeerSettings: getPeerSettings,
getPeerMuted: getPeerMuted, getPeerMuted: getPeerMuted,
savePeerSettings: savePeerSettings savePeerSettings: savePeerSettings,
updatePeerSettings: updatePeerSettings
}; };
function getPeerSettings (peerID) { function getPeerSettings (peerID) {
@ -3016,11 +3031,16 @@ angular.module('myApp.services', [])
} }
function savePeerSettings (peerID, settings) { function savePeerSettings (peerID, settings) {
// console.trace(dT(), 'peer settings', peerID, settings);
peerSettings[peerID] = $q.when(settings);
}
function updatePeerSettings (peerID, settings) {
savePeerSettings(peerID, settings);
var inputSettings = angular.copy(settings); var inputSettings = angular.copy(settings);
inputSettings._ = 'inputPeerNotifySettings'; inputSettings._ = 'inputPeerNotifySettings';
peerSettings[peerID] = $q.when(settings);
return MtpApiManager.invokeApi('account.updateNotifySettings', { return MtpApiManager.invokeApi('account.updateNotifySettings', {
peer: { peer: {
_: 'inputNotifyPeer', _: 'inputNotifyPeer',

Loading…
Cancel
Save