Skip to content

Use TagsView for "Site Settings -> Tags" #24674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: feature/tags-data-view-post-settings
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,18 @@ public final class DataViewPaginatedResponse<Element: Identifiable, PageIndex>:
self.total = total - 1
}
}

public func replace(_ item: Element) {
guard let index = items.firstIndex(where: { $0.id == item.id }) else {
return
}
items[index] = item
}

public func prepend(_ newItems: [Element]) {
self.items = newItems + self.items
if let total {
self.total = total + newItems.count
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How should the Data View handle a new item is added from the client side? Like adding a new tag in this case.

We should not refresh the Data View, because the new item may not be on the first page.

We can insert the new item into the fetched items. But where? We can only try to mimic the server-side implementation, based on the order of response items. Then the DataViewPaginatedResponse needs to have a sorting function, which may complicate things.

In this PR, I went with the simplest solution, where the new item is placed at the top of the list.

Let me know what you think, @kean

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inserting at the top seems like the best option.

}
Loading