| | | 1 | | @using static UIBlazor.Components.Chat.DiffView |
| | | 2 | | @{ |
| | 0 | 3 | | var css = Model.Type switch |
| | 0 | 4 | | { |
| | 0 | 5 | | DiffBlockType.SearchHeader => "diff-header-search", |
| | 0 | 6 | | DiffBlockType.Separator => "diff-header-separator", |
| | 0 | 7 | | DiffBlockType.ReplaceHeader => "diff-header-replace", |
| | 0 | 8 | | DiffBlockType.Removed => "diff-line diff-line-removed", |
| | 0 | 9 | | DiffBlockType.Added => "diff-line diff-line-added", |
| | 0 | 10 | | _ => "diff-line-context" |
| | 0 | 11 | | }; |
| | | 12 | | } |
| | | 13 | | |
| | | 14 | | <div class="@css"> |
| | 0 | 15 | | @if (Model.Type == DiffBlockType.Removed) |
| | | 16 | | { |
| | | 17 | | <span class="diff-marker">-</span> |
| | | 18 | | } |
| | 0 | 19 | | @if (Model.Type == DiffBlockType.Added) |
| | | 20 | | { |
| | | 21 | | <span class="diff-marker">+</span> |
| | | 22 | | } |
| | 0 | 23 | | @Model.Content |
| | | 24 | | </div> |
| | | 25 | | |
| | | 26 | | @code { |
| | 0 | 27 | | [Parameter] public DiffBlock Model { get; set; } = default!; |
| | | 28 | | |
| | 0 | 29 | | private string _lastContent = string.Empty; |
| | | 30 | | private DiffBlockType _lastType; |
| | | 31 | | |
| | | 32 | | protected override bool ShouldRender() |
| | | 33 | | { |
| | | 34 | | // Рендерим ТОЛЬКО если контент или тип реально изменились |
| | 0 | 35 | | if (Model.Content != _lastContent || Model.Type != _lastType) |
| | | 36 | | { |
| | 0 | 37 | | _lastContent = Model.Content; |
| | 0 | 38 | | _lastType = Model.Type; |
| | 0 | 39 | | return true; |
| | | 40 | | } |
| | 0 | 41 | | return false; |
| | | 42 | | } |
| | | 43 | | } |