mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-21 21:44:52 +00:00
When looping the conversations in bulk action to assign them to new labels, the existing labels in other conversations were also getting duplicated across all conversations. This PR fixes the issue. > In the previous implementation, new_labels is appended to the existing labels using the << operator. This operator modifies the original array instead of creating a new one, causing unwanted side effects. More specifically, new_labels is a reference to the original argument array of the method. Co-authored-by: Sojan <sojan@pepalo.com> Co-authored-by: Peter Salib <74493166+Peteraymansalib@users.noreply.github.com>
18 lines
374 B
Ruby
18 lines
374 B
Ruby
module Labelable
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
acts_as_taggable_on :labels
|
|
end
|
|
|
|
def update_labels(labels = nil)
|
|
update!(label_list: labels)
|
|
end
|
|
|
|
def add_labels(new_labels = nil)
|
|
new_labels = Array(new_labels) # Make sure new_labels is an array
|
|
combined_labels = labels + new_labels
|
|
update!(label_list: combined_labels)
|
|
end
|
|
end
|