mirror of
https://github.com/status-im/universal-links-handler.git
synced 2025-02-23 16:18:09 +00:00
make button show 'Open in Status' on Android
And use the status-im:// URL scheme for the button. Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
d94bfc7a4b
commit
d689e123dd
@ -39,13 +39,19 @@ router.get('/.well-known/apple-app-site-association', function(req, res) {
|
|||||||
|
|
||||||
router.get('/chat/:chatType/:chatId', function(req, res, next) {
|
router.get('/chat/:chatType/:chatId', function(req, res, next) {
|
||||||
const { chatId, chatType } = req.params;
|
const { chatId, chatType } = req.params;
|
||||||
|
/* Make button open chat if on Android */
|
||||||
|
let buttonTitle = 'Download Status'
|
||||||
|
let buttonUrl = 'https://status.im/get/'
|
||||||
|
if (utils.isAndroid(req.headers['user-agent'])) {
|
||||||
|
buttonTitle = 'Open in Status'
|
||||||
|
buttonUrl = `status-im://chat/${chatType}/${chatId}`
|
||||||
|
}
|
||||||
chatName = `#${chatId}`;
|
chatName = `#${chatId}`;
|
||||||
const options = {
|
const options = {
|
||||||
title: `Join ${chatType} channel #${chatId} on Status`,
|
title: `Join ${chatType} channel #${chatId} on Status`,
|
||||||
info: `Join public channel <span>#${chatId}</span> on Status.`,
|
info: `Join public channel <span>#${chatId}</span> on Status.`,
|
||||||
path: req.originalUrl,
|
path: req.originalUrl,
|
||||||
chatId: chatId,
|
chatId, chatName, buttonTitle, buttonUrl
|
||||||
chatName: chatName,
|
|
||||||
};
|
};
|
||||||
utils.makeQrCodeDataUri(chatName).then(
|
utils.makeQrCodeDataUri(chatName).then(
|
||||||
qrCodeDataUri => res.render('index', { ...options, qrCodeDataUri }),
|
qrCodeDataUri => res.render('index', { ...options, qrCodeDataUri }),
|
||||||
@ -55,8 +61,15 @@ router.get('/chat/:chatType/:chatId', function(req, res, next) {
|
|||||||
|
|
||||||
router.get('/user/:userId', function(req, res, next) {
|
router.get('/user/:userId', function(req, res, next) {
|
||||||
const { userId } = req.params;
|
const { userId } = req.params;
|
||||||
chatName = userId
|
/* Make button open user profile if on Android */
|
||||||
|
let buttonTitle = 'Download Status'
|
||||||
|
let buttonUrl = 'https://status.im/get/'
|
||||||
|
if (utils.isAndroid(req.headers['user-agent'])) {
|
||||||
|
buttonTitle = 'Open in Status'
|
||||||
|
buttonUrl = `status-im://user/${userId}`
|
||||||
|
}
|
||||||
/* chat keys can be resolved to chat names */
|
/* chat keys can be resolved to chat names */
|
||||||
|
chatName = userId
|
||||||
if (utils.isChatKey(userId)) {
|
if (utils.isChatKey(userId)) {
|
||||||
chatName = StatusIm.chatKeyToChatName(userId)
|
chatName = StatusIm.chatKeyToChatName(userId)
|
||||||
}
|
}
|
||||||
@ -65,7 +78,7 @@ router.get('/user/:userId', function(req, res, next) {
|
|||||||
info: `Chat and transact with <span>${userId}</span> in Status.`,
|
info: `Chat and transact with <span>${userId}</span> in Status.`,
|
||||||
path: req.originalUrl,
|
path: req.originalUrl,
|
||||||
chatId: userId,
|
chatId: userId,
|
||||||
chatName: chatName,
|
chatName, buttonTitle, buttonUrl
|
||||||
};
|
};
|
||||||
utils.makeQrCodeDataUri(userId).then(
|
utils.makeQrCodeDataUri(userId).then(
|
||||||
qrCodeDataUri => res.render('index', { ...options, qrCodeDataUri }),
|
qrCodeDataUri => res.render('index', { ...options, qrCodeDataUri }),
|
||||||
@ -81,6 +94,8 @@ router.get('/extension/:extensionEndpoint', function(req, res, next) {
|
|||||||
path: req.originalUrl,
|
path: req.originalUrl,
|
||||||
chatId: extensionEndpoint,
|
chatId: extensionEndpoint,
|
||||||
chatName: extensionEndpoint,
|
chatName: extensionEndpoint,
|
||||||
|
buttonTitle: 'Download Status',
|
||||||
|
buttonUrl: 'https://status.im/get/',
|
||||||
};
|
};
|
||||||
utils.makeQrCodeDataUri('https://join.status.im/extension/' + extensionEndpoint).then(
|
utils.makeQrCodeDataUri('https://join.status.im/extension/' + extensionEndpoint).then(
|
||||||
qrCodeDataUri => res.render('index', { ...options, qrCodeDataUri }),
|
qrCodeDataUri => res.render('index', { ...options, qrCodeDataUri }),
|
||||||
|
@ -173,7 +173,7 @@
|
|||||||
<div class="inner" id="copy-target"><%= chatId %></div>
|
<div class="inner" id="copy-target"><%= chatId %></div>
|
||||||
<a href="#" data-clipboard-target="#copy-target">Copy</a>
|
<a href="#" data-clipboard-target="#copy-target">Copy</a>
|
||||||
</div>
|
</div>
|
||||||
<a href="https://status.im/get/" class="btn btn-purple-fill">Download Status</a>
|
<a href="<%= buttonUrl %>" class="btn btn-purple-fill"><%= buttonTitle %></a>
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<%- info %>
|
<%- info %>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user