public static void PromptSendRequest(string key, string promptText) { int index = FindMatchingRequestIndex(key); if (index >= 0 && index < promptRequests.Count) { PromptRequestData matchingRequest = FindMatchingRequest(index); string matchingKey = matchingRequest.key; PromptRequestData updatedRequest = new PromptRequestData( matchingKey, promptText); promptRequests[index] = updatedRequest; OnPromptUpdated?.Invoke(updatedRequest, promptText); return; } PromptRequestData request = new PromptRequestData(key, promptText); if (request.IsInvalid) { return; } promptRequests.Add(request); OnPromptSendRequestReceived?.Invoke(request); OnLatestPromptSelected?.Invoke(request); }
public static void PromptRemovalRequest(string key) { PromptRequestData request = FindMatchingRequest(key); if (request.IsInvalid) { return; } promptRequests.Remove(request); OnPromptRemovalRequestReceived?.Invoke(request); if (promptRequests.Count > 0) { PromptRequestData lastPromptRequest = promptRequests.Last(); OnLatestPromptSelected?.Invoke(request); } else { OnLatestPromptSelected?.Invoke(PromptRequestData.Invalid); } }