store/retrieve last used Mastodon instance to/from local storage
This commit is contained in:
parent
0d15726250
commit
2a7dc36678
1 changed files with 11 additions and 1 deletions
|
|
@ -31,16 +31,26 @@ BR.ShareRoute = L.Class.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.options.services.mastodon === true) {
|
if (this.options.services.mastodon === true) {
|
||||||
|
let storedMastodonInstance;
|
||||||
|
if (BR.Util.localStorageAvailable()) {
|
||||||
|
storedMastodonInstance = localStorage.getItem('share/mastodonInstance');
|
||||||
|
}
|
||||||
$('.share-service-mastodon')
|
$('.share-service-mastodon')
|
||||||
.removeAttr('hidden')
|
.removeAttr('hidden')
|
||||||
.on('click', function () {
|
.on('click', function () {
|
||||||
let mastodonServer = window.prompt(
|
let mastodonServer = window.prompt(
|
||||||
i18next.t('share.mastodon-enter-server-name'),
|
i18next.t('share.mastodon-enter-server-name'),
|
||||||
'mastodon.social'
|
storedMastodonInstance ?? 'mastodon.social'
|
||||||
);
|
);
|
||||||
|
|
||||||
if (mastodonServer.indexOf('http') !== 0) {
|
if (mastodonServer.indexOf('http') !== 0) {
|
||||||
mastodonServer = 'https://' + mastodonServer;
|
mastodonServer = 'https://' + mastodonServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (BR.Util.localStorageAvailable()) {
|
||||||
|
localStorage.setItem('share/mastodonInstance', new URL(mastodonServer).hostname);
|
||||||
|
}
|
||||||
|
|
||||||
window.open(mastodonServer + '/share?text=' + encodeURIComponent(self.getShareUrl()), '_blank');
|
window.open(mastodonServer + '/share?text=' + encodeURIComponent(self.getShareUrl()), '_blank');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue