Browse Source

Start button draft

master
Igor Zhukov 9 years ago
parent
commit
a25619bf19
  1. 69
      app/js/controllers.js
  2. 1
      app/js/locales/en-us.json
  3. 12
      app/partials/desktop/im.html

69
app/js/controllers.js

@ -407,9 +407,12 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.$on('$routeUpdate', updateCurDialog); $scope.$on('$routeUpdate', updateCurDialog);
var pendingParams = false;
$scope.$on('history_focus', function (e, peerData) { $scope.$on('history_focus', function (e, peerData) {
$modalStack.dismissAll(); $modalStack.dismissAll();
if (peerData.peerString == $scope.curDialog.peer && peerData.messageID == $scope.curDialog.messageID) { if (peerData.peerString == $scope.curDialog.peer &&
peerData.messageID == $scope.curDialog.messageID &&
!peerData.startParam) {
$scope.$broadcast(peerData.messageID ? 'ui_history_change_scroll' : 'ui_history_focus'); $scope.$broadcast(peerData.messageID ? 'ui_history_change_scroll' : 'ui_history_focus');
} else { } else {
var peerID = AppPeersManager.getPeerID(peerData.peerString); var peerID = AppPeersManager.getPeerID(peerData.peerString);
@ -420,7 +423,19 @@ angular.module('myApp.controllers', ['myApp.i18n'])
peer = '@' + username; peer = '@' + username;
} }
} }
$location.url('/im?p=' + peer + (peerData.messageID ? '&m=' + peerData.messageID : '')); if (peerData.messageID || peerData.startParam) {
pendingParams = {
messageID: peerData.messageID,
startParam: peerData.startParam
};
} else {
pendingParams = false;
}
if ($routeParams.p != peer) {
$location.url('/im?p=' + peer);
} else {
updateCurDialog();
}
} }
}); });
@ -568,21 +583,24 @@ angular.module('myApp.controllers', ['myApp.i18n'])
} else { } else {
lastSearch = false; lastSearch = false;
} }
var addParams = pendingParams || {};
pendingParams = false;
addParams.messageID = parseInt(addParams.messageID) || false;
addParams.startParam = addParams.startParam || false;
if ($routeParams.p && $routeParams.p.charAt(0) == '@') { if ($routeParams.p && $routeParams.p.charAt(0) == '@') {
if ($scope.curDialog === undefined) { if ($scope.curDialog === undefined) {
$scope.curDialog = {}; $scope.curDialog = {};
} }
AppUsersManager.resolveUsername($routeParams.p.substr(1)).then(function (userID) { AppUsersManager.resolveUsername($routeParams.p.substr(1)).then(function (userID) {
$scope.curDialog = { $scope.curDialog = angular.extend({
peer: AppUsersManager.getUserString(userID), peer: AppUsersManager.getUserString(userID)
messageID: parseInt($routeParams.m) || false }, addParams);
};
}); });
} else { } else {
$scope.curDialog = { $scope.curDialog = angular.extend({
peer: $routeParams.p || false, peer: $routeParams.p || false
messageID: parseInt($routeParams.m) || false }, addParams);
};
} }
} }
@ -740,8 +758,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$location.url( $location.url(
'/im' + '/im' +
($scope.curDialog.peer ($scope.curDialog.peer
? '?p=' + $scope.curDialog.peer + ? '?p=' + $scope.curDialog.peer
($scope.curDialog.messageID ? '&m=' + $scope.curDialog.messageID : '')
: '' : ''
) )
); );
@ -1016,8 +1033,9 @@ angular.module('myApp.controllers', ['myApp.i18n'])
var newPeer = newDialog.peer || $scope.curDialog.peer || ''; var newPeer = newDialog.peer || $scope.curDialog.peer || '';
peerID = AppPeersManager.getPeerID(newPeer); peerID = AppPeersManager.getPeerID(newPeer);
if (peerID == $scope.curDialog.peerID &&
if (peerID == $scope.curDialog.peerID && oldDialog.messageID == newDialog.messageID) { oldDialog.messageID == newDialog.messageID &&
oldDialog.startParam == newDialog.startParam) {
return false; return false;
} }
@ -1025,10 +1043,13 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.curDialog.peerID = peerID; $scope.curDialog.peerID = peerID;
$scope.curDialog.inputPeer = AppPeersManager.getInputPeer(newPeer); $scope.curDialog.inputPeer = AppPeersManager.getInputPeer(newPeer);
$scope.historyFilter.mediaType = false; $scope.historyFilter.mediaType = false;
$scope.historyState.startBot = newDialog.startParam ? 1 : false;
selectedCancel(true); selectedCancel(true);
if (oldDialog.peer && oldDialog.peer == newDialog.peer && newDialog.messageID) { if (oldDialog.peer &&
oldDialog.peer == newDialog.peer &&
newDialog.messageID) {
messageFocusHistory(); messageFocusHistory();
} }
else if (peerID) { else if (peerID) {
@ -1319,11 +1340,29 @@ angular.module('myApp.controllers', ['myApp.i18n'])
AppMessagesManager.readHistory($scope.curDialog.inputPeer); 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;
}
}, function () { }, function () {
safeReplaceObject($scope.state, {error: true}); 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 () { function showEmptyHistory () {
jump++; jump++;
safeReplaceObject($scope.historyPeer, {}); safeReplaceObject($scope.historyPeer, {});

1
app/js/locales/en-us.json

@ -398,6 +398,7 @@
"im_delete": "Delete {count}", "im_delete": "Delete {count}",
"im_forward": "Forward {count}", "im_forward": "Forward {count}",
"im_reply": "Reply", "im_reply": "Reply",
"im_start": "Start",
"im_reply_loading": "Loading{dots}", "im_reply_loading": "Loading{dots}",
"im_photos_drop_text": "Drop photos here to send", "im_photos_drop_text": "Drop photos here to send",
"im_message_field_placeholder": "Write a message...", "im_message_field_placeholder": "Write a message...",

12
app/partials/desktop/im.html

@ -140,7 +140,7 @@
<div class="im_bottom_panel_wrap"> <div class="im_bottom_panel_wrap">
<div class="im_edit_panel_wrap clearfix" ng-show="historyState.selectActions"> <div class="im_edit_panel_wrap clearfix" ng-show="historyState.selectActions &amp;&amp; !historyState.startBot">
<div class="im_edit_panel_border"></div> <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> <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> <div class="im_edit_selected_actions" my-i18n>
@ -151,7 +151,15 @@
</div> </div>
</div> </div>
<div class="im_send_panel_wrap" ng-hide="historyState.selectActions"> <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"> <div class="im_send_form_wrap1">

Loading…
Cancel
Save