Resolve account URLs too

This commit is contained in:
Lim Chee Aun 2024-01-06 01:03:30 +08:00
parent be5fcc35ac
commit e43f2283dd

View file

@ -37,16 +37,20 @@ export default function HttpRoute() {
const { masto: currentMasto, instance: currentInstance } = api();
const result = await currentMasto.v2.search.fetch({
q: url,
type: 'statuses',
limit: 1,
resolve: true,
});
if (result.statuses.length) {
const status = result.statuses[0];
window.location.hash = `/${currentInstance}/s/${status.id}?view=full`;
} else {
} else if (result.accounts.length) {
const account = result.accounts[0];
window.location.hash = `/${currentInstance}/a/${account.id}`;
} else if (statusURL) {
// Fallback to original URL, which will probably show error
window.location.hash = statusURL + '?view=full';
} else {
setUIState('error');
}
}
})();