find the title property and update its name to Title
This commit is contained in:
@ -96,7 +96,10 @@ export const setIntegrationResolver = authorized<
|
||||
if (integration.name.toLowerCase() === 'readwise') {
|
||||
// create a task to export all the items for readwise temporarily
|
||||
await enqueueExportToIntegration(integration.id, uid)
|
||||
} else if (integration.name.toLowerCase() === 'notion') {
|
||||
} else if (
|
||||
integration.name.toLowerCase() === 'notion' &&
|
||||
integration.settings
|
||||
) {
|
||||
const settings = integration.settings as { parentDatabaseId?: string }
|
||||
if (settings.parentDatabaseId) {
|
||||
// update notion database properties
|
||||
|
||||
@ -369,26 +369,17 @@ export class NotionClient implements IntegrationClient {
|
||||
|
||||
updateDatabase = async (databaseId: string) => {
|
||||
const database = await this.findDatabase(databaseId)
|
||||
// find the title property and update it
|
||||
const titleProperty = Object.entries(database.properties).find(
|
||||
([, property]) => property.type === 'title'
|
||||
)
|
||||
const title = titleProperty ? titleProperty[0] : 'Name'
|
||||
|
||||
await this.client.databases.update({
|
||||
database_id: database.id,
|
||||
title: [
|
||||
{
|
||||
text: {
|
||||
content: 'Library',
|
||||
},
|
||||
},
|
||||
],
|
||||
description: [
|
||||
{
|
||||
text: {
|
||||
content: 'Library of saved items from Omnivore',
|
||||
},
|
||||
},
|
||||
],
|
||||
properties: {
|
||||
Title: {
|
||||
title: {},
|
||||
[title]: {
|
||||
name: 'Title',
|
||||
},
|
||||
Author: {
|
||||
rich_text: {},
|
||||
|
||||
Reference in New Issue
Block a user