Browse Source

Fixed its hole bug bug

master
Igor Zhukov 9 years ago
parent
commit
6a09ee41ef
  1. 27
      app/js/controllers.js
  2. 2
      app/js/directives.js
  3. 8
      app/js/lib/ng_utils.js
  4. 9
      app/js/messages_manager.js
  5. 20
      app/js/services.js
  6. 24
      app/less/app.less
  7. 8
      app/partials/desktop/stickerset_modal.html

27
app/js/controllers.js

@ -4660,7 +4660,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -4660,7 +4660,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
})
.controller('StickersetModalController', function ($scope, MtpApiManager, AppStickersManager) {
.controller('StickersetModalController', function ($scope, MtpApiManager, RichTextProcessor, AppStickersManager) {
$scope.slice = {limit: 20, limitDelta: 20};
AppStickersManager.getStickerset($scope.inputStickerset).then(function (result) {
@ -4669,6 +4669,31 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -4669,6 +4669,31 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.stickerset = result.set;
$scope.stickersetInstalled = result.installed;
$scope.documents = result.documents;
$scope.stickerEmojis = {};
angular.forEach($scope.documents, function (doc) {
$scope.stickerEmojis[doc.id] = RichTextProcessor.wrapRichText(doc.stickerEmojiRaw, {
noLinks: true,
noLinebreaks: true,
emojiIconSize: 26
});
});
// if (doc.id && doc.access_hash) {
// var inputMedia = {
// _: 'inputMediaDocument',
// id: {
// _: 'inputDocument',
// id: doc.id,
// access_hash: doc.access_hash
// }
// }
// var options = {
// replyToMsgID: $scope.draftMessage.replyToMessage && $scope.draftMessage.replyToMessage.mid
// };
// AppMessagesManager.sendOther($scope.curDialog.peerID, inputMedia, options);
// $scope.$broadcast('ui_message_send');
// }
});
$scope.toggleInstalled = function (installed) {

2
app/js/directives.js

@ -1074,7 +1074,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -1074,7 +1074,7 @@ angular.module('myApp.directives', ['myApp.filters'])
function updateSizes () {
$(element).css({
height: Math.min(500, $($window).height()
height: Math.min(600, $($window).height()
- (Config.Mobile ? 46 + 18 : 200))
});
$(stickersWrap).nanoScroller();

8
app/js/lib/ng_utils.js

@ -1484,6 +1484,7 @@ angular.module('izhukov.utils', []) @@ -1484,6 +1484,7 @@ angular.module('izhukov.utils', [])
var url;
var html = [];
var lastOffset = 0;
var curEmojiSize = options.emojiIconSize || emojiIconSize;
for (i = 0; i < len; i++) {
entity = entities[i];
if (entity.offset > lastOffset) {
@ -1600,9 +1601,9 @@ angular.module('izhukov.utils', []) @@ -1600,9 +1601,9 @@ angular.module('izhukov.utils', [])
'<span class="emoji emoji-',
entity.coords.category,
'-',
(emojiIconSize * entity.coords.column),
(curEmojiSize * entity.coords.column),
'-',
(emojiIconSize * entity.coords.row),
(curEmojiSize * entity.coords.row),
'" ',
'title="', entity.title, '">',
':', entity.title, ':</span>'
@ -1675,8 +1676,9 @@ angular.module('izhukov.utils', []) @@ -1675,8 +1676,9 @@ angular.module('izhukov.utils', [])
if (!options.nested && (emojiFound || options.hasNested)) {
text = text.replace(/\ufe0f|&#65039;|&#65533;|&#8205;/g, '', text);
var emojiSizeClass = curEmojiSize == 18 ? '' : (' emoji-w' + curEmojiSize);
text = text.replace(/<span class="emoji emoji-(\d)-(\d+)-(\d+)"(.+?)<\/span>/g,
'<span class="emoji emoji-spritesheet-$1" style="background-position: -$2px -$3px;" $4</span>');
'<span class="emoji ' + emojiSizeClass + ' emoji-spritesheet-$1" style="background-position: -$2px -$3px;" $4</span>');
}
return $sce.trustAs('html', text);

9
app/js/messages_manager.js

@ -1051,7 +1051,16 @@ angular.module('myApp.services') @@ -1051,7 +1051,16 @@ angular.module('myApp.services')
apiPromise = MtpApiManager.invokeApi('messages.readHistory', {
peer: AppPeersManager.getInputPeerByID(peerID),
max_id: 0
}).then(function (affectedMessages) {
ApiUpdatesManager.processUpdateMessage({
_: 'updateShort',
update: {
_: 'updatePts',
pts: affectedMessages.pts,
pts_count: affectedMessages.pts_count
}
});
})
}
historyStorage.readPromise = apiPromise.then(function () {

20
app/js/services.js

@ -2650,6 +2650,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -2650,6 +2650,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
}
function getDifference () {
console.trace(dT(), 'Get full diff');
if (!updatesState.syncLoading) {
updatesState.syncLoading = true;
updatesState.pendingSeqUpdates = {};
@ -2721,12 +2722,18 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -2721,12 +2722,18 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
channelState.syncLoading = true;
channelState.pendingPtsUpdates = [];
}
if (channelState.syncPending) {
clearTimeout(channelState.syncPending.timeout);
channelState.syncPending = false;
}
console.log(dT(), 'Get channel diff', AppChatsManager.getChat(channelID), channelState.pts);
MtpApiManager.invokeApi('updates.getChannelDifference', {
channel: AppChatsManager.getChannelInput(channelID),
filter: {_: 'channelMessagesFilterEmpty'},
pts: channelState.pts,
limit: 10
limit: 30
}).then(function (differenceResult) {
console.log(dT(), 'channel diff result', differenceResult);
channelState.pts = differenceResult.pts;
if (differenceResult._ == 'updates.channelDifferenceEmpty') {
@ -2809,12 +2816,16 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -2809,12 +2816,16 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
channelID = update.channel_id;
break;
}
// if (channelID) {
// console.log(dT(), channelID, update.pts, update);
// }
if (channelID && !AppChatsManager.hasChat(channelID)) {
console.log(dT(), 'skip update, missing channel', channelID, update);
return false;
}
var curState = channelID ? getChannelState(channelID, update.pts) : updatesState;
// console.log('process', channelID, curState, update);
console.log(dT(), 'process', channelID, curState, update);
if (curState.syncLoading) {
return false;
@ -2840,7 +2851,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -2840,7 +2851,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
if (update.pts) {
var newPts = curState.pts + (update.pts_count || 0);
if (newPts < update.pts) {
console.log(dT(), 'Pts hole', curState, update);
console.warn(dT(), 'Pts hole', curState, update, channelID && AppChatsManager.getChat(channelID));
curState.pendingPtsUpdates.push(update);
if (!curState.syncPending) {
curState.syncPending = {
@ -2860,6 +2871,9 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -2860,6 +2871,9 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
curState.pts = update.pts;
popPts = true;
}
if (channelID && options.date && updatesState.date < options.date) {
updatesState.date = options.date;
}
}
else if (!channelID && options.seq > 0) {
var seq = options.seq;

24
app/less/app.less

@ -3366,28 +3366,34 @@ ul.chat_modal_migrate_list { @@ -3366,28 +3366,34 @@ ul.chat_modal_migrate_list {
.stickerset_modal_window .modal-dialog {
max-width: 474px;
max-width: 642px;
width: auto;
}
.stickerset_modal_stickers_list {
padding: 25px;
}
.stickerset_modal_sticker_wrap {
list-style: none;
margin: 0 10px 10px 0;
margin: 0 5px 5px 0;
padding: 0;
position: relative;
display: block;
width: 96px;
height: 96px;
width: 192px;
height: 192px;
float: left;
border-radius: 3px;
overflow: hidden;
&:hover {
background: #f2f6fa;
}
}
.stickerset_modal_sticker {
width: 96px;
height: 96px;
width: 192px;
height: 192px;
}
.stickerset_modal_sticker img {
max-width: 96px;
max-height: 96px;
max-width: 192px;
max-height: 192px;
}
.stickerset_modal_sticker_alt {
position: absolute;

8
app/partials/desktop/stickerset_modal.html

@ -26,10 +26,10 @@ @@ -26,10 +26,10 @@
</div>
<div ng-switch-default class="stickerset_modal_stickers_list clearfix">
<div class="stickerset_modal_sticker_wrap" ng-repeat="sticker in documents | limitTo: slice.limit">
<div class="stickerset_modal_sticker" my-load-sticker document="sticker" thumb="true"></div>
<div class="stickerset_modal_sticker_alt" ng-bind-html="sticker.stickerEmoji"></div>
</div>
<a class="stickerset_modal_sticker_wrap" ng-repeat="sticker in documents | limitTo: slice.limit" ng-click="chooseSticker(sticker.id)">
<div class="stickerset_modal_sticker" my-load-sticker document="sticker"></div>
<div class="stickerset_modal_sticker_alt" ng-bind-html="stickerEmojis[sticker.id]"></div>
</a>
</div>
</div>

Loading…
Cancel
Save