mirror of
https://iceshrimp.dev/Crimekillz/jointrashposs.git
synced 2024-11-25 02:09:05 +01:00
1f2b1aa58b
* wip * (add) mfm preview * (fix) iroiro * (Fix) build error * (fix) something
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
import * as Misskey from 'misskey-js';
|
|
|
|
export const getIOMeta = async (): Promise<Misskey.entities.LiteInstanceMetadata> => {
|
|
if (!process.client) {
|
|
return {};
|
|
}
|
|
if (!sessionStorage.getItem('miHub_io_meta')) {
|
|
const meta = await fetch('https://misskey.io/api/meta');
|
|
|
|
const metaText = await meta.text();
|
|
sessionStorage.setItem('miHub_io_meta', metaText);
|
|
|
|
return JSON.parse(metaText);
|
|
} else {
|
|
return JSON.parse(sessionStorage.getItem('miHub_io_meta') ?? '');
|
|
}
|
|
}
|
|
|
|
export const getIOEmoji = async (): Promise<{ emojis: Misskey.entities.CustomEmoji[] }> => {
|
|
if (!process.client) {
|
|
return { emojis: [] };
|
|
}
|
|
if (!localStorage.getItem('miHub_io_emoji')) {
|
|
const emoji = await fetch('https://misskey.io/api/emojis');
|
|
|
|
const emojiText = await emoji.text();
|
|
localStorage.setItem('miHub_io_emoji', emojiText);
|
|
|
|
return JSON.parse(emojiText);
|
|
} else {
|
|
return JSON.parse(localStorage.getItem('miHub_io_emoji') ?? '');
|
|
}
|
|
} |