Skip to content

Commit bd350a0

Browse files
committed
Reset button cal reload online settings when in Free mode
1 parent 12b10dc commit bd350a0

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

FetchXmlBuilder/DockControls/AiChatControl.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ internal void Initialize(bool neverprompt = false)
152152
SetTitle();
153153
if (provider.Free && !IsFreeAiUser(fxb) && !string.IsNullOrWhiteSpace(OnlineSettings.Instance.AiSupport.TextToRequestFreeAi))
154154
{
155-
chatHistory.Add(ChatRole.Assistant, OnlineSettings.Instance.AiSupport.TextToRequestFreeAi, false);
155+
chatHistory.Add(ChatRole.Assistant, OnlineSettings.Instance.AiSupport.TextToRequestFreeAi);
156156
}
157157
mnuFree.Text = IsFreeAiUser(fxb) ? "Using AI for Free!" : "Request for Free AI...";
158158
EnableButtons();
@@ -210,7 +210,7 @@ private void EnableButtons()
210210
btnAiChatAsk.Enabled = cancall && !string.IsNullOrWhiteSpace(txtAiChat.Text);
211211
btnYes.Enabled = cancall && chatHistory?.HasDialog == true;
212212
btnExecute.Enabled = cancall;
213-
btnReset.Enabled = cancall && chatHistory?.IsRunning == false && chatHistory?.HasDialog == true;
213+
btnReset.Enabled = (cancall && chatHistory?.IsRunning == false && chatHistory?.HasDialog == true) || (provider?.Free == true && !IsFreeAiUser(fxb));
214214
splitAiChat.Panel2.Enabled = chatHistory?.IsRunning != true;
215215
txtAiChat.BackColor = chatHistory?.IsRunning == true ? ChatMessageHistory.WaitingBackColor : ChatMessageHistory.BackColor;
216216
txtAiChat.Enabled = cancall && chatHistory?.IsRunning != true;
@@ -387,7 +387,7 @@ private string UpdateCurrentFetchXmlQuery([Description("A well formed FetchXml q
387387
}
388388
}
389389

390-
[Description("Retrieves the logical name and display name of tables/entity that matches a description. The result is returned in a JSON list with entries of the format {\"LN\":\"[logical name of entity]\",\"DN\":\"[display name of entity]\"}. There may be many results, if a unique table cannot be found.")]
390+
[Description("Retrieves the logical name and display name of tables/entity that matches a description. The result is returned in a JSON list with entries of the format {\"L\":\"[logical name of entity]\",\"D\":\"[display name of entity]\"}. There may be many results, if a unique table cannot be found.")]
391391
private string GetMetadataForUnknownEntity([Description("The name/description of a table.")] string tableDescription)
392392
{
393393
var entities = fxb.EntitiesForAi();
@@ -406,7 +406,7 @@ private string GetMetadataForUnknownEntity([Description("The name/description of
406406
return result.Text;
407407
}
408408

409-
[Description("Returns attributes of a table/entity that matches a description. Information about attributes is returned in a JSON list with entries of the format {\"LN\":\"[logical name of attribute]\",\"DN\":\"[display name of attribute]\"}. There may be many results, if a unique attribute cannot be found.")]
409+
[Description("Returns attributes of a table/entity that matches a description. Information about attributes is returned in a JSON list with entries of the format {\"L\":\"[logical name of attribute]\",\"D\":\"[display name of attribute]\"}. There may be many results, if a unique attribute cannot be found.")]
410410
private string GetMetadataForUnknownAttribute([Description("The logical name of the entity and a name/description of an attribute, separated by '@@'. Example: 'logical name of table@@a description of an attribute'")] string entityNameAndAttributeDescription)
411411
{
412412
var parts = entityNameAndAttributeDescription.Split(new[] { "@@" }, 2, StringSplitOptions.None);
@@ -582,6 +582,12 @@ private void txtAiChatAsk_KeyDown(object sender, KeyEventArgs e)
582582

583583
private void btnReset_Click(object sender, EventArgs e)
584584
{
585+
if (provider?.Free == true && !IsFreeAiUser(fxb))
586+
{
587+
OnlineSettings.Reset();
588+
Initialize();
589+
return;
590+
}
585591
if (MessageBoxEx.Show(fxb, "Are you sure you want to clear the AI chat history?", "Reset AI Chat", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
586592
{
587593
Initialize();

FetchXmlBuilder/Settings/OnlineSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public static OnlineSettings Instance
4242
}
4343
}
4444

45+
public static void Reset() => instance = null;
46+
4547
private static T Load<T>(string filename)
4648
{
4749
var path = Path.Combine(Paths.SettingsPath, FileName);

0 commit comments

Comments
 (0)