Browse Source

stickersets install draft

master
Igor Zhukov 9 years ago
parent
commit
8ed3baa01c
  1. 11
      app/js/controllers.js
  2. 4
      app/js/lib/config.js
  3. 17
      app/js/lib/schema.tl.txt
  4. 2
      app/js/message_composer.js
  5. 116
      app/js/services.js
  6. 45
      app/partials/desktop/stickerset_modal.html

11
app/js/controllers.js

@ -3840,3 +3840,14 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -3840,3 +3840,14 @@ angular.module('myApp.controllers', ['myApp.i18n'])
};
})
.controller('StickersetModalController', function ($scope, MtpApiManager, AppStickersManager) {
$scope.slice = {limit: 20, limitDelta: 20};
AppStickersManager.getStickerset($scope.inputStickerset).then(function (result) {
$scope.$broadcast('ui_height');
$scope.stickersetLoaded = true;
$scope.stickerset = result.set;
$scope.documents = result.documents;
});
})

4
app/js/lib/config.js

File diff suppressed because one or more lines are too long

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

@ -403,7 +403,7 @@ updateUserPhone#12b9417b user_id:int phone:string = Update; @@ -403,7 +403,7 @@ updateUserPhone#12b9417b user_id:int phone:string = Update;
documentAttributeImageSize#6c37c15c w:int h:int = DocumentAttribute;
documentAttributeAnimated#11b58939 = DocumentAttribute;
documentAttributeSticker#994c9882 alt:string = DocumentAttribute;
documentAttributeSticker#3a556302 alt:string stickerset:InputStickerSet = DocumentAttribute;
documentAttributeVideo#5910cccb duration:int w:int h:int = DocumentAttribute;
documentAttributeAudio#51448e5 duration:int = DocumentAttribute;
documentAttributeFilename#15590068 file_name:string = DocumentAttribute;
@ -414,7 +414,7 @@ messages.stickers#8a8ecd32 hash:string stickers:Vector<Document> = messages.Stic @@ -414,7 +414,7 @@ messages.stickers#8a8ecd32 hash:string stickers:Vector<Document> = messages.Stic
stickerPack#12b299d4 emoticon:string documents:Vector<long> = StickerPack;
messages.allStickersNotModified#e86602c3 = messages.AllStickers;
messages.allStickers#dcef3102 hash:string packs:Vector<StickerPack> documents:Vector<Document> = messages.AllStickers;
messages.allStickers#5ce352ec hash:string packs:Vector<StickerPack> sets:Vector<StickerSet> documents:Vector<Document> = messages.AllStickers;
disabledFeature#ae636f24 feature:string description:string = DisabledFeature;
@ -465,6 +465,14 @@ messageActionChatJoinedByLink#f89cf5e8 inviter_id:int = MessageAction; @@ -465,6 +465,14 @@ messageActionChatJoinedByLink#f89cf5e8 inviter_id:int = MessageAction;
updateReadMessagesContents#68c13933 messages:Vector<int> pts:int pts_count:int = Update;
inputStickerSetEmpty#ffb62b95 = InputStickerSet;
inputStickerSetID#9de7a269 id:long access_hash:long = InputStickerSet;
inputStickerSetShortName#861cc8a0 short_name:string = InputStickerSet;
stickerSet#a7a43b17 id:long access_hash:long title:string short_name:string = StickerSet;
messages.stickerSet#b60a24a6 set:StickerSet packs:Vector<StickerPack> documents:Vector<Document> = messages.StickerSet;
---functions---
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
@ -621,4 +629,7 @@ invokeWithoutUpdates#bf9459b7 {X:Type} query:!X = X; @@ -621,4 +629,7 @@ invokeWithoutUpdates#bf9459b7 {X:Type} query:!X = X;
messages.exportChatInvite#7d885289 chat_id:int = ExportedChatInvite;
messages.checkChatInvite#3eadb1bb hash:string = ChatInvite;
messages.importChatInvite#6c50051c hash:string = Updates;
messages.importChatInvite#6c50051c hash:string = Updates;
messages.getStickerSet#2619a90e stickerset:InputStickerSet = messages.StickerSet;
messages.installStickerSet#efbbfae9 stickerset:InputStickerSet = Bool;
messages.uninstallStickerSet#f96e55de stickerset:InputStickerSet = Bool;

2
app/js/message_composer.js

@ -15,7 +15,6 @@ @@ -15,7 +15,6 @@
var emojis = {};
var shortcuts = {};
var spritesheetPositions = {};
var stickers = {};
var index = false;
var popular = 'joy,kissing_heart,heart,heart_eyes,blush,grin,+1,relaxed,pensive,smile,sob,kiss,unamused,flushed,stuck_out_tongue_winking_eye,see_no_evil,wink,smiley,cry,stuck_out_tongue_closed_eyes,scream,rage,smirk,disappointed,sweat_smile,kissing_closed_eyes,speak_no_evil,relieved,grinning,yum,laughing,ok_hand,neutral_face,confused'.split(',');
@ -122,7 +121,6 @@ @@ -122,7 +121,6 @@
emojis: emojis,
shortcuts: shortcuts,
spritesheetPositions: spritesheetPositions,
stickers: stickers,
getPopularEmoji: getPopularEmoji,
pushPopularEmoji: pushPopularEmoji,
indexEmojis: indexEmojis,

116
app/js/services.js

@ -2284,7 +2284,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -2284,7 +2284,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
case 'messageMediaDocument':
if (message.media.document.sticker) {
notificationMessage = _('conversation_media_sticker');
var stickerEmoji = EmojiHelper.stickers[message.media.document.id];
var stickerEmoji = message.media.document.stickerEmojiRaw;
if (stickerEmoji !== undefined) {
notificationMessage = RichTextProcessor.wrapPlainText(stickerEmoji) + ' (' + notificationMessage + ')';
}
@ -3343,10 +3343,10 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -3343,10 +3343,10 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
break;
case 'documentAttributeSticker':
apiDoc.sticker = 1;
var stickerEmoji = attribute.alt || EmojiHelper.stickers[apiDoc.id];
if (stickerEmoji !== undefined) {
if (attribute.alt !== undefined) {
apiDoc.sticker = 2;
apiDoc.stickerEmoji = RichTextProcessor.wrapRichText(stickerEmoji, {noLinks: true, noLinebreaks: true});
apiDoc.stickerEmojiRaw = attribute.alt;
apiDoc.stickerEmoji = RichTextProcessor.wrapRichText(apiDoc.stickerEmojiRaw, {noLinks: true, noLinebreaks: true});
}
break;
case 'documentAttributeImageSize':
@ -3640,17 +3640,18 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -3640,17 +3640,18 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
}
})
.service('AppStickersManager', function ($q, FileManager, MtpApiManager, MtpApiFileManager, AppDocsManager, Storage) {
.service('AppStickersManager', function ($q, $rootScope, $modal, FileManager, MtpApiManager, MtpApiFileManager, AppDocsManager, Storage) {
var stickersToEmoji = {};
var currentStickers = [];
var installedStickersets = {};
var applied = false;
var started = false;
return {
start: start,
getStickerEmoji: getStickerEmoji,
openStickersetLink: openStickersetLink,
getStickers: getStickers,
getStickerset: getStickerset,
getStickersImages: getStickersImages
};
@ -3666,38 +3667,17 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -3666,38 +3667,17 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
getStickers().then(getStickersImages);
}
function getStickerEmoji(docID) {
return EmojiHelper.stickers[docID] || false;
}
function processRawStickers(stickers) {
if (applied !== stickers.hash) {
applied = stickers.hash;
var i, j, len1, len2;
var i, j, len1, len2, doc;
len1 = stickers.documents.length;
for (i = 0; i < len1; i++) {
AppDocsManager.saveDoc(stickers.documents[i]);
}
var pack, emoticon, docID;
var doneDocIDs = {};
currentStickers = [];
len1 = stickers.packs.length;
for (i = 0; i < len1; i++) {
pack = stickers.packs[i];
emoticon = pack.emoticon;
len2 = pack.documents.length;
for (j = 0; j < len2; j++) {
docID = pack.documents[j];
if (EmojiHelper.stickers[docID] === undefined) {
EmojiHelper.stickers[docID] = emoticon;
}
if (doneDocIDs[docID] === undefined) {
doneDocIDs[docID] = true;
currentStickers.push(docID);
}
}
doc = stickers.documents[i];
AppDocsManager.saveDoc(doc);
currentStickers.push(doc.id);
}
}
return currentStickers;
@ -3728,29 +3708,57 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -3728,29 +3708,57 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
})
}
function downloadStickerThumb (docID) {
var doc = AppDocsManager.getDoc(docID);
return MtpApiFileManager.downloadSmallFile(doc.thumb.location).then(function (blob) {
if (WebpManager.isWebpSupported()) {
return {
id: doc.id,
src: FileManager.getUrl(blob, 'image/webp')
};
}
return FileManager.getByteArray(blob).then(function (bytes) {
return {
id: doc.id,
src: WebpManager.getPngUrlFromData(bytes)
};
});
});
}
function getStickersImages () {
var promises = [];
angular.forEach(currentStickers, function (docID) {
var doc = AppDocsManager.getDoc(docID);
var promise = MtpApiFileManager.downloadSmallFile(doc.thumb.location).then(function (blob) {
if (WebpManager.isWebpSupported()) {
return {
id: docID,
src: FileManager.getUrl(blob, 'image/webp')
};
}
return FileManager.getByteArray(blob).then(function (bytes) {
return {
id: docID,
src: WebpManager.getPngUrlFromData(bytes)
};
});
});
promises.push(promise);
promises.push(downloadStickerThumb (docID));
});
return $q.all(promises);
}
function getStickerset (inputStickerset) {
return MtpApiManager.invokeApi('messages.getStickerSet', {
stickerset: inputStickerset
}).then(function (result) {
for (var i = 0; i < result.documents.length; i++) {
AppDocsManager.saveDoc(result.documents[i]);
}
return result;
});
}
function openStickersetLink (shortName) {
var scope = $rootScope.$new(true);
scope.inputStickerset = {
_: 'inputStickerSetShortName',
short_name: shortName
};
var modal = $modal.open({
templateUrl: templateUrl('stickerset_modal'),
controller: 'StickersetModalController',
scope: scope/*,
windowClass: 'error_modal_window'*/
});
}
})
.service('ApiUpdatesManager', function ($rootScope, MtpNetworkerFactory, AppUsersManager, AppChatsManager, AppPeersManager, MtpApiManager) {
@ -4278,6 +4286,9 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -4278,6 +4286,9 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
case 'joinchat':
url = 'tg://join?invite=' + path[1];
break;
case 'addstickers':
url = 'tg://addstickers?set=' + path[1];
break;
default:
url = 'tg://resolve?domain=' + path[0];
}
@ -5361,7 +5372,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -5361,7 +5372,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
})
.service('LocationParamsService', function ($rootScope, $routeParams, AppUsersManager, AppMessagesManager) {
.service('LocationParamsService', function ($rootScope, $routeParams, AppUsersManager, AppMessagesManager, AppStickersManager) {
var tgAddrRegEx = /^(web\+)?tg:(\/\/)?(.+)/;
@ -5391,6 +5402,11 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -5391,6 +5402,11 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
return true;
}
if (matches = url.match(/^addstickers\?set=(.+)$/)) {
AppStickersManager.openStickersetLink(matches[1]);
return true;
}
return false;
}

45
app/partials/desktop/stickerset_modal.html

@ -0,0 +1,45 @@ @@ -0,0 +1,45 @@
<div class="stickerset_modal_wrap md_modal_wrap" my-modal-position>
<div class="md_modal_head md_modal_head_simple">
<div class="md_modal_title_wrap">
<div class="md_modal_actions_wrap clearfix">
<a class="md_modal_action md_modal_action_close" ng-click="$dismiss()" my-i18n="modal_close"></a>
</div>
</div>
<div class="md_modal_title" my-i18n="stickerset_modal_title"></div>
</div>
<div class="md_modal_body">
<div my-stickerset-list class="stickerset_modal_col">
<div class="stickerset_wrap nano" my-infinite-scroller>
<div class="stickerset_scrollable_wrap nano-content" ng-switch="!stickersetLoaded">
<div ng-switch-when="true" class="stickerset_modal_loading" my-vertical-position="0.2" padding="true" my-i18n="stickerset_modal_loading">
<my-i18n-param name="dots">
<span my-loading-dots></span>
</my-i18n-param>
</div>
<div ng-switch-default>
<h4 ng-bind="stickerset.title"></h4>
<ul class="stickerset_modal_stickers_list">
<li class="stickerset_modal_sticker_wrap" ng-repeat="sticker in documents | limitTo: slice.limit">
<img class="stickerset_modal_sticker" my-load-sticker document="sticker"></img>
<div class="stickerset_modal_sticker_alt" ng-bind-html="sticker.stickerEmoji"></div>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
Loading…
Cancel
Save