Skip to content

Commit a0597de

Browse files
committed
GenerateUUID can now generate different IDs in ChatManager.ts
1 parent 25b5f89 commit a0597de

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

app/models/ChatManager.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ export class ChatManager {
99
this.listElement = listElement
1010
this.agentBaseURL = agentBaseURL
1111

12-
this.userId = `user-${ChatManager.generateUUID()}`
13-
this.roomId = `default-room-${ChatManager.generateUUID()}`
12+
this.userId = ChatManager.generateID('xxxxxxx')
13+
this.roomId = `room-${ChatManager.generateID('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx')}`
1414
}
1515

16-
static generateUUID(): string {
17-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
16+
static generateID(template: string): string {
17+
return template.replace(/[xy]/g, (c) => {
1818
const r = Math.random() * 16 | 0
1919
const v = c === 'x' ? r : (r & 0x3 | 0x8)
2020
return v.toString(16)

0 commit comments

Comments
 (0)