-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#28 - Added event triggers when modifying items
- Loading branch information
1 parent
7517869
commit 3a96fe8
Showing
7 changed files
with
67 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { pusher } from '../../plugins/pusher'; | ||
import { Item } from './item.schema'; | ||
|
||
export enum ItemEventType { | ||
UPDATE = 'update', | ||
DELETE = 'delete', | ||
} | ||
|
||
const getItemParentChannel = (item: Item): string => { | ||
if (!item.parentId) { | ||
return `browser-root-${item.ownerId}`; | ||
} | ||
|
||
return `browser-folder-${item.parentId}`; | ||
}; | ||
|
||
export const triggerItemEvent = async (item: Item, type: ItemEventType): Promise<void> => { | ||
const channelName = getItemParentChannel(item); | ||
|
||
await pusher.trigger(channelName, type, item); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters