create long hash

This commit is contained in:
Ruben Fiszel
2025-03-28 00:03:27 +01:00
parent ef88a83f56
commit e72ff9cde1
3 changed files with 9 additions and 4 deletions

View File

@@ -16,7 +16,7 @@
import { sendUserToast } from '$lib/toast'
import { openDB, type DBSchema as IDBSchema, type IDBPDatabase } from 'idb'
import { isInitialCode } from '$lib/script_helpers'
import { langToExt } from '$lib/editorUtils'
import { createLongHash, langToExt } from '$lib/editorUtils'
import { scriptLangToEditorLang } from '$lib/scripts'
export let lang: ScriptLang | 'bunnative'
@@ -159,7 +159,7 @@
}
})
let currentChatId: string = crypto.randomUUID()
let currentChatId: string = createLongHash()
let savedChats: Record<
string,
{
@@ -292,7 +292,7 @@
async function saveAndClear() {
await saveChat()
currentChatId = crypto.randomUUID()
currentChatId = createLongHash()
displayMessages = []
messages = [prepareSystemMessage()]
}

View File

@@ -1,3 +1,4 @@
import { createLongHash } from '$lib/editorUtils'
import { type editor as meditor } from 'monaco-editor'
export type VisualChange =
@@ -71,7 +72,7 @@ export function setGlobalCSS(id: string, cssCode: string) {
}
function addInlineGhostText(change: Extract<VisualChange, { type: 'added_inline' }>) {
const cssId = crypto.randomUUID()
const cssId = createLongHash()
const decoration = {
range: {
startLineNumber: change.position.line,

View File

@@ -44,6 +44,10 @@ export function createHash() {
return (Math.random() + 1).toString(36).substring(2)
}
export function createLongHash() {
return Math.random().toString(36).substring(2) + Math.random().toString(36).substring(2)
}
export function langToExt(lang: string): string {
switch (lang) {
case 'javascript':