fix: don't allow empty sounds

This commit is contained in:
Anna 2021-05-12 18:38:39 -04:00
parent 3fa40d3d29
commit b148669f5f
1 changed files with 10 additions and 6 deletions

View File

@ -63,18 +63,20 @@ namespace SoundFilter.Ui {
this._newSoundPath = string.Empty;
}
if (Util.IconButton(FontAwesomeIcon.Save, $"save-filter-{this.Id}") && this._soundPaths.Count > 0 && !string.IsNullOrWhiteSpace(this._filterName)) {
if (Util.IconButton(FontAwesomeIcon.Save, $"save-filter-{this.Id}") && !string.IsNullOrWhiteSpace(this._filterName)) {
if (!string.IsNullOrWhiteSpace(this._newSoundPath)) {
this._soundPaths.Add(this._newSoundPath);
}
this.Save();
if (this._soundPaths.Count(sound => sound.Length > 0) > 0) {
this.Save();
this._filterName = string.Empty;
this._newSoundPath = string.Empty;
this._soundPaths.Clear();
this._filterName = string.Empty;
this._newSoundPath = string.Empty;
this._soundPaths.Clear();
return true;
return true;
}
}
@ -95,6 +97,8 @@ namespace SoundFilter.Ui {
}
private void Save() {
this._soundPaths.RemoveAll(string.IsNullOrWhiteSpace);
if (this.Filter != null) {
this.Filter.Name = this._filterName;
this.Filter.Globs.Clear();