Improved stickers box
This commit is contained in:
parent
6a09ee41ef
commit
0b1ddc85f6
@ -1911,7 +1911,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
|||||||
}
|
}
|
||||||
if (len > 10) {
|
if (len > 10) {
|
||||||
if (curPeer) {
|
if (curPeer) {
|
||||||
if (exlen > 10) {
|
if (exlen > 10 && isIDLE) {
|
||||||
minID = history.messages[exlen - 1].mid;
|
minID = history.messages[exlen - 1].mid;
|
||||||
$scope.historyState.skipped = hasLess = minID > 0;
|
$scope.historyState.skipped = hasLess = minID > 0;
|
||||||
if (hasLess) {
|
if (hasLess) {
|
||||||
@ -2130,16 +2130,8 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
|||||||
replyToMsgID: $scope.draftMessage.replyToMessage && $scope.draftMessage.replyToMessage.mid
|
replyToMsgID: $scope.draftMessage.replyToMessage && $scope.draftMessage.replyToMessage.mid
|
||||||
};
|
};
|
||||||
do {
|
do {
|
||||||
|
AppMessagesManager.sendText($scope.curDialog.peerID, text.substr(0, 4096), options);
|
||||||
(function (peerID, curText, curTimeout) {
|
|
||||||
setTimeout(function () {
|
|
||||||
AppMessagesManager.sendText(peerID, curText, options);
|
|
||||||
}, curTimeout)
|
|
||||||
})($scope.curDialog.peerID, text.substr(0, 4096), timeout);
|
|
||||||
|
|
||||||
text = text.substr(4096);
|
text = text.substr(4096);
|
||||||
timeout += 100;
|
|
||||||
|
|
||||||
} while (text.length);
|
} while (text.length);
|
||||||
}
|
}
|
||||||
fwdsSend();
|
fwdsSend();
|
||||||
@ -2331,9 +2323,9 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
|||||||
$scope.draftMessage.fwdMessages.length) {
|
$scope.draftMessage.fwdMessages.length) {
|
||||||
var ids = $scope.draftMessage.fwdMessages.slice();
|
var ids = $scope.draftMessage.fwdMessages.slice();
|
||||||
fwdsClear();
|
fwdsClear();
|
||||||
setTimeout(function () {
|
setZeroTimeout(function () {
|
||||||
AppMessagesManager.forwardMessages($scope.curDialog.peerID, ids);
|
AppMessagesManager.forwardMessages($scope.curDialog.peerID, ids);
|
||||||
}, 0);
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4660,7 +4652,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
.controller('StickersetModalController', function ($scope, MtpApiManager, RichTextProcessor, AppStickersManager) {
|
.controller('StickersetModalController', function ($scope, $rootScope, $modalInstance, MtpApiManager, RichTextProcessor, AppStickersManager, AppDocsManager, AppMessagesManager, LocationParamsService) {
|
||||||
$scope.slice = {limit: 20, limitDelta: 20};
|
$scope.slice = {limit: 20, limitDelta: 20};
|
||||||
|
|
||||||
AppStickersManager.getStickerset($scope.inputStickerset).then(function (result) {
|
AppStickersManager.getStickerset($scope.inputStickerset).then(function (result) {
|
||||||
@ -4679,26 +4671,32 @@ angular.module('myApp.controllers', ['myApp.i18n'])
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// 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) {
|
$scope.toggleInstalled = function (installed) {
|
||||||
AppStickersManager.installStickerset($scope.stickerset, !installed).then(function () {
|
AppStickersManager.installStickerset($scope.stickerset, !installed).then(function () {
|
||||||
$scope.stickersetInstalled = installed;
|
$scope.stickersetInstalled = installed;
|
||||||
})
|
})
|
||||||
}
|
};
|
||||||
|
|
||||||
|
$scope.chooseSticker = function (docID) {
|
||||||
|
var doc = AppDocsManager.getDoc(docID);
|
||||||
|
if (!doc.id || !doc.access_hash || !$rootScope.selectedPeerID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var inputMedia = {
|
||||||
|
_: 'inputMediaDocument',
|
||||||
|
id: {
|
||||||
|
_: 'inputDocument',
|
||||||
|
id: doc.id,
|
||||||
|
access_hash: doc.access_hash
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AppMessagesManager.sendOther($rootScope.selectedPeerID, inputMedia);
|
||||||
|
$modalInstance.close(doc.id);
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.share = function () {
|
||||||
|
LocationParamsService.shareUrl('https://telegram.me/addstickers/' + $scope.stickerset.short_name, $scope.stickerset.title);
|
||||||
|
};
|
||||||
})
|
})
|
||||||
|
@ -106,6 +106,7 @@
|
|||||||
"stickerset_modal_title_loading": "Stickerset",
|
"stickerset_modal_title_loading": "Stickerset",
|
||||||
"stickerset_modal_install": "Add stickers",
|
"stickerset_modal_install": "Add stickers",
|
||||||
"stickerset_modal_uninstall": "Remove stickers",
|
"stickerset_modal_uninstall": "Remove stickers",
|
||||||
|
"stickerset_modal_share": "Share",
|
||||||
"stickerset_modal_loading": "Loading{dots}",
|
"stickerset_modal_loading": "Loading{dots}",
|
||||||
|
|
||||||
"page_title_pluralize_notifications": "{'0': 'No notifications', 'one': '1 notification', 'other': '{} notifications'}",
|
"page_title_pluralize_notifications": "{'0': 'No notifications', 'one': '1 notification', 'other': '{} notifications'}",
|
||||||
|
@ -2650,7 +2650,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getDifference () {
|
function getDifference () {
|
||||||
console.trace(dT(), 'Get full diff');
|
// console.trace(dT(), 'Get full diff');
|
||||||
if (!updatesState.syncLoading) {
|
if (!updatesState.syncLoading) {
|
||||||
updatesState.syncLoading = true;
|
updatesState.syncLoading = true;
|
||||||
updatesState.pendingSeqUpdates = {};
|
updatesState.pendingSeqUpdates = {};
|
||||||
@ -2704,7 +2704,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
updatesState.pts = nextState.pts;
|
updatesState.pts = nextState.pts;
|
||||||
updatesState.date = nextState.date;
|
updatesState.date = nextState.date;
|
||||||
|
|
||||||
console.log(dT(), 'apply diff', updatesState.seq, updatesState.pts);
|
// console.log(dT(), 'apply diff', updatesState.seq, updatesState.pts);
|
||||||
|
|
||||||
if (differenceResult._ == 'updates.differenceSlice') {
|
if (differenceResult._ == 'updates.differenceSlice') {
|
||||||
getDifference();
|
getDifference();
|
||||||
@ -2726,14 +2726,14 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
clearTimeout(channelState.syncPending.timeout);
|
clearTimeout(channelState.syncPending.timeout);
|
||||||
channelState.syncPending = false;
|
channelState.syncPending = false;
|
||||||
}
|
}
|
||||||
console.log(dT(), 'Get channel diff', AppChatsManager.getChat(channelID), channelState.pts);
|
// console.log(dT(), 'Get channel diff', AppChatsManager.getChat(channelID), channelState.pts);
|
||||||
MtpApiManager.invokeApi('updates.getChannelDifference', {
|
MtpApiManager.invokeApi('updates.getChannelDifference', {
|
||||||
channel: AppChatsManager.getChannelInput(channelID),
|
channel: AppChatsManager.getChannelInput(channelID),
|
||||||
filter: {_: 'channelMessagesFilterEmpty'},
|
filter: {_: 'channelMessagesFilterEmpty'},
|
||||||
pts: channelState.pts,
|
pts: channelState.pts,
|
||||||
limit: 30
|
limit: 30
|
||||||
}).then(function (differenceResult) {
|
}).then(function (differenceResult) {
|
||||||
console.log(dT(), 'channel diff result', differenceResult);
|
// console.log(dT(), 'channel diff result', differenceResult);
|
||||||
channelState.pts = differenceResult.pts;
|
channelState.pts = differenceResult.pts;
|
||||||
|
|
||||||
if (differenceResult._ == 'updates.channelDifferenceEmpty') {
|
if (differenceResult._ == 'updates.channelDifferenceEmpty') {
|
||||||
@ -2816,16 +2816,13 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
channelID = update.channel_id;
|
channelID = update.channel_id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// if (channelID) {
|
|
||||||
// console.log(dT(), channelID, update.pts, update);
|
|
||||||
// }
|
|
||||||
if (channelID && !AppChatsManager.hasChat(channelID)) {
|
if (channelID && !AppChatsManager.hasChat(channelID)) {
|
||||||
console.log(dT(), 'skip update, missing channel', channelID, update);
|
// console.log(dT(), 'skip update, missing channel', channelID, update);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var curState = channelID ? getChannelState(channelID, update.pts) : updatesState;
|
var curState = channelID ? getChannelState(channelID, update.pts) : updatesState;
|
||||||
|
|
||||||
console.log(dT(), 'process', channelID, curState, update);
|
// console.log(dT(), 'process', channelID, curState, update);
|
||||||
|
|
||||||
if (curState.syncLoading) {
|
if (curState.syncLoading) {
|
||||||
return false;
|
return false;
|
||||||
@ -3944,14 +3941,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
PeersSelectService.selectPeer().then(function (toPeerString) {
|
PeersSelectService.selectPeer().then(function (toPeerString) {
|
||||||
var url = decodeURIComponent(matches[1]);
|
var url = decodeURIComponent(matches[1]);
|
||||||
var text = matches[2] ? decodeURIComponent(matches[2]) : '';
|
var text = matches[2] ? decodeURIComponent(matches[2]) : '';
|
||||||
$rootScope.$broadcast('history_focus', {
|
shareUrl(url, text);
|
||||||
peerString: toPeerString,
|
|
||||||
attachment: {
|
|
||||||
_: 'share_url',
|
|
||||||
url: url,
|
|
||||||
text: text
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -3987,6 +3977,57 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleActivityMessage (name, data) {
|
||||||
|
console.log(dT(), 'Received activity', name, data);
|
||||||
|
|
||||||
|
if (name == 'share' && data.url) {
|
||||||
|
shareUrl(data.url, '');
|
||||||
|
}
|
||||||
|
else if (name == 'view' && data.url) {
|
||||||
|
var matches = data.url.match(tgAddrRegExp);
|
||||||
|
if (matches) {
|
||||||
|
handleTgProtoAddr(matches[3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (name == 'webrtc-call' && data.contact) {
|
||||||
|
var contact = data.contact;
|
||||||
|
var phones = [];
|
||||||
|
if (contact.tel != undefined) {
|
||||||
|
for (var i = 0; i < contact.tel.length; i++) {
|
||||||
|
phones.push(contact.tel[i].value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var firstName = (contact.givenName || []).join(' ');
|
||||||
|
var lastName = (contact.familyName || []).join(' ');
|
||||||
|
|
||||||
|
if (phones.length) {
|
||||||
|
AppUsersManager.importContact(phones[0], firstName, lastName).then(function (foundUserID) {
|
||||||
|
if (foundUserID) {
|
||||||
|
var peerString = AppPeersManager.getPeerString(foundUserID);
|
||||||
|
$rootScope.$broadcast('history_focus', {peerString: peerString});
|
||||||
|
} else {
|
||||||
|
ErrorService.show({
|
||||||
|
error: {code: 404, type: 'USER_NOT_USING_TELEGRAM'}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (name === 'share' && data.blobs && data.blobs.length > 0) {
|
||||||
|
PeersSelectService.selectPeers({confirm_type: 'EXT_SHARE_PEER'}).then(function (peerStrings) {
|
||||||
|
angular.forEach(peerStrings, function (peerString) {
|
||||||
|
var peerID = AppPeersManager.getPeerID(peerString);
|
||||||
|
angular.forEach(data.blobs, function (blob) {
|
||||||
|
AppMessagesManager.sendFile(peerID, blob, {isMedia: true});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
if (peerStrings.length == 1) {
|
||||||
|
$rootScope.$broadcast('history_focus', {peerString: peerStrings[0]});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var started = false;
|
var started = false;
|
||||||
function start () {
|
function start () {
|
||||||
if (started) {
|
if (started) {
|
||||||
@ -4006,56 +4047,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
if (window.navigator.mozSetMessageHandler) {
|
if (window.navigator.mozSetMessageHandler) {
|
||||||
console.log(dT(), 'Set activity message handler');
|
console.log(dT(), 'Set activity message handler');
|
||||||
window.navigator.mozSetMessageHandler('activity', function(activityRequest) {
|
window.navigator.mozSetMessageHandler('activity', function(activityRequest) {
|
||||||
var source = activityRequest.source;
|
handleActivityMessage(activityRequest.source.name, activityRequest.source.data);
|
||||||
console.log(dT(), 'Received activity', source.name, source.data);
|
|
||||||
|
|
||||||
if (source.name == 'share' && source.data.url) {
|
|
||||||
var tgUrl = 'msg_url?url=' + encodeURIComponent(source.data.url);
|
|
||||||
handleTgProtoAddr(tgUrl);
|
|
||||||
}
|
|
||||||
else if (source.name == 'view' && source.data.url) {
|
|
||||||
var matches = source.data.url.match(tgAddrRegExp);
|
|
||||||
if (matches) {
|
|
||||||
handleTgProtoAddr(matches[3]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (source.name == 'webrtc-call' && source.data.contact) {
|
|
||||||
var contact = source.data.contact;
|
|
||||||
var phones = [];
|
|
||||||
if (contact.tel != undefined) {
|
|
||||||
for (var i = 0; i < contact.tel.length; i++) {
|
|
||||||
phones.push(contact.tel[i].value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var firstName = (contact.givenName || []).join(' ');
|
|
||||||
var lastName = (contact.familyName || []).join(' ');
|
|
||||||
|
|
||||||
if (phones.length) {
|
|
||||||
AppUsersManager.importContact(phones[0], firstName, lastName).then(function (foundUserID) {
|
|
||||||
if (foundUserID) {
|
|
||||||
var peerString = AppPeersManager.getPeerString(foundUserID);
|
|
||||||
$rootScope.$broadcast('history_focus', {peerString: peerString});
|
|
||||||
} else {
|
|
||||||
ErrorService.show({
|
|
||||||
error: {code: 404, type: 'USER_NOT_USING_TELEGRAM'}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (source.name === 'share' && source.data.blobs && source.data.blobs.length > 0) {
|
|
||||||
PeersSelectService.selectPeers({confirm_type: 'EXT_SHARE_PEER'}).then(function (peerStrings) {
|
|
||||||
angular.forEach(peerStrings, function (peerString) {
|
|
||||||
var peerID = AppPeersManager.getPeerID(peerString);
|
|
||||||
angular.forEach(source.data.blobs, function (blob) {
|
|
||||||
AppMessagesManager.sendFile(peerID, blob, {isMedia: true});
|
|
||||||
});
|
|
||||||
})
|
|
||||||
if (peerStrings.length == 1) {
|
|
||||||
$rootScope.$broadcast('history_focus', {peerString: peerStrings[0]});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4079,7 +4071,21 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
|
|||||||
checkLocationTgAddr();
|
checkLocationTgAddr();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function shareUrl (url, text) {
|
||||||
|
PeersSelectService.selectPeer().then(function (toPeerString) {
|
||||||
|
$rootScope.$broadcast('history_focus', {
|
||||||
|
peerString: toPeerString,
|
||||||
|
attachment: {
|
||||||
|
_: 'share_url',
|
||||||
|
url: url,
|
||||||
|
text: text
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
start: start
|
start: start,
|
||||||
|
shareUrl: shareUrl
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
@ -1764,9 +1764,10 @@ a.media_modal_date:hover {
|
|||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
.stickerset_modal_sticker_wrap,
|
.stickerset_modal_sticker_wrap,
|
||||||
.stickerset_modal_sticker_wrap img {
|
.stickerset_modal_sticker_wrap img,
|
||||||
width: 64px;
|
.stickerset_modal_sticker {
|
||||||
height: 64px;
|
width: 90px;
|
||||||
|
height: 90px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.message_actions_modal_window {
|
.message_actions_modal_window {
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
<div class="stickerset_actions_wrap">
|
<div class="stickerset_actions_wrap">
|
||||||
<div class="stickerset_actions" ng-switch="stickersetInstalled">
|
<div class="stickerset_actions" ng-switch="stickersetInstalled">
|
||||||
|
<button ng-if="stickersetLoaded" class="btn btn-md btn-md-primary pull-left" my-i18n="stickerset_modal_share" ng-click="share()"></button>
|
||||||
<button ng-switch-when="true" class="btn btn-md btn-md-danger" my-i18n="stickerset_modal_uninstall" ng-click="toggleInstalled(false)"></button>
|
<button ng-switch-when="true" class="btn btn-md btn-md-danger" my-i18n="stickerset_modal_uninstall" ng-click="toggleInstalled(false)"></button>
|
||||||
<button ng-switch-when="false" class="btn btn-md btn-md-primary" my-i18n="stickerset_modal_install" ng-click="toggleInstalled(true)"></button>
|
<button ng-switch-when="false" class="btn btn-md btn-md-primary" my-i18n="stickerset_modal_install" ng-click="toggleInstalled(true)"></button>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user