mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-15 16:59:41 +00:00
[Glitch] Fix error handling when re-fetching already-known statuses
Port edfbcfb3f5 to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
@@ -78,6 +78,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));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,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('flavours/glitch/models/status').Status>} */
|
/** @type {ImmutableMap<string, import('flavours/glitch/models/status').Status>} */
|
||||||
const initialState = ImmutableMap();
|
const initialState = ImmutableMap();
|
||||||
@@ -75,11 +79,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:
|
||||||
|
|||||||
Reference in New Issue
Block a user