Run `prettier --write` on remaining pack files to reduce further diff

This commit is contained in:
Renaud Chaput 2024-03-03 22:51:15 +01:00
parent 07e36555ad
commit 3aeb630949
No known key found for this signature in database
GPG Key ID: BCFC859D49B46990
3 changed files with 94 additions and 59 deletions

View File

@ -2,7 +2,7 @@ import './public-path';
import { createRoot } from 'react-dom/client';
import { start } from '../mastodon/common';
import ComposeContainer from '../mastodon/containers/compose_container';
import ComposeContainer from '../mastodon/containers/compose_container';
import { loadPolyfills } from '../mastodon/polyfills';
import ready from '../mastodon/ready';
@ -27,6 +27,8 @@ function main() {
ready(loaded);
}
loadPolyfills().then(main).catch(error => {
console.error(error);
});
loadPolyfills()
.then(main)
.catch((error) => {
console.error(error);
});

View File

@ -5,16 +5,19 @@ import ready from '../mastodon/ready';
ready(() => {
setInterval(() => {
axios.get('/api/v1/emails/check_confirmation').then((response) => {
if (response.data) {
window.location = '/start';
}
}).catch(error => {
console.error(error);
});
axios
.get('/api/v1/emails/check_confirmation')
.then((response) => {
if (response.data) {
window.location = '/start';
}
})
.catch((error) => {
console.error(error);
});
}, 5000);
document.querySelectorAll('.timer-button').forEach(button => {
document.querySelectorAll('.timer-button').forEach((button) => {
let counter = 30;
const container = document.createElement('span');

View File

@ -14,62 +14,83 @@ function getCSRFToken() {
}
function hideFlashMessages() {
Array.from(document.getElementsByClassName('flash-message')).forEach(function(flashMessage) {
flashMessage.classList.add('hidden');
});
Array.from(document.getElementsByClassName('flash-message')).forEach(
function (flashMessage) {
flashMessage.classList.add('hidden');
},
);
}
function callback(url, body) {
axios.post(url, JSON.stringify(body), {
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-CSRF-Token': getCSRFToken(),
},
credentials: 'same-origin',
}).then(function(response) {
window.location.replace(response.data.redirect_path);
}).catch(function(error) {
if (error.response.status === 422) {
const errorMessage = document.getElementById('security-key-error-message');
errorMessage.classList.remove('hidden');
console.error(error.response.data.error);
} else {
console.error(error);
}
});
axios
.post(url, JSON.stringify(body), {
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
'X-CSRF-Token': getCSRFToken(),
},
credentials: 'same-origin',
})
.then(function (response) {
window.location.replace(response.data.redirect_path);
})
.catch(function (error) {
if (error.response.status === 422) {
const errorMessage = document.getElementById(
'security-key-error-message',
);
errorMessage.classList.remove('hidden');
console.error(error.response.data.error);
} else {
console.error(error);
}
});
}
ready(() => {
if (!WebAuthnJSON.supported()) {
const unsupported_browser_message = document.getElementById('unsupported-browser-message');
const unsupported_browser_message = document.getElementById(
'unsupported-browser-message',
);
if (unsupported_browser_message) {
unsupported_browser_message.classList.remove('hidden');
document.querySelector('.btn.js-webauthn').disabled = true;
}
}
const webAuthnCredentialRegistrationForm = document.getElementById('new_webauthn_credential');
const webAuthnCredentialRegistrationForm = document.getElementById(
'new_webauthn_credential',
);
if (webAuthnCredentialRegistrationForm) {
webAuthnCredentialRegistrationForm.addEventListener('submit', (event) => {
event.preventDefault();
var nickname = event.target.querySelector('input[name="new_webauthn_credential[nickname]"]');
var nickname = event.target.querySelector(
'input[name="new_webauthn_credential[nickname]"]',
);
if (nickname.value) {
axios.get('/settings/security_keys/options')
axios
.get('/settings/security_keys/options')
.then((response) => {
const credentialOptions = response.data;
WebAuthnJSON.create({ 'publicKey': credentialOptions }).then((credential) => {
var params = { 'credential': credential, 'nickname': nickname.value };
callback('/settings/security_keys', params);
}).catch((error) => {
const errorMessage = document.getElementById('security-key-error-message');
errorMessage.classList.remove('hidden');
console.error(error);
});
}).catch((error) => {
WebAuthnJSON.create({ publicKey: credentialOptions })
.then((credential) => {
var params = {
credential: credential,
nickname: nickname.value,
};
callback('/settings/security_keys', params);
})
.catch((error) => {
const errorMessage = document.getElementById(
'security-key-error-message',
);
errorMessage.classList.remove('hidden');
console.error(error);
});
})
.catch((error) => {
console.error(error.response.data.error);
});
} else {
@ -78,29 +99,38 @@ ready(() => {
});
}
const webAuthnCredentialAuthenticationForm = document.getElementById('webauthn-form');
const webAuthnCredentialAuthenticationForm =
document.getElementById('webauthn-form');
if (webAuthnCredentialAuthenticationForm) {
webAuthnCredentialAuthenticationForm.addEventListener('submit', (event) => {
event.preventDefault();
axios.get('sessions/security_key_options')
axios
.get('sessions/security_key_options')
.then((response) => {
const credentialOptions = response.data;
WebAuthnJSON.get({ 'publicKey': credentialOptions }).then((credential) => {
var params = { 'user': { 'credential': credential } };
callback('sign_in', params);
}).catch((error) => {
const errorMessage = document.getElementById('security-key-error-message');
errorMessage.classList.remove('hidden');
console.error(error);
});
}).catch((error) => {
WebAuthnJSON.get({ publicKey: credentialOptions })
.then((credential) => {
var params = { user: { credential: credential } };
callback('sign_in', params);
})
.catch((error) => {
const errorMessage = document.getElementById(
'security-key-error-message',
);
errorMessage.classList.remove('hidden');
console.error(error);
});
})
.catch((error) => {
console.error(error.response.data.error);
});
});
const otpAuthenticationForm = document.getElementById('otp-authentication-form');
const otpAuthenticationForm = document.getElementById(
'otp-authentication-form',
);
const linkToOtp = document.getElementById('link-to-otp');
linkToOtp.addEventListener('click', () => {