mirror of
https://github.com/yingziwu/mastodon.git
synced 2026-02-04 03:25:14 +00:00
Fix error handling when re-fetching already-known statuses (#37077)
This commit is contained in:
parent
1ef4bbd88d
commit
b0c141e658
2 changed files with 8 additions and 3 deletions
|
|
@ -85,6 +85,8 @@ export function fetchStatus(id, {
|
||||||
dispatch(fetchStatusSuccess(skipLoading));
|
dispatch(fetchStatusSuccess(skipLoading));
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
dispatch(fetchStatusFail(id, error, skipLoading, parentQuotePostId));
|
dispatch(fetchStatusFail(id, error, skipLoading, parentQuotePostId));
|
||||||
|
if (error.status === 404)
|
||||||
|
dispatch(deleteFromTimelines(id));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,10 @@ const statusTranslateUndo = (state, id) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const removeStatusStub = (state, id) => {
|
||||||
|
return state.getIn([id, 'id']) ? state.deleteIn([id, 'isLoading']) : state.delete(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** @type {ImmutableMap<string, import('mastodon/models/status').Status>} */
|
/** @type {ImmutableMap<string, import('mastodon/models/status').Status>} */
|
||||||
const initialState = ImmutableMap();
|
const initialState = ImmutableMap();
|
||||||
|
|
@ -92,11 +96,10 @@ export default function statuses(state = initialState, action) {
|
||||||
return state.setIn([action.id, 'isLoading'], true);
|
return state.setIn([action.id, 'isLoading'], true);
|
||||||
case STATUS_FETCH_FAIL: {
|
case STATUS_FETCH_FAIL: {
|
||||||
if (action.parentQuotePostId && action.error.status === 404) {
|
if (action.parentQuotePostId && action.error.status === 404) {
|
||||||
return state
|
return removeStatusStub(state, action.id)
|
||||||
.delete(action.id)
|
|
||||||
.setIn([action.parentQuotePostId, 'quote', 'state'], 'deleted')
|
.setIn([action.parentQuotePostId, 'quote', 'state'], 'deleted')
|
||||||
} else {
|
} else {
|
||||||
return state.delete(action.id);
|
return removeStatusStub(state, action.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case STATUS_IMPORT:
|
case STATUS_IMPORT:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue