Skip to content
Snippets Groups Projects
Commit 0a6cb235 authored by Vasilii Iakliushin's avatar Vasilii Iakliushin
Browse files

Load only blobs visible on the paginated page

Contributes to https://gitlab.com/gitlab-org/gitlab/-/issues/363065

Changelog: fixed
parent 52fcdbdc
No related merge requests found
......@@ -126,7 +126,7 @@ def define_commits
end
def define_diffs
@diffs = compare.present? ? compare.diffs(diff_options) : []
@diffs = compare.present? ? compare.diffs(diff_options.merge(manual_load: true)) : []
end
def define_environment
......
......@@ -137,7 +137,7 @@ def commit_signature_badge_classes(additional_classes)
def conditionally_paginate_diff_files(diffs, paginate:, page:, per:)
if paginate
Kaminari.paginate_array(diffs.diff_files.to_a).page(page).per(per)
Kaminari.paginate_array(diffs.diff_files.to_a).page(page).per(per).tap { |diff_files| diff_files.each(&:lazy_load!) }
else
diffs.diff_files
end
......
......@@ -30,6 +30,7 @@ def initialize(
diff_refs: nil,
fallback_diff_refs: nil,
stats: nil,
manual_load: nil,
unique_identifier: nil)
@diff = diff
......@@ -41,6 +42,13 @@ def initialize(
@unfolded = false
# Ensure items are collected in the the batch
unless manual_load
new_blob_lazy
old_blob_lazy
end
end
def lazy_load!
new_blob_lazy
old_blob_lazy
end
......
......@@ -125,6 +125,7 @@ def decorate_diff!(diff)
repository: project.repository,
diff_refs: diff_refs,
fallback_diff_refs: fallback_diff_refs,
manual_load: diff_options.fetch(:manual_load, false),
stats: stats)
if @use_extra_viewer_as_main && diff_file.has_renderable?
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment