(ctx context.Context, request *UserInputRequest)
| 105 | } |
| 106 | |
| 107 | func (p *FrontendProvider) GetUserInput(ctx context.Context, request *UserInputRequest) (*UserInputResponse, error) { |
| 108 | id, uiCh := MainUserInputHandler.registerChannel() |
| 109 | defer MainUserInputHandler.unregisterChannel(id) |
| 110 | request.RequestId = id |
| 111 | request.TimeoutMs = int(utilfn.TimeoutFromContext(ctx, 30*time.Second).Milliseconds()) |
| 112 | |
| 113 | scopes, scopesErr := determineScopes(ctx) |
| 114 | if scopesErr != nil { |
| 115 | log.Printf("user input scopes could not be found: %v", scopesErr) |
| 116 | blocklogger.Infof(ctx, "user input scopes could not be found: %v", scopesErr) |
| 117 | allWindows, err := wstore.DBGetAllOIDsByType(ctx, "window") |
| 118 | if err != nil { |
| 119 | blocklogger.Infof(ctx, "unable to find windows for user input: %v", err) |
| 120 | return nil, fmt.Errorf("unable to find windows for user input: %v", err) |
| 121 | } |
| 122 | scopes = allWindows |
| 123 | } |
| 124 | |
| 125 | MainUserInputHandler.sendRequestToFrontend(request, scopes) |
| 126 | |
| 127 | var response *UserInputResponse |
| 128 | var err error |
| 129 | select { |
| 130 | case resp := <-uiCh: |
| 131 | log.Printf("checking received: %v", resp.RequestId) |
| 132 | response = resp |
| 133 | case <-ctx.Done(): |
| 134 | return nil, fmt.Errorf("timed out waiting for user input") |
| 135 | } |
| 136 | |
| 137 | if response.ErrorMsg != "" { |
| 138 | err = errors.New(response.ErrorMsg) |
| 139 | } |
| 140 | |
| 141 | return response, err |
| 142 | } |
| 143 | |
| 144 | func GetUserInput(ctx context.Context, request *UserInputRequest) (*UserInputResponse, error) { |
| 145 | return defaultProvider.GetUserInput(ctx, request) |
nothing calls this directly
no test coverage detected