jormungandr-bite/packages/client/src/scripts/lookup-instance.ts

26 lines
541 B
TypeScript
Raw Normal View History

2023-04-11 11:03:25 -06:00
import { i18n } from "@/i18n";
import * as os from "@/os";
export async function lookupInstance() {
const { canceled, result: q } = await os.inputText({
title: i18n.ts.instance,
});
if (canceled) return;
os.api(
"federation/show-instance",
2023-04-12 18:19:14 -06:00
q.startsWith("http://") || q.startsWith("https://")
? { host: q.replace("https://", "") }
: { host: q },
2023-04-11 11:03:25 -06:00
)
.then((instance) => {
os.pageWindow(`/instance-info/${instance.host}`);
})
.catch(() => {
os.alert({
type: "error",
text: i18n.ts.notFound,
});
});
}