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) => {
|
||||
|
||||
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) {
|
||||
projectCards.push(card);
|
||||
rest.delete(card);
|
||||
} else {
|
||||
rest.add(card);
|
||||
if (!memoized) rest.add(card);
|
||||
}
|
||||
|
||||
return projectCards;
|
||||
|
@ -95,11 +95,19 @@ function createCards(projects: Project[], issues: any, lane: BoardLane, rest: Se
|
|||
|
||||
const kanboardCardMemo: {[key: string]: KanboardCard} = {};
|
||||
|
||||
function getMemoizedKanboardCard(id: number, title: string, project: Project, issue: Issue): KanboardCard {
|
||||
const key = `${project.id}-${issue.id}-${id}`;
|
||||
if (kanboardCardMemo.hasOwnProperty(key)) return kanboardCardMemo[key];
|
||||
function getKanboardCardMemoizationKey(id: number, project: Project, issue: Issue) {
|
||||
return `${project.id}-${issue.id}-${id}`;
|
||||
}
|
||||
|
||||
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 };
|
||||
return kanboardCardMemo[key];
|
||||
return { card: kanboardCardMemo[key], memoized: false };
|
||||
}
|
||||
|
||||
function resetKandboarCardMemo() {
|
||||
|
|
Loading…
Reference in New Issue