|
|
@ -3348,6 +3348,10 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) |
|
|
|
apiDoc.stickerEmojiRaw = attribute.alt; |
|
|
|
apiDoc.stickerEmojiRaw = attribute.alt; |
|
|
|
apiDoc.stickerEmoji = RichTextProcessor.wrapRichText(apiDoc.stickerEmojiRaw, {noLinks: true, noLinebreaks: true}); |
|
|
|
apiDoc.stickerEmoji = RichTextProcessor.wrapRichText(apiDoc.stickerEmojiRaw, {noLinks: true, noLinebreaks: true}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (attribute.stickerset && |
|
|
|
|
|
|
|
attribute.stickerset._ == 'inputStickerSetID') { |
|
|
|
|
|
|
|
apiDoc.stickerSetID = attribute.stickerset.id; |
|
|
|
|
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'documentAttributeImageSize': |
|
|
|
case 'documentAttributeImageSize': |
|
|
|
apiDoc.w = attribute.w; |
|
|
|
apiDoc.w = attribute.w; |
|
|
@ -3640,16 +3644,19 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
.service('AppStickersManager', function ($q, $rootScope, $modal, FileManager, MtpApiManager, MtpApiFileManager, AppDocsManager, Storage) { |
|
|
|
.service('AppStickersManager', function ($q, $rootScope, $modal, _, FileManager, MtpApiManager, MtpApiFileManager, AppDocsManager, Storage) { |
|
|
|
|
|
|
|
|
|
|
|
var currentStickers = []; |
|
|
|
var currentStickers = []; |
|
|
|
|
|
|
|
var currentStickersets = []; |
|
|
|
var installedStickersets = {}; |
|
|
|
var installedStickersets = {}; |
|
|
|
|
|
|
|
var stickersetItems = {}; |
|
|
|
var applied = false; |
|
|
|
var applied = false; |
|
|
|
var started = false; |
|
|
|
var started = false; |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
start: start, |
|
|
|
start: start, |
|
|
|
openStickersetLink: openStickersetLink, |
|
|
|
openStickersetLink: openStickersetLink, |
|
|
|
|
|
|
|
installStickerset: installStickerset, |
|
|
|
getStickers: getStickers, |
|
|
|
getStickers: getStickers, |
|
|
|
getStickerset: getStickerset, |
|
|
|
getStickerset: getStickerset, |
|
|
|
getStickersImages: getStickersImages |
|
|
|
getStickersImages: getStickersImages |
|
|
@ -3670,26 +3677,49 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) |
|
|
|
function processRawStickers(stickers) { |
|
|
|
function processRawStickers(stickers) { |
|
|
|
if (applied !== stickers.hash) { |
|
|
|
if (applied !== stickers.hash) { |
|
|
|
applied = stickers.hash; |
|
|
|
applied = stickers.hash; |
|
|
|
var i, j, len1, len2, doc; |
|
|
|
var i, j, len1, len2, doc, setID, set; |
|
|
|
|
|
|
|
|
|
|
|
len1 = stickers.documents.length; |
|
|
|
len1 = stickers.documents.length; |
|
|
|
currentStickers = []; |
|
|
|
currentStickers = []; |
|
|
|
|
|
|
|
stickersetItems = {}; |
|
|
|
for (i = 0; i < len1; i++) { |
|
|
|
for (i = 0; i < len1; i++) { |
|
|
|
doc = stickers.documents[i]; |
|
|
|
doc = stickers.documents[i]; |
|
|
|
AppDocsManager.saveDoc(doc); |
|
|
|
AppDocsManager.saveDoc(doc); |
|
|
|
currentStickers.push(doc.id); |
|
|
|
currentStickers.push(doc.id); |
|
|
|
|
|
|
|
setID = doc.stickerSetID || 0; |
|
|
|
|
|
|
|
if (stickersetItems[setID] === undefined) { |
|
|
|
|
|
|
|
stickersetItems[setID] = []; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
stickersetItems[setID].push(doc.id); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (stickersetItems[0] !== undefined) { |
|
|
|
|
|
|
|
currentStickersets.push({ |
|
|
|
|
|
|
|
_: 'stickerSetDefault', |
|
|
|
|
|
|
|
id: 0, |
|
|
|
|
|
|
|
docIDs: stickersetItems[0] |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
len1 = stickers.sets.length; |
|
|
|
|
|
|
|
for (i = 0; i < len1; i++) { |
|
|
|
|
|
|
|
set = stickers.sets[i]; |
|
|
|
|
|
|
|
installedStickersets[set.id] = true; |
|
|
|
|
|
|
|
set.docIDs = stickersetItems[set.id] || []; |
|
|
|
|
|
|
|
currentStickersets.push(set); |
|
|
|
} |
|
|
|
} |
|
|
|
return currentStickers; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function getStickers () { |
|
|
|
return currentStickersets; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getStickers (force) { |
|
|
|
return Storage.get('all_stickers').then(function (stickers) { |
|
|
|
return Storage.get('all_stickers').then(function (stickers) { |
|
|
|
var layer = Config.Schema.API.layer; |
|
|
|
var layer = Config.Schema.API.layer; |
|
|
|
if (stickers.layer != layer) { |
|
|
|
if (stickers.layer != layer) { |
|
|
|
stickers = false; |
|
|
|
stickers = false; |
|
|
|
} |
|
|
|
} |
|
|
|
if (stickers && stickers.date > tsNow(true)) { |
|
|
|
if (stickers && stickers.date > tsNow(true) && !force) { |
|
|
|
return processRawStickers(stickers); |
|
|
|
return processRawStickers(stickers); |
|
|
|
} |
|
|
|
} |
|
|
|
return MtpApiManager.invokeApi('messages.getAllStickers', { |
|
|
|
return MtpApiManager.invokeApi('messages.getAllStickers', { |
|
|
@ -3742,10 +3772,32 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) |
|
|
|
for (var i = 0; i < result.documents.length; i++) { |
|
|
|
for (var i = 0; i < result.documents.length; i++) { |
|
|
|
AppDocsManager.saveDoc(result.documents[i]); |
|
|
|
AppDocsManager.saveDoc(result.documents[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
result.installed = installedStickersets[result.set.id] !== undefined; |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function installStickerset (set, uninstall) { |
|
|
|
|
|
|
|
var method = uninstall |
|
|
|
|
|
|
|
? 'messages.uninstallStickerSet' |
|
|
|
|
|
|
|
: 'messages.installStickerSet'; |
|
|
|
|
|
|
|
var inputStickerset = { |
|
|
|
|
|
|
|
_: 'inputStickerSetID', |
|
|
|
|
|
|
|
id: set.id, |
|
|
|
|
|
|
|
access_hash: set.access_hash |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
return MtpApiManager.invokeApi(method, { |
|
|
|
|
|
|
|
stickerset: inputStickerset |
|
|
|
|
|
|
|
}).then(function (result) { |
|
|
|
|
|
|
|
if (uninstall) { |
|
|
|
|
|
|
|
delete installedStickersets[set.id]; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
installedStickersets[set.id] = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
getStickers(true); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function openStickersetLink (shortName) { |
|
|
|
function openStickersetLink (shortName) { |
|
|
|
var scope = $rootScope.$new(true); |
|
|
|
var scope = $rootScope.$new(true); |
|
|
|
scope.inputStickerset = { |
|
|
|
scope.inputStickerset = { |
|
|
@ -3755,8 +3807,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) |
|
|
|
var modal = $modal.open({ |
|
|
|
var modal = $modal.open({ |
|
|
|
templateUrl: templateUrl('stickerset_modal'), |
|
|
|
templateUrl: templateUrl('stickerset_modal'), |
|
|
|
controller: 'StickersetModalController', |
|
|
|
controller: 'StickersetModalController', |
|
|
|
scope: scope/*, |
|
|
|
scope: scope, |
|
|
|
windowClass: 'error_modal_window'*/ |
|
|
|
windowClass: 'stickerset_modal_window' |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|