ShowModal displays a modal and returns a channel that will receive the result
(config rpctypes.ModalConfig)
| 433 | |
| 434 | // ShowModal displays a modal and returns a channel that will receive the result |
| 435 | func (c *ClientImpl) ShowModal(config rpctypes.ModalConfig) chan bool { |
| 436 | resultChan := c.addModalToMap(config) |
| 437 | |
| 438 | data, err := json.Marshal(config) |
| 439 | if err != nil { |
| 440 | log.Printf("failed to marshal modal config: %v", err) |
| 441 | c.CloseModal(config.ModalId, false) |
| 442 | return resultChan |
| 443 | } |
| 444 | |
| 445 | err = c.SendSSEvent(ssEvent{Event: "showmodal", Data: data}) |
| 446 | if err != nil { |
| 447 | log.Printf("failed to send modal SSE event: %v", err) |
| 448 | c.CloseModal(config.ModalId, false) |
| 449 | return resultChan |
| 450 | } |
| 451 | |
| 452 | return resultChan |
| 453 | } |
| 454 | |
| 455 | // removeModalFromMap removes a modal from the map and returns its state |
| 456 | func (c *ClientImpl) removeModalFromMap(modalId string) *ModalState { |
no test coverage detected