feat: allow using chat to modify page titles
This commit is contained in:
@@ -96,7 +96,7 @@ export class ChatStore {
|
||||
});
|
||||
}
|
||||
|
||||
addArtifact({ messageId, name, title, id }: ArtifactCallbackData) {
|
||||
async addArtifact({ messageId, name, title, id }: ArtifactCallbackData) {
|
||||
const artifact = this.getArtifact(messageId, name);
|
||||
if (artifact) {
|
||||
return;
|
||||
@@ -129,6 +129,8 @@ export class ChatStore {
|
||||
artifactsByPageName.set(name, newArtifact);
|
||||
|
||||
this.artifacts.set(artifactsByMessageId);
|
||||
const bridge = await editorBridge;
|
||||
bridge.updatePageAttributes(name, { title });
|
||||
}
|
||||
|
||||
updateArtifact({ messageId, name }: ArtifactCallbackData, state: Partial<ArtifactUpdateState>) {
|
||||
|
||||
@@ -299,6 +299,11 @@ export class PagesStore {
|
||||
switch (type) {
|
||||
case 'add_page': {
|
||||
const { title: pageTitle, actionIds = [] } = payload;
|
||||
const oldPage = this.pages.get()[pageName];
|
||||
if (oldPage) {
|
||||
throw new Error(`Page ${pageName} already exists`);
|
||||
}
|
||||
|
||||
this.pages.setKey(pageName, {
|
||||
name: pageName,
|
||||
title: pageTitle,
|
||||
@@ -312,10 +317,12 @@ export class PagesStore {
|
||||
}
|
||||
case 'upsert_page': {
|
||||
const { title: pageTitle, actionIds = [] } = payload;
|
||||
const oldPage = this.pages.get()[pageName];
|
||||
this.pages.setKey(pageName, {
|
||||
name: pageName,
|
||||
title: pageTitle,
|
||||
actionIds,
|
||||
actionIds: actionIds || oldPage?.actionIds,
|
||||
content: oldPage?.content,
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user