Fix topic uniqueness issue
This commit is contained in:
@@ -5,8 +5,11 @@ namespace ntfysh_client
|
||||
{
|
||||
public partial class SubscribeDialog : Form
|
||||
{
|
||||
public SubscribeDialog()
|
||||
private readonly ListBox _notificationTopics;
|
||||
|
||||
public SubscribeDialog(ListBox notificationTopics)
|
||||
{
|
||||
_notificationTopics = notificationTopics;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
@@ -30,6 +33,11 @@ namespace ntfysh_client
|
||||
return password.Text;
|
||||
}
|
||||
|
||||
public string getUniqueString()
|
||||
{
|
||||
return $"{topicId.Text}@{serverUrl.Text}";
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (topicId.Text.Length < 1)
|
||||
@@ -64,6 +72,14 @@ namespace ntfysh_client
|
||||
return;
|
||||
}
|
||||
|
||||
if (_notificationTopics.Items.Contains(getUniqueString()))
|
||||
{
|
||||
MessageBox.Show($"The specified topic '{topicId.Text}' on the server '{serverUrl.Text}' is already subscribed", "Topic already subscribed", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
DialogResult = DialogResult.None;
|
||||
username.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user