Skip to content

Commit

Permalink
Fixed renaming thread issue, thanks to eva-1-x-3 in this issue report:
Browse files Browse the repository at this point in the history
…#7

Clicking cancel in rename thread dialog box reverted thread to "No Subject".
  • Loading branch information
Issung committed Dec 24, 2020
1 parent 9eaedd0 commit 1f72421
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 34 deletions.
20 changes: 9 additions & 11 deletions GChan/Forms/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,19 +309,17 @@ private bool IsUnique(string url, IEnumerable<Tracker> list)

private void RenameThreadSubjectPrompt(int threadBindingSourceIndex)
{
lock (threadLock)
Thread thread = Model.Threads[threadBindingSourceIndex];
GetStringMessageBox dialog = new GetStringMessageBox(thread.Subject);
dialog.StartPosition = FormStartPosition.CenterParent;

DialogResult result = dialog.ShowDialog();

if (result == DialogResult.OK)
{
string currentSubject = Model.Threads[threadBindingSourceIndex].Subject;
string entry = Utils.MessageBoxGetString(currentSubject, Left + 50, Top + 50);
string newSubject = string.IsNullOrWhiteSpace(dialog.UserEntry) ? Thread.NO_SUBJECT : dialog.UserEntry;

if (string.IsNullOrWhiteSpace(entry))
{
Model.Threads[threadBindingSourceIndex].SetSubject(Thread.NO_SUBJECT);
}
else
{
Model.Threads[threadBindingSourceIndex].SetSubject(entry);
}
thread.SetSubject(newSubject);
}
}

Expand Down
23 changes: 0 additions & 23 deletions GChan/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,29 +291,6 @@ public static string CombinePathAndFilename(string directory, string filename)
return fullpath;
}

public static string MessageBoxGetString(string currentSubject, int x = 0, int y = 0)
{
GetStringMessageBox dialog = new GetStringMessageBox(currentSubject);
dialog.TopMost = true;

if (x != 0 && y != 0)
{
dialog.Left = x;
dialog.Top = y;
}

// Show testDialog as a modal dialog and determine if DialogResult = OK.
if (dialog.ShowDialog() == DialogResult.OK)
{
// Read the contents of testDialog's TextBox.
return dialog.UserEntry.Replace("\n", "").Replace("\r", "");
}
else
{
return null;
}
}

public static string RemoveCharactersFromString(string haystack, params char[] removeThese)
{
string ret = haystack;
Expand Down

0 comments on commit 1f72421

Please sign in to comment.