parent
7309a2157b
commit
b456fe9f65
|
@ -75,13 +75,13 @@ function createCards(projects: Project[], issues: any, lane: BoardLane, rest: Se
|
||||||
return projectIssues.reduce((projectCards: KanboardCard[], issue: any) => {
|
return projectIssues.reduce((projectCards: KanboardCard[], issue: any) => {
|
||||||
|
|
||||||
const hasLabel = issue.labels.some((l: any) => l.name === lane.issueLabel);
|
const hasLabel = issue.labels.some((l: any) => l.name === lane.issueLabel);
|
||||||
const card = getMemoizedKanboardCard(issue.id, issue.title, p, issue);
|
const { card, memoized } = getMemoizedKanboardCard(issue.id, issue.title, p, issue);
|
||||||
|
|
||||||
if (hasLabel) {
|
if (hasLabel) {
|
||||||
projectCards.push(card);
|
projectCards.push(card);
|
||||||
rest.delete(card);
|
rest.delete(card);
|
||||||
} else {
|
} else {
|
||||||
rest.add(card);
|
if (!memoized) rest.add(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
return projectCards;
|
return projectCards;
|
||||||
|
@ -95,11 +95,19 @@ function createCards(projects: Project[], issues: any, lane: BoardLane, rest: Se
|
||||||
|
|
||||||
const kanboardCardMemo: {[key: string]: KanboardCard} = {};
|
const kanboardCardMemo: {[key: string]: KanboardCard} = {};
|
||||||
|
|
||||||
function getMemoizedKanboardCard(id: number, title: string, project: Project, issue: Issue): KanboardCard {
|
function getKanboardCardMemoizationKey(id: number, project: Project, issue: Issue) {
|
||||||
const key = `${project.id}-${issue.id}-${id}`;
|
return `${project.id}-${issue.id}-${id}`;
|
||||||
if (kanboardCardMemo.hasOwnProperty(key)) return kanboardCardMemo[key];
|
}
|
||||||
|
|
||||||
|
function isKanboardCardMemoized(key: string) {
|
||||||
|
return kanboardCardMemo.hasOwnProperty(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
function getMemoizedKanboardCard(id: number, title: string, project: Project, issue: Issue) {
|
||||||
|
const key = getKanboardCardMemoizationKey(id, project, issue);
|
||||||
|
if (isKanboardCardMemoized(key)) return { card: kanboardCardMemo[key], memoized: true };
|
||||||
kanboardCardMemo[key] = { id, title, project, issue };
|
kanboardCardMemo[key] = { id, title, project, issue };
|
||||||
return kanboardCardMemo[key];
|
return { card: kanboardCardMemo[key], memoized: false };
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetKandboarCardMemo() {
|
function resetKandboarCardMemo() {
|
||||||
|
|
Loading…
Reference in New Issue