Still got to make sure instance is lowercase

Also, spellcheck={false} > spellcheck="false"
This commit is contained in:
Lim Chee Aun 2023-02-22 09:46:50 +08:00
parent c95aeaee01
commit 2120a1e28e
4 changed files with 14 additions and 4 deletions

View file

@ -368,6 +368,9 @@ function ShortcutForm({ type, lists, followedHashtags, onSubmit, disabled }) {
? 'followed-hashtags-datalist' ? 'followed-hashtags-datalist'
: null : null
} }
autocorrect="off"
autocapitalize="off"
spellcheck={false}
/> />
{currentType === 'hashtag' && followedHashtags.length > 0 && ( {currentType === 'hashtag' && followedHashtags.length > 0 && (
<datalist id="followed-hashtags-datalist"> <datalist id="followed-hashtags-datalist">

View file

@ -88,7 +88,7 @@ function Login() {
autocorrect="off" autocorrect="off"
autocapitalize="off" autocapitalize="off"
autocomplete="off" autocomplete="off"
spellcheck="false" spellcheck={false}
/> />
<datalist id="instances-list"> <datalist id="instances-list">
{instancesList.map((instance) => ( {instancesList.map((instance) => (

View file

@ -79,7 +79,7 @@ function Public({ local, ...props }) {
type="button" type="button"
class="plain" class="plain"
onClick={() => { onClick={() => {
const newInstance = prompt( let newInstance = prompt(
'Enter a new instance e.g. "mastodon.social"', 'Enter a new instance e.g. "mastodon.social"',
); );
if (!/\./.test(newInstance)) { if (!/\./.test(newInstance)) {
@ -87,6 +87,7 @@ function Public({ local, ...props }) {
return; return;
} }
if (newInstance) { if (newInstance) {
newInstance = newInstance.toLowerCase().trim();
navigate(isLocal ? `/${newInstance}/p/l` : `/${newInstance}/p`); navigate(isLocal ? `/${newInstance}/p/l` : `/${newInstance}/p`);
} }
}} }}

View file

@ -115,6 +115,11 @@ export async function initPreferences(client) {
// Get the masto instance // Get the masto instance
// If accountID is provided, get the masto instance for that account // If accountID is provided, get the masto instance for that account
export function api({ instance, accessToken, accountID, account } = {}) { export function api({ instance, accessToken, accountID, account } = {}) {
// Always lowercase and trim the instance
if (instance) {
instance = instance.toLowerCase().trim();
}
// If instance and accessToken are provided, get the masto instance for that account // If instance and accessToken are provided, get the masto instance for that account
if (instance && accessToken) { if (instance && accessToken) {
return { return {
@ -131,7 +136,7 @@ export function api({ instance, accessToken, accountID, account } = {}) {
account = account || getAccount(accountID); account = account || getAccount(accountID);
if (account) { if (account) {
const accessToken = account.accessToken; const accessToken = account.accessToken;
const instance = account.instanceURL; const instance = account.instanceURL.toLowerCase().trim();
return { return {
masto: masto:
accountApis[instance]?.[accessToken] || accountApis[instance]?.[accessToken] ||
@ -155,12 +160,13 @@ export function api({ instance, accessToken, accountID, account } = {}) {
} }
// If no instance is provided, get the masto instance for the current account // If no instance is provided, get the masto instance for the current account
if (currentAccountApi) if (currentAccountApi) {
return { return {
masto: currentAccountApi, masto: currentAccountApi,
authenticated: true, authenticated: true,
instance: currentAccountApi.__instance__, instance: currentAccountApi.__instance__,
}; };
}
const currentAccount = getCurrentAccount(); const currentAccount = getCurrentAccount();
if (currentAccount) { if (currentAccount) {
const { accessToken, instanceURL: instance } = currentAccount; const { accessToken, instanceURL: instance } = currentAccount;