Skip to content

Commit

Permalink
Move push operation of blacklist into handler of add_window_btn in prefs
Browse files Browse the repository at this point in the history
Closes #21
  • Loading branch information
LuoYi committed Aug 6, 2022
1 parent cadf00f commit 838ffeb
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/preferences/pages/blacklist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,22 @@ export default GObject.registerClass (
private _add_row_btn !: Gtk.Button

/** Store value of settings */
private black_list: Array<string> = []
private black_list !: string[]

_init () {
super._init ()
this.black_list = []
this.black_list = settings ().black_list

// Read blacklist from settings, and add it to this._black_list
settings ().black_list.forEach ((name) => this.on_add_row (name))
this.black_list.forEach ((name) => this.on_add_row (name))

connections.get ().connect (this._add_row_btn, 'clicked', () => {
if (this.black_list.includes ('')) {
return
}

this.on_add_row ()
this.black_list.push ('')
settings ().black_list = this.black_list
})

Expand Down Expand Up @@ -69,11 +74,6 @@ export default GObject.registerClass (

/** Add a row to black list */
private on_add_row (title = '') {
if (this.black_list.includes (title)) {
this.show_err_msg (title)
return
}

const handlers: AppRowHandler = {
on_delete: (row, title) => this.on_delete_row (row, title),
on_title_changed: (old_title, new_title) =>
Expand All @@ -88,7 +88,6 @@ export default GObject.registerClass (
}

this._black_list_group.append (row)
this.black_list.push (title)
}

/** Called when title of item need to changed */
Expand Down

0 comments on commit 838ffeb

Please sign in to comment.