Update to new arch

This commit is contained in:
Nick Mowen 2022-01-13 17:40:41 -07:00
parent ce6d9b3ca9
commit 5d91fc34cd

View File

@ -123,9 +123,19 @@ export function useRetain() {
async function retainEvent(eventId, shouldRetain) { async function retainEvent(eventId, shouldRetain) {
if (!eventId) return null; if (!eventId) return null;
const response = await fetch(`${state.host}/api/events/${eventId}?retain=${shouldRetain}`, { method: 'POST' }); console.log("trying to set retain as " + shouldRetain);
await dispatch({ type: 'POST', payload: { eventId } });
return await (response.status < 300 ? response.json() : { success: true }); if (shouldRetain) {
const response = await fetch(`${state.host}/api/events/${eventId}/retain`, { method: 'POST' });
console.log("response is " + response.status);
await dispatch({ type: 'POST', payload: { eventId } });
return await (response.status < 300 ? response.json() : { success: true });
} else {
const response = await fetch(`${state.host}/api/events/${eventId}/retain`, { method: 'DELETE' });
console.log("response is " + response.status);
await dispatch({ type: 'DELETE', payload: { eventId } });
return await (response.status < 300 ? response.json() : { success: true });
}
} }
return retainEvent; return retainEvent;