Skip to content

[Do Not Merge]fix(list-view): Recycle items for component children #740

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

Closed
wants to merge 1 commit into from

Conversation

hdeshev
Copy link
Contributor

@hdeshev hdeshev commented Apr 5, 2017

We were not recycling item views if the item contained a single
custom component child.

Fixes #737

We were not recycling item views if the item contained a single
custom component child.
@@ -160,6 +162,7 @@ export class ListViewComponent implements DoCheck, OnDestroy, AfterContentInit {

if (args.view && args.view[NG_VIEW]) {
listViewLog("onItemLoading: " + index + " - Reusing existing view");
console.log("onItemLoading: " + index + " - Reusing existing view");
Copy link
Contributor

Choose a reason for hiding this comment

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

Debug console.log leftover?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is the code that should extract the view ref, event if the root view was "wrapped" in Stack layout

@@ -169,6 +172,7 @@ export class ListViewComponent implements DoCheck, OnDestroy, AfterContentInit {
}
} else {
listViewLog("onItemLoading: " + index + " - Creating view from template");
console.log("onItemLoading: " + index + " - Creating view from template");
Copy link
Contributor

Choose a reason for hiding this comment

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

Debug console.log leftover?

@@ -242,7 +246,12 @@ export interface ComponentView {
export type RootLocator = (nodes: Array<any>, nestLevel: number) => View;

export function getItemViewRoot(viewRef: ComponentView, rootLocator: RootLocator = getSingleViewRecursive): View {
const rootView = rootLocator(viewRef.rootNodes, 0);
let rootView = rootLocator(viewRef.rootNodes, -1);
if (rootView instanceof ProxyViewContainer) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a more borad check should be used:
if (!args.view instanceof LayoutBase || args.view instanceof ProxyViewContainer)
This will handle cases when template produces a single Label or Button for example

@vakrilov vakrilov changed the title fix(list-view): Recycle items for component children [Do Not Merge]fix(list-view): Recycle items for component children Apr 6, 2017
@vakrilov
Copy link
Contributor

Closing in because of #743

@vakrilov vakrilov closed this Apr 10, 2017
@sis0k0 sis0k0 deleted the hdeshev/listview-component-recycle branch August 3, 2017 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants