skip publishing event for importing

This commit is contained in:
Hongbo Wu
2023-10-23 21:31:38 +08:00
parent 79a647deb4
commit 3f14ac4f9b
2 changed files with 12 additions and 3 deletions

View File

@ -527,7 +527,8 @@ export const createLibraryItems = async (
export const createLibraryItem = async (
libraryItem: DeepPartial<LibraryItem>,
userId: string,
pubsub = createPubSubClient()
pubsub = createPubSubClient(),
skipPubSub = false
): Promise<LibraryItem> => {
const newLibraryItem = await authTrx(
async (tx) =>
@ -541,6 +542,10 @@ export const createLibraryItem = async (
userId
)
if (skipPubSub) {
return newLibraryItem
}
await pubsub.entityCreated<DeepPartial<LibraryItem>>(
EntityType.PAGE,
{

View File

@ -7,7 +7,6 @@ import { User } from '../entity/user'
import { homePageURL } from '../env'
import {
ArticleSavingRequestStatus,
HighlightType,
Maybe,
PreparedDocumentInput,
SaveErrorCode,
@ -144,7 +143,12 @@ export const savePage = async (
)
} else {
// do not publish a pubsub event if the item is imported
const newItem = await createLibraryItem(itemToSave, user.id)
const newItem = await createLibraryItem(
itemToSave,
user.id,
undefined,
isImported
)
clientRequestId = newItem.id
}