Skip to content

Commit

Permalink
chore: Try using v2 instance endpoint
Browse files Browse the repository at this point in the history
Since v1 is deprecated for Mastodon
  • Loading branch information
null2264 committed Nov 1, 2023
1 parent 2e181e8 commit 440d8c5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
# Changelog

<!--
If the update is small (max 5 points):
## 20xx.xx.x
- Type: changes
Else:
## 20xx.xx.x
### Added
### Changed
- Type: changes
### Fixed
### Removed
-->

## 2023.11.0 (Unreleased)

### Added
- Mastodon: support `/api/v2/instance`

### Changed
- Timeline: re-design ScrollTopButton
- Mastodon: support `/api/v2/instance`
- Backend: try to use v2 instance instead of v1 when possible

### Fixed
- Search: disable domain button for autosuggest results
Expand Down
9 changes: 8 additions & 1 deletion src/soapbox/actions/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ export const fetchInstance = createAsyncThunk<void, void, { state: RootState }>(
'instance/fetch',
async(_arg, { dispatch, getState, rejectWithValue }) => {
try {
const { data: instance } = await api(getState).get('/api/v1/instance');
let resp: any;
try {
resp = await api(getState).get('/api/v2/instance');
} catch (e) {
resp = await api(getState).get('/api/v1/instance');
}

const { data: instance } = resp;
if (needsNodeinfo(instance)) {
dispatch(fetchNodeinfo());
}
Expand Down

0 comments on commit 440d8c5

Please sign in to comment.