updated the interaction api to have the new call to clear interactions, and am now using that call to clear the interactions from the pressure chain and when that response comes back successfully then will add the new set of interactions
This commit is contained in:
parent
0d0936269f
commit
39ac6fd5e2
3 changed files with 38 additions and 26 deletions
|
|
@ -36,6 +36,7 @@ export interface IInteractionsAPIContext {
|
|||
alerts: pond.AlertData[],
|
||||
otherTeam?: string
|
||||
) => Promise<AxiosResponse<pond.SetAlertInteractionsResponse>>;
|
||||
clearInteractions: (device: number, sources?: quack.ComponentID[], otherTeam?: string) => Promise<AxiosResponse<pond.ClearInteractionsResponse>>
|
||||
}
|
||||
|
||||
export const InteractionsAPIContext = createContext<IInteractionsAPIContext>(
|
||||
|
|
@ -285,6 +286,25 @@ export default function InteractionProvider(props: PropsWithChildren<Props>) {
|
|||
})
|
||||
};
|
||||
|
||||
const clearInteractions = (device: number, sources?: quack.ComponentID[], otherTeam?: string): Promise<AxiosResponse<pond.ClearInteractionsResponse>> => {
|
||||
const view = otherTeam ? otherTeam : as
|
||||
let sourceArray: string[] = []
|
||||
if (sources){
|
||||
sources.forEach(source => {
|
||||
sourceArray.push(componentIDToString(source))
|
||||
})
|
||||
}
|
||||
let url = pondURL("/devices/"+ device + "/interactions/clear" + (view ? "?as=" + view : "") + (sources ? "&sources=" + sourceArray.toString() : ""))
|
||||
return new Promise<AxiosResponse<pond.ClearInteractionsResponse>>((resolve, reject) => {
|
||||
post<pond.ClearInteractionsResponse>(url).then(resp => {
|
||||
resp.data = pond.ClearInteractionsResponse.fromObject(resp.data)
|
||||
return resolve(resp)
|
||||
}).catch(err => {
|
||||
return reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<InteractionsAPIContext.Provider
|
||||
value={{
|
||||
|
|
@ -296,7 +316,8 @@ export default function InteractionProvider(props: PropsWithChildren<Props>) {
|
|||
updateInteractionPondSettings,
|
||||
removeInteraction,
|
||||
listInteractionsByDevice,
|
||||
listInteractionsByComponent
|
||||
listInteractionsByComponent,
|
||||
clearInteractions
|
||||
}}>
|
||||
{children}
|
||||
</InteractionsAPIContext.Provider>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue