Skip to content

Commit

Permalink
Remove unnecessary triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmeyers committed Apr 28, 2024
1 parent 79fdb96 commit e34ebef
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 63 deletions.
8 changes: 0 additions & 8 deletions src/DragDropApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,6 @@ export function DragDropApp({ win, plugin }: { win: Window; plugin: KanbanPlugin
dropPath.push(0);
}

plugin.app.workspace.trigger(
'kanban:card-moved',
stateManager.file,
dragPath,
dropPath,
dragEntityData
);

return stateManager.setState((board) => {
let didMoveItem = false;

Expand Down
2 changes: 0 additions & 2 deletions src/StateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,6 @@ export class StateManager {
});
});

this.app.workspace.trigger('kanban:board-cards-archived', this.file, archived);

try {
this.setState(
update(board, {
Expand Down
53 changes: 0 additions & 53 deletions src/helpers/boardModifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,44 +55,24 @@ export function getBoardModifiers(stateManager: StateManager): BoardModifiers {

return {
appendItems: (path: Path, items: Item[]) => {
items.forEach((item) =>
stateManager.app.workspace.trigger('kanban:card-added', stateManager.file, item)
);

stateManager.setState((boardData) => appendEntities(boardData, path, items));
},

prependItems: (path: Path, items: Item[]) => {
items.forEach((item) =>
stateManager.app.workspace.trigger('kanban:card-added', stateManager.file, item)
);

stateManager.setState((boardData) => prependEntities(boardData, path, items));
},

insertItems: (path: Path, items: Item[]) => {
items.forEach((item) =>
stateManager.app.workspace.trigger('kanban:card-added', stateManager.file, item)
);

stateManager.setState((boardData) => insertEntity(boardData, path, items));
},

replaceItem: (path: Path, items: Item[]) => {
items.forEach((item) =>
stateManager.app.workspace.trigger('kanban:card-added', stateManager.file, item)
);

stateManager.setState((boardData) =>
insertEntity(removeEntity(boardData, path), path, items)
);
},

splitItem: (path: Path, items: Item[]) => {
items.forEach((item) =>
stateManager.app.workspace.trigger('kanban:card-added', stateManager.file, item)
);

stateManager.setState((boardData) => {
return insertEntity(removeEntity(boardData, path), path, items);
});
Expand All @@ -111,20 +91,14 @@ export function getBoardModifiers(stateManager: StateManager): BoardModifiers {
},

addLane: (lane: Lane) => {
stateManager.app.workspace.trigger('kanban:lane-added', stateManager.file, lane);

stateManager.setState((boardData) => appendEntities(boardData, [], [lane]));
},

insertLane: (path: Path, lane: Lane) => {
stateManager.app.workspace.trigger('kanban:lane-added', stateManager.file, lane);

stateManager.setState((boardData) => insertEntity(boardData, path, [lane]));
},

updateLane: (path: Path, lane: Lane) => {
stateManager.app.workspace.trigger('kanban:lane-updated', stateManager.file, lane);

stateManager.setState((boardData) =>
updateParentEntity(boardData, path, {
children: {
Expand All @@ -141,8 +115,6 @@ export function getBoardModifiers(stateManager: StateManager): BoardModifiers {
const lane = getEntityFromPath(boardData, path);
const items = lane.children;

stateManager.app.workspace.trigger('kanban:lane-archived', stateManager.file, lane);

try {
return update(removeEntity(boardData, path), {
data: {
Expand All @@ -165,8 +137,6 @@ export function getBoardModifiers(stateManager: StateManager): BoardModifiers {
const lane = getEntityFromPath(boardData, path);
const items = lane.children;

stateManager.app.workspace.trigger('kanban:lane-cards-archived', stateManager.file, items);

try {
return update(
updateEntity(boardData, path, {
Expand All @@ -193,24 +163,12 @@ export function getBoardModifiers(stateManager: StateManager): BoardModifiers {

deleteEntity: (path: Path) => {
stateManager.setState((boardData) => {
const entity = getEntityFromPath(boardData, path);

stateManager.app.workspace.trigger(
`kanban:${entity.type}-deleted`,
stateManager.file,
entity
);

return removeEntity(boardData, path);
});
},

updateItem: (path: Path, item: Item) => {
stateManager.setState((boardData) => {
const oldItem = getEntityFromPath(boardData, path);

stateManager.app.workspace.trigger('kanban:card-updated', stateManager.file, oldItem, item);

return updateParentEntity(boardData, path, {
children: {
[path[path.length - 1]]: {
Expand All @@ -224,9 +182,6 @@ export function getBoardModifiers(stateManager: StateManager): BoardModifiers {
archiveItem: (path: Path) => {
stateManager.setState((boardData) => {
const item = getEntityFromPath(boardData, path);

stateManager.app.workspace.trigger('kanban:card-archived', stateManager.file, path, item);

try {
return update(removeEntity(boardData, path), {
data: {
Expand All @@ -247,14 +202,6 @@ export function getBoardModifiers(stateManager: StateManager): BoardModifiers {
duplicateEntity: (path: Path) => {
stateManager.setState((boardData) => {
const entity = getEntityFromPath(boardData, path);

stateManager.app.workspace.trigger(
`kanban:${entity.type}-duplicated`,
stateManager.file,
path,
entity
);

const entityWithNewID = update(entity, {
id: {
$set: generateInstanceId(),
Expand Down

0 comments on commit e34ebef

Please sign in to comment.