Skip to content
This repository was archived by the owner on Oct 25, 2023. It is now read-only.

Commit b110849

Browse files
committed
Added toaster for callback answers
1 parent e63fb55 commit b110849

11 files changed

Lines changed: 825 additions & 18 deletions

File tree

‎app/index.html‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<!-- build:css css/app.css -->
1212
<link rel="stylesheet" href="vendor/angular/angular-csp.css"/>
1313
<link rel="stylesheet" href="vendor/bootstrap/css/bootstrap.css"/>
14+
<link rel="stylesheet" href="vendor/angularjs-toaster/toaster.css"/>
1415
<link rel="stylesheet" href="css/app.css"/>
1516
<!-- endbuild -->
1617

@@ -65,6 +66,7 @@
6566
<script type="text/javascript" src="vendor/closure/long.js"></script>
6667
<script type="text/javascript" src="vendor/leemon_bigint/bigint.js"></script>
6768
<script type="text/javascript" src="vendor/libwebpjs/libwebp-0.2.0.js"></script>
69+
<script type="text/javascript" src="vendor/angularjs-toaster/toaster.js"></script>
6870

6971

7072
<script type="text/javascript" src="js/lib/utils.js"></script>

‎app/js/app.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ angular.module('myApp', [
2020
'ngTouch',
2121
'ui.bootstrap',
2222
'mediaPlayer',
23+
'toaster',
2324
'izhukov.utils',
2425
'izhukov.mtproto',
2526
'izhukov.mtproto.wrapper',

‎app/js/controllers.js‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,6 +1804,9 @@ angular.module('myApp.controllers', ['myApp.i18n'])
18041804
if (!replyKeyboard) {
18051805
return;
18061806
}
1807+
var sendOptions = {
1808+
replyToMsgID: peerID < 0 && replyKeyboard.mid
1809+
};
18071810
switch (button._) {
18081811
case 'keyboardButtonRequestPhone':
18091812
ErrorService.confirm({type: 'BOT_ACCESS_PHONE'}).then(function () {
@@ -1813,9 +1816,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
18131816
phone_number: user.phone,
18141817
first_name: user.first_name,
18151818
last_name: user.last_name
1816-
}, {
1817-
replyToMsgID: peerID < 0 && replyKeyboard.mid
1818-
});
1819+
}, sendOptions);
18191820
});
18201821
break;
18211822

@@ -1829,22 +1830,18 @@ angular.module('myApp.controllers', ['myApp.i18n'])
18291830
'lat': coords['lat'],
18301831
'long': coords['long']
18311832
}
1832-
}, {
1833-
replyToMsgID: peerID < 0 && replyKeyboard.mid
1834-
});
1833+
}, sendOptions);
18351834
}, function (error) {
18361835
ErrorService.alert(
1837-
_('error_modal_password_success_title_raw'),
1838-
_('error_modal_password_success_descripion_raw')
1836+
_('error_modal_bad_request_title_raw'),
1837+
_('error_modal_gelocation_na_raw')
18391838
);
18401839
});
18411840
});
18421841
break;
18431842

18441843
default:
1845-
AppMessagesManager.sendText(peerID, button.text, {
1846-
replyToMsgID: peerID < 0 && replyKeyboard.mid
1847-
});
1844+
AppMessagesManager.sendText(peerID, button.text, sendOptions);
18481845
}
18491846
});
18501847

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,9 @@
235235
"confirm_modal_delete_group_md": "Are you sure you want to delete this group?\n\nAll members will be removed and all messages will be lost.",
236236
"confirm_modal_jump_ext_url_md": "Open this link?\n\n{url}",
237237
"confirm_modal_migrate_supergroup_md": "Please note that group members will need to update their Telegram apps to the latest version to see your supergroup.\n\nAre you sure you want to upgrade this group?",
238-
"confirm_modal_bot_access_phone": "Do you want?",
239-
"confirm_modal_bot_access_geo": "Do you want?",
240-
"confirm_modal_bot_access_geo_inline": "Do you want?",
238+
"confirm_modal_bot_access_phone": "The bot will know your phone number. This can be useful for integration with other services.",
239+
"confirm_modal_bot_access_geo": "This will send your current location to the bot.",
240+
"confirm_modal_bot_access_geo_inline": "This bot would like to know your location each time you send it a request. This can be used to provide location-specific results.",
241241

242242
"confirm_modal_are_u_sure": "Are you sure?",
243243

@@ -392,6 +392,7 @@
392392
"error_modal_invite_link_invalid": "The invite link is invalid",
393393
"error_modal_channel_not_accessible": "Sorry, this channel is not accessible.",
394394
"error_modal_not_contact_flood": "Sorry, you can only send messages to mutual contacts at the moment. {more-info-link: More info »}",
395+
"error_modal_gelocation_na": "App was unable to determine your current location",
395396

396397

397398
"head_telegram": "Telegram",

‎app/js/services.js‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2383,7 +2383,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
23832383
}
23842384
})
23852385

2386-
.service('AppInlineBotsManager', function (qSync, $q, $rootScope, Storage, ErrorService, MtpApiManager, AppMessagesManager, AppDocsManager, AppPhotosManager, RichTextProcessor, AppUsersManager, AppPeersManager, PeersSelectService, GeoLocationManager) {
2386+
.service('AppInlineBotsManager', function (qSync, $q, $rootScope, toaster, Storage, ErrorService, MtpApiManager, AppMessagesManager, AppDocsManager, AppPhotosManager, RichTextProcessor, AppUsersManager, AppPeersManager, PeersSelectService, GeoLocationManager) {
23872387

23882388
var inlineResults = {};
23892389

@@ -2460,7 +2460,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
24602460
id: peerID,
24612461
placeholder: bot.bot_inline_placeholder
24622462
};
2463-
if (bot.pFlags.bot_inline_geo) {
2463+
if (bot.pFlags.bot_inline_geo &&
2464+
GeoLocationManager.isAvailable()) {
24642465
return checkGeoLocationAccess(peerID).then(function () {
24652466
return GeoLocationManager.getPosition().then(function (coords) {
24662467
resolvedBot.geo = coords;
@@ -2656,7 +2657,22 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
26562657
msg_id: AppMessagesManager.getMessageLocalID(id),
26572658
data: button.data
26582659
}).then(function (callbackAnswer) {
2659-
console.info(callbackAnswer.message || 'empty answer');
2660+
if (typeof callbackAnswer.message != 'string' ||
2661+
!callbackAnswer.message.length) {
2662+
return;
2663+
}
2664+
if (callbackAnswer.pFlags.alert) {
2665+
ErrorService.alert(callbackAnswer.message);
2666+
} else {
2667+
var html = RichTextProcessor.wrapRichText(callbackAnswer.message, {noLinks: true, noLinebreaks: true}).valueOf();;
2668+
toaster.pop({
2669+
type: 'material',
2670+
timeout: 100000,
2671+
body: html,
2672+
bodyOutputType: 'trustedHtml',
2673+
showCloseButton: false
2674+
});
2675+
}
26602676
});
26612677
}
26622678

‎app/partials/desktop/im.html‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,3 +247,5 @@ <h3 class="im_dialogs_empty_header" my-i18n="im_get_started"></h3>
247247
</div>
248248

249249
<div class="footer_wrap footer_empty"></div>
250+
251+
<toaster-container toaster-options="{'position-class': 'toast-bottom-center'}"></toaster-container>

‎app/partials/mobile/im.html‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,6 @@ <h5 my-i18n="im_messages"></h5>
192192

193193
</div>
194194

195-
</div>
195+
</div>
196+
197+
<toaster-container></toaster-container>

0 commit comments

Comments
 (0)