diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-10-16 19:21:16 +0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-11-06 22:39:31 +0300 |
commit | ec66ef1b74fa431b18b23812a2a7cf881d1b98d8 (patch) | |
tree | 2d56631926261b642f79d4fcc1a3ce8e3d7c6844 /app/services | |
parent | 912741cfea06ead8dad95d20f2f0adb955a55732 (diff) |
Comment on any expanded diff line on MRs
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/merge_requests/reload_diffs_service.rb | 4 | ||||
-rw-r--r-- | app/services/notes/base_service.rb | 15 | ||||
-rw-r--r-- | app/services/notes/create_service.rb | 3 | ||||
-rw-r--r-- | app/services/notes/destroy_service.rb | 4 |
4 files changed, 20 insertions, 6 deletions
diff --git a/app/services/merge_requests/reload_diffs_service.rb b/app/services/merge_requests/reload_diffs_service.rb index b4d48fe92ad..d19cd1ac40f 100644 --- a/app/services/merge_requests/reload_diffs_service.rb +++ b/app/services/merge_requests/reload_diffs_service.rb @@ -29,10 +29,6 @@ module MergeRequests # rubocop: disable CodeReuse/ActiveRecord def clear_cache(new_diff) - # Executing the iteration we cache highlighted diffs for each diff file of - # MergeRequestDiff. - cacheable_collection(new_diff).write_cache - # Remove cache for all diffs on this MR. Do not use the association on the # model, as that will interfere with other actions happening when # reloading the diff. diff --git a/app/services/notes/base_service.rb b/app/services/notes/base_service.rb new file mode 100644 index 00000000000..431ff6c11c4 --- /dev/null +++ b/app/services/notes/base_service.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Notes + class BaseService < ::BaseService + def clear_noteable_diffs_cache(note) + noteable = note.noteable + + if note.is_a?(DiffNote) && + note.discussion_first_note? && + note.position.unfolded_diff?(project.repository) + noteable.diffs.clear_cache + end + end + end +end diff --git a/app/services/notes/create_service.rb b/app/services/notes/create_service.rb index 049e6c5a871..e03789e3ca9 100644 --- a/app/services/notes/create_service.rb +++ b/app/services/notes/create_service.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Notes - class CreateService < ::BaseService + class CreateService < ::Notes::BaseService def execute merge_request_diff_head_sha = params.delete(:merge_request_diff_head_sha) @@ -35,6 +35,7 @@ module Notes if !only_commands && note.save todo_service.new_note(note, current_user) + clear_noteable_diffs_cache(note) end if command_params.present? diff --git a/app/services/notes/destroy_service.rb b/app/services/notes/destroy_service.rb index 64e9accd97f..fa0c2c5c86b 100644 --- a/app/services/notes/destroy_service.rb +++ b/app/services/notes/destroy_service.rb @@ -1,11 +1,13 @@ # frozen_string_literal: true module Notes - class DestroyService < BaseService + class DestroyService < ::Notes::BaseService def execute(note) TodoService.new.destroy_target(note) do |note| note.destroy end + + clear_noteable_diffs_cache(note) end end end |