Browse Source

Bot start, deep links

master
Igor Zhukov 10 years ago
parent
commit
bde5bc166d
  1. 64
      app/js/controllers.js
  2. 12
      app/js/services.js
  3. 7
      app/less/app.less
  4. 11
      app/less/desktop.less
  5. 17
      app/partials/desktop/im.html

64
app/js/controllers.js

@ -973,7 +973,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -973,7 +973,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
.controller('AppImHistoryController', function ($scope, $location, $timeout, $rootScope, MtpApiManager, AppUsersManager, AppChatsManager, AppMessagesManager, AppPeersManager, ApiUpdatesManager, PeersSelectService, IdleManager, StatusManager, ErrorService) {
$scope.$watch('curDialog', applyDialogSelect);
$scope.$watchCollection('curDialog', applyDialogSelect);
ApiUpdatesManager.attach();
IdleManager.start();
@ -993,6 +993,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -993,6 +993,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.selectedReply = selectedReply;
$scope.selectedCancel = selectedCancel;
$scope.selectedFlush = selectedFlush;
$scope.botStart = botStart;
$scope.toggleEdit = toggleEdit;
$scope.toggleMedia = toggleMedia;
@ -1043,8 +1044,8 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1043,8 +1044,8 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.curDialog.peerID = peerID;
$scope.curDialog.inputPeer = AppPeersManager.getInputPeer(newPeer);
$scope.historyFilter.mediaType = false;
$scope.historyState.startBot = newDialog.startParam ? 1 : false;
updateStartBot();
selectedCancel(true);
if (oldDialog.peer &&
@ -1138,6 +1139,33 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1138,6 +1139,33 @@ angular.module('myApp.controllers', ['myApp.i18n'])
}
}
function updateStartBot () {
if (!peerID ||
peerID < 0 ||
!AppUsersManager.isBot(peerID) ||
$scope.historyFilter.mediaType ||
$scope.curDialog.messageID) {
$scope.historyState.startBot = false;
}
else if (
$scope.state.empty || (
peerHistory &&
peerHistory.messages.length == 1 &&
peerHistory.messages[0].action &&
peerHistory.messages[0].action._ == 'messageActionBotIntro'
)
) {
$scope.historyState.startBot = 2;
}
else if ($scope.curDialog.startParam) {
$scope.historyState.startBot = 1;
}
else {
$scope.historyState.startBot = false;
}
$scope.$broadcast('ui_panel_update');
}
function messageFocusHistory () {
var history = historiesQueueFind(peerID);
@ -1340,29 +1368,13 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1340,29 +1368,13 @@ angular.module('myApp.controllers', ['myApp.i18n'])
AppMessagesManager.readHistory($scope.curDialog.inputPeer);
if (!$scope.curDialog.messageID &&
!inputMediaFilter &&
peerID > 0 &&
AppUsersManager.isBot(peerID) &&
(!peerHistory.ids.length || peerHistory.ids.length == 1 && peerHistory.ids[0] < 0)
) {
$scope.historyState.startBot = 2;
}
updateStartBot();
}, function () {
safeReplaceObject($scope.state, {error: true});
});
}
$scope.botStartCancel = function () {
delete $scope.curDialog.startParam;
}
$scope.botStart = function () {
AppMessagesManager.startBot(peerID, 0, $scope.curDialog.startParam);
delete $scope.curDialog.startParam;
}
function showEmptyHistory () {
jump++;
safeReplaceObject($scope.historyPeer, {});
@ -1373,6 +1385,11 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1373,6 +1385,11 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.$broadcast('ui_history_change');
}
function botStart () {
AppMessagesManager.startBot(peerID, 0, $scope.curDialog.startParam);
$scope.curDialog.startParam = false;
}
function toggleMessage (messageID, $event) {
var target = $event.target,
shiftClick = $event.shiftKey;
@ -1430,6 +1447,11 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1430,6 +1447,11 @@ angular.module('myApp.controllers', ['myApp.i18n'])
}
function selectedCancel (noBroadcast) {
if (!noBroadcast &&
$scope.curDialog.startParam) {
delete $scope.curDialog.startParam;
return;
}
$scope.selectedMsgs = {};
$scope.selectedCount = 0;
$scope.historyState.selectActions = false;
@ -1692,6 +1714,8 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1692,6 +1714,8 @@ angular.module('myApp.controllers', ['myApp.i18n'])
AppMessagesManager.readHistory($scope.curDialog.inputPeer);
});
}
updateStartBot();
}
});
@ -1721,6 +1745,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1721,6 +1745,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.$broadcast('messages_regroup');
if (historyUpdate.peerID == $scope.curDialog.peerID) {
$scope.state.empty = !newMessages.length;
updateStartBot();
}
});
@ -1731,6 +1756,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) @@ -1731,6 +1756,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
history.ids = [];
if (dialog.peerID == $scope.curDialog.peerID) {
$scope.state.empty = true;
updateStartBot();
}
}
});

12
app/js/services.js

@ -1107,7 +1107,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -1107,7 +1107,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
return AppProfileManager.getProfile(peerID).then(function (userFull) {
var description = userFull.bot_info && userFull.bot_info.description;
if (description) {
var messageID = tempID--
var messageID = tempID--;
var message = {
_: 'messageService',
id: messageID,
@ -2896,6 +2896,14 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -2896,6 +2896,14 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
}
}
historyStorage.history = newHistory;
if (updatedData.count &&
historyStorage.count !== null &&
historyStorage.count > 0) {
historyStorage.count -= updatedData.count;
if (historyStorage.count < 0) {
historyStorage.count = 0;
}
}
for (var i = 0; i < historyStorage.pending.length; i++) {
if (!updatedData.msgs[historyStorage.pending[i]]) {
@ -4293,9 +4301,11 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) @@ -4293,9 +4301,11 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
syncPending.ptsAwaiting = true;
return false;
}
if (update.pts > curState.pts) {
curState.pts = update.pts;
popPts = true;
}
}
else if (options.seq > 0) {
var seq = options.seq;
var seqStart = options.seqStart || seq;

7
app/less/app.less

@ -3046,13 +3046,6 @@ a.contacts_modal_contact:hover .md_modal_list_peer_description, @@ -3046,13 +3046,6 @@ a.contacts_modal_contact:hover .md_modal_list_peer_description,
}
}
.im_edit_panel_title {
text-align: center;
margin: 0;
font-size: 14px;
line-height: 34px;
}
.im_message_focus {
.im_message_date,
.im_message_document_size,

11
app/less/desktop.less

@ -823,7 +823,8 @@ a.footer_link.active:active { @@ -823,7 +823,8 @@ a.footer_link.active:active {
.im {
&_edit_delete_btn,
&_edit_forward_btn,
&_edit_reply_btn {
&_edit_reply_btn,
&_start_btn {
border-radius: 2px;
padding: 7px 17px;
font-weight: bold;
@ -857,6 +858,14 @@ a.footer_link.active:active { @@ -857,6 +858,14 @@ a.footer_link.active:active {
text-transform: uppercase;
}
&_edit_start_actions {
text-align: center;
text-transform: uppercase;
}
&_start_btn {
padding: 7px 25px;
}
&_selected_count {
color: #b9cfe3;
}

17
app/partials/desktop/im.html

@ -140,10 +140,13 @@ @@ -140,10 +140,13 @@
<div class="im_bottom_panel_wrap">
<div class="im_edit_panel_wrap clearfix" ng-show="historyState.selectActions &amp;&amp; !historyState.startBot">
<div class="im_edit_panel_wrap clearfix" ng-show="historyState.selectActions || historyState.startBot" ng-switch="historyState.startBot != false">
<div class="im_edit_panel_border"></div>
<a class="btn btn-md btn-md-primary im_edit_cancel_link" ng-click="selectedCancel()" my-i18n="modal_cancel"></a>
<div class="im_edit_selected_actions" my-i18n>
<a ng-show="historyState.startBot != 2" class="btn btn-md btn-md-primary im_edit_cancel_link" ng-click="selectedCancel()" my-i18n="modal_cancel"></a>
<div class="im_edit_start_actions" ng-switch-when="true">
<a class="btn btn-primary im_start_btn" ng-click="botStart()" my-i18n="im_start"></a>
</div>
<div class="im_edit_selected_actions" ng-switch-default my-i18n>
<a class="btn btn-primary im_edit_forward_btn" ng-click="selectedForward()" ng-class="{disabled: !selectedCount}" ng-disabled="!selectedCount" my-i18n-format="im_forward"></a>
<a class="btn btn-primary im_edit_delete_btn" ng-click="selectedDelete()" ng-class="{disabled: !selectedCount}" ng-disabled="!selectedCount" my-i18n-format="im_delete"></a>
<a class="btn btn-primary im_edit_reply_btn" ng-click="selectedReply()" ng-show="selectedCount == 1"my-i18n="im_reply"></a>
@ -151,14 +154,6 @@ @@ -151,14 +154,6 @@
</div>
</div>
<div class="im_start_panel_wrap clearfix" ng-show="historyState.startBot">
<div class="im_edit_panel_border"></div>
<a ng-show="historyState.startBot == 1" class="btn btn-md btn-md-primary im_edit_cancel_link" ng-click="botStartCancel()" my-i18n="modal_cancel"></a>
<div class="im_edit_selected_actions" my-i18n>
<a class="btn btn-primary im_start_btn" ng-click="botStart()" my-i18n-format="im_start"></a>
</div>
</div>
<div class="im_send_panel_wrap" ng-show="!historyState.selectActions &amp;&amp; !historyState.startBot">
<div class="im_send_form_wrap1">

Loading…
Cancel
Save