Skip to content

Commit 8874c68

Browse files
authored
Merge pull request ChatGPTNextWeb#1728 from yanCode/fix/steps
fix: bug ChatGPTNextWeb#1727
2 parents 58e1997 + e84da30 commit 8874c68

File tree

2 files changed

+61
-68
lines changed

2 files changed

+61
-68
lines changed

app/components/exporter.tsx

+57-64
Original file line numberDiff line numberDiff line change
@@ -152,71 +152,64 @@ export function MessageExporter() {
152152
index={currentStepIndex}
153153
onStepChange={setCurrentStepIndex}
154154
/>
155-
156-
<div className={styles["message-exporter-body"]}>
157-
{currentStep.value === "select" && (
158-
<>
159-
<List>
160-
<ListItem
161-
title={Locale.Export.Format.Title}
162-
subTitle={Locale.Export.Format.SubTitle}
163-
>
164-
<Select
165-
value={exportConfig.format}
166-
onChange={(e) =>
167-
updateExportConfig(
168-
(config) =>
169-
(config.format = e.currentTarget.value as ExportFormat),
170-
)
171-
}
172-
>
173-
{formats.map((f) => (
174-
<option key={f} value={f}>
175-
{f}
176-
</option>
177-
))}
178-
</Select>
179-
</ListItem>
180-
<ListItem
181-
title={Locale.Export.IncludeContext.Title}
182-
subTitle={Locale.Export.IncludeContext.SubTitle}
183-
>
184-
<input
185-
type="checkbox"
186-
checked={exportConfig.includeContext}
187-
onChange={(e) => {
188-
updateExportConfig(
189-
(config) =>
190-
(config.includeContext = e.currentTarget.checked),
191-
);
192-
}}
193-
></input>
194-
</ListItem>
195-
</List>
196-
<MessageSelector
197-
selection={selection}
198-
updateSelection={updateSelection}
199-
defaultSelectAll
200-
/>
201-
</>
202-
)}
203-
204-
{currentStep.value === "preview" && (
205-
<>
206-
{exportConfig.format === "text" ? (
207-
<MarkdownPreviewer
208-
messages={selectedMessages}
209-
topic={session.topic}
210-
/>
211-
) : (
212-
<ImagePreviewer
213-
messages={selectedMessages}
214-
topic={session.topic}
215-
/>
216-
)}
217-
</>
218-
)}
155+
<div
156+
className={styles["message-exporter-body"]}
157+
style={currentStep.value !== "select" ? { display: "none" } : {}}
158+
>
159+
<List>
160+
<ListItem
161+
title={Locale.Export.Format.Title}
162+
subTitle={Locale.Export.Format.SubTitle}
163+
>
164+
<Select
165+
value={exportConfig.format}
166+
onChange={(e) =>
167+
updateExportConfig(
168+
(config) =>
169+
(config.format = e.currentTarget.value as ExportFormat),
170+
)
171+
}
172+
>
173+
{formats.map((f) => (
174+
<option key={f} value={f}>
175+
{f}
176+
</option>
177+
))}
178+
</Select>
179+
</ListItem>
180+
<ListItem
181+
title={Locale.Export.IncludeContext.Title}
182+
subTitle={Locale.Export.IncludeContext.SubTitle}
183+
>
184+
<input
185+
type="checkbox"
186+
checked={exportConfig.includeContext}
187+
onChange={(e) => {
188+
updateExportConfig(
189+
(config) => (config.includeContext = e.currentTarget.checked),
190+
);
191+
}}
192+
></input>
193+
</ListItem>
194+
</List>
195+
<MessageSelector
196+
selection={selection}
197+
updateSelection={updateSelection}
198+
defaultSelectAll
199+
/>
219200
</div>
201+
{currentStep.value === "preview" && (
202+
<div className={styles["message-exporter-body"]}>
203+
{exportConfig.format === "text" ? (
204+
<MarkdownPreviewer
205+
messages={selectedMessages}
206+
topic={session.topic}
207+
/>
208+
) : (
209+
<ImagePreviewer messages={selectedMessages} topic={session.topic} />
210+
)}
211+
</div>
212+
)}
220213
</>
221214
);
222215
}

app/components/message-selector.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export function MessageSelector(props: {
7575
const isValid = (m: ChatMessage) => m.content && !m.isError && !m.streaming;
7676
const messages = session.messages.filter(
7777
(m, i) =>
78-
m.id && // messsage must has id
78+
m.id && // message must have id
7979
isValid(m) &&
8080
(i >= session.messages.length - 1 || isValid(session.messages[i + 1])),
8181
);
@@ -88,13 +88,13 @@ export function MessageSelector(props: {
8888
return searchInput.length === 0 || searchIds.has(id);
8989
};
9090
const doSearch = (text: string) => {
91-
const searchResuts = new Set<number>();
91+
const searchResults = new Set<number>();
9292
if (text.length > 0) {
9393
messages.forEach((m) =>
94-
m.content.includes(text) ? searchResuts.add(m.id!) : null,
94+
m.content.includes(text) ? searchResults.add(m.id!) : null,
9595
);
9696
}
97-
setSearchIds(searchResuts);
97+
setSearchIds(searchResults);
9898
};
9999

100100
// for range selection

0 commit comments

Comments
 (0)