Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webhook project setttings fix #1265

Merged
merged 3 commits into from
Jan 9, 2025
Merged

Conversation

sneakzttv
Copy link
Contributor

@sneakzttv sneakzttv commented Jan 7, 2025

The websocket if it's there is already being applied via Web3SettingsEditor.ChainSettings.cs:

if (webHookOptions.Length > 0)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel("Select WebHook");
                    selectedWebHookIndex =
                        Mathf.Clamp(selectedWebHookIndex, 0, window.chainList[selectedChainIndex].rpc.Count - 1);
                    var webhookIndex = window.chainList[selectedChainIndex].rpc.IndexOf(chainConfig.Ws);
                    var selectedWebHook =
                        webhookIndex == -1 ? window.chainList[selectedChainIndex].rpc[selectedWebHookIndex] : chainConfig.Ws;
                    if (GUILayout.Button(selectedWebHook, EditorStyles.popup))
                    {
                        searchProvider = CreateInstance<StringListSearchProvider>();
                        searchProvider.Initialize(webHookOptions,
                            x =>
                            {
                                var str = x.Replace("\u2215", "/");

                                selectedWebHookIndex = window.chainList[selectedChainIndex].rpc.IndexOf(str);
                                chainConfig.Ws = str;
                                changedRpcOrWs = true;
                                UpdateServerMenuInfo();
                            });
                        SearchWindow.Open(
                            new SearchWindowContext(GUIUtility.GUIToScreenPoint(Event.current.mousePosition)),
                            searchProvider);
                    }

                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.HelpBox("If you set your custom WebHook URI it will override the selection above.", MessageType.Info);
                }

                chainConfig.Ws = EditorGUILayout.TextField("Custom WebHook", chainConfig.Ws);

I've also altered the ternary operator with an extra safety check though just to be sure.

var selectedWebHook = (webhookIndex == -1 || string.IsNullOrEmpty(chainConfig.Ws))  ? window.chainList[selectedChainIndex].rpc[selectedWebHookIndex] : chainConfig.Ws;

Video:
https://gyazo.com/05c96ad8c83dc489d9358c70d9bdd44a

No documentation changes are needed.

altered the ternary operator to account for cases where websocket is empty.
@sneakzttv sneakzttv added ready-to-merge Ready to Merge PR - this'll trigger required checks documented Apply on Pull Request after documentation to allow merge labels Jan 7, 2025
@sneakzttv sneakzttv linked an issue Jan 7, 2025 that may be closed by this pull request
Copy link
Contributor

@juans-chainsafe juans-chainsafe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, is not breaking existing project settings changes

@sneakzttv sneakzttv added ready-to-merge Ready to Merge PR - this'll trigger required checks and removed ready-to-merge Ready to Merge PR - this'll trigger required checks labels Jan 9, 2025
@sneakzttv sneakzttv added ready-to-merge Ready to Merge PR - this'll trigger required checks and removed ready-to-merge Ready to Merge PR - this'll trigger required checks labels Jan 9, 2025
@sneakzttv sneakzttv merged commit faf1164 into dev Jan 9, 2025
7 checks passed
@sneakzttv sneakzttv deleted the sneakz/webhook-default-display-fix branch January 9, 2025 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documented Apply on Pull Request after documentation to allow merge ready-to-merge Ready to Merge PR - this'll trigger required checks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Polishing. Fill out the Custom WebHook URL on initialization.
3 participants