Set text and URL separately for `navigator.share`

Apparently for most mobile OSses `url` is a required share option
This commit is contained in:
Andreas Nedbal 2023-10-18 20:01:59 +02:00
parent dc8c5fbf82
commit 8b86e2f123
2 changed files with 5 additions and 4 deletions

View File

@ -3,9 +3,7 @@
require "cgi"
class Ajax::AnswerController < AjaxController
include SocialHelper::TwitterMethods
include SocialHelper::TumblrMethods
include SocialHelper::TelegramMethods
include SocialHelper
def create
params.require :id
@ -73,6 +71,8 @@ class Ajax::AnswerController < AjaxController
private
def sharing_hash(answer) = {
url: answer_share_url(answer),
text: prepare_tweet(answer, nil, true),
twitter: twitter_share_url(answer),
tumblr: tumblr_share_url(answer),
telegram: telegram_share_url(answer),

View File

@ -32,7 +32,8 @@ export function answerEntryHandler(event: Event): void {
const shareButton = inboxEntry.querySelector<HTMLButtonElement>('[data-controller="share"]');
if (shareButton != null) {
shareButton.dataset.shareTextValue = decodeURIComponent(data.sharing.custom).replaceAll('+', ' ');
shareButton.dataset.shareUrlValue = data.sharing.url;
shareButton.dataset.shareTextValue = data.sharing.text;
}
const sharing = inboxEntry.querySelector<HTMLElement>('.inbox-entry__sharing');