Skip to content

Commit

Permalink
refactor: ensure empty string IDs fall back to the unique ID variant
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 committed Mar 12, 2024
1 parent 65f3ed8 commit 3462797
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Expand Up @@ -331,7 +331,7 @@ watch(
: "variables"
if (props.editingEnvironmentIndex !== "Global") {
editingID.value = workingEnv.value?.id ?? uniqueID()
editingID.value = workingEnv.value?.id || uniqueID()
}
vars.value = pipe(
workingEnv.value?.variables ?? [],
Expand Down
2 changes: 1 addition & 1 deletion packages/hoppscotch-data/src/environment/index.ts
Expand Up @@ -165,7 +165,7 @@ export const translateToNewEnvironment = (x: any): Environment => {
if (x.v && x.v === EnvironmentSchemaVersion) return x

// Legacy
const id = x.id ?? uniqueID()
const id = x.id || uniqueID()
const name = x.name ?? "Untitled"
const variables = (x.variables ?? []).map(translateToNewEnvironmentVariables)

Expand Down
2 changes: 1 addition & 1 deletion packages/hoppscotch-data/src/environment/v/1.ts
Expand Up @@ -30,7 +30,7 @@ export default defineVersion({
const result: z.infer<typeof V1_SCHEMA> = {
...old,
v: 1,
id: old.id ?? uniqueID(),
id: old.id || uniqueID(),
variables: old.variables.map((variable) => {
return {
...variable,
Expand Down

0 comments on commit 3462797

Please sign in to comment.