- threads.each { |t| user_labels.each { |l| t.apply_label l } }
- user_labels.each { |l| LabelManager << l }
+ undo = threads.map do |t|
+ old_labels = t.labels
+ user_labels.each do |(l, to_remove)|
+ if to_remove
+ t.remove_label l
+ else
+ t.apply_label l
+ end
+ end
+ ## UpdateManager or some other regresh mechanism?
+ UpdateManager.relay self, :labeled, t.first
+ lambda do
+ t.labels = old_labels
+ UpdateManager.relay self, :labeled, t.first
+ end
+ end
+ user_labels.each { |(l,_)| LabelManager << l }
+ UndoManager.register("labeling #{threads.size} #{threads.size.pluralize 'thread'}",
+ undo << lambda { regen_text})