2020-03-27 13:59:38 -07:00
|
|
|
'use strict';
|
|
|
|
|
2022-03-11 12:42:52 -08:00
|
|
|
import { Record as ImmutableRecord } from 'immutable';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-04-25 11:57:24 -07:00
|
|
|
import { fetchInstance } from 'soapbox/actions/instance';
|
2020-03-27 13:59:38 -07:00
|
|
|
|
2022-04-24 12:28:07 -07:00
|
|
|
import type { AnyAction } from 'redux';
|
|
|
|
|
2022-03-11 12:42:52 -08:00
|
|
|
const ReducerRecord = ImmutableRecord({
|
|
|
|
instance_fetch_failed: false,
|
|
|
|
});
|
2020-03-27 13:59:38 -07:00
|
|
|
|
2022-04-24 12:28:07 -07:00
|
|
|
export default function meta(state = ReducerRecord(), action: AnyAction) {
|
2022-05-11 10:40:34 -07:00
|
|
|
switch (action.type) {
|
2022-05-11 14:06:35 -07:00
|
|
|
case fetchInstance.rejected.type:
|
|
|
|
if (action.payload.response?.status === 404) {
|
|
|
|
return state.set('instance_fetch_failed', true);
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
default:
|
|
|
|
return state;
|
2020-03-27 13:59:38 -07:00
|
|
|
}
|
2021-08-03 12:22:51 -07:00
|
|
|
}
|