Skip to content

Commit 2947fbb

Browse files
Copilothuangyiirene
andcommitted
Fix code review issues - replace deprecated substr() and remove type assertions
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
1 parent 4b2de5a commit 2947fbb

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

apps/playground/src/pages/Studio.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ const StudioToolbarContext = ({
244244

245245
// Inner Component handles state for a specific example
246246
const StudioEditor = ({ exampleId, initialJson, isUserDesign, currentDesignId }: {
247-
exampleId: ExampleKey | 'new',
247+
exampleId: ExampleKey | 'new' | string,
248248
initialJson: string,
249249
isUserDesign?: boolean,
250250
currentDesignId?: string
@@ -608,7 +608,7 @@ export const Studio = () => {
608608
return (
609609
<StudioEditor
610610
key={userDesign.id}
611-
exampleId={userDesign.id as any}
611+
exampleId={userDesign.id}
612612
initialJson={initialCode}
613613
isUserDesign={true}
614614
currentDesignId={userDesign.id}
@@ -622,7 +622,7 @@ export const Studio = () => {
622622
const sharedDesign = designStorage.getSharedDesign(shareId);
623623
if (sharedDesign) {
624624
const initialCode = JSON.stringify(sharedDesign.schema, null, 2);
625-
return <StudioEditor key={shareId} exampleId={sharedDesign.name as any} initialJson={initialCode} />;
625+
return <StudioEditor key={shareId} exampleId={sharedDesign.name} initialJson={initialCode} />;
626626
}
627627
}
628628

apps/playground/src/services/designStorage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,11 @@ class DesignStorageService {
156156

157157
// Private helper methods
158158
private generateId(): string {
159-
return `design_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
159+
return `design_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
160160
}
161161

162162
private generateShareId(): string {
163-
return Math.random().toString(36).substr(2, 12);
163+
return Math.random().toString(36).substring(2, 14);
164164
}
165165

166166
private getSharedDesigns(): Record<string, Design> {

0 commit comments

Comments
 (0)