Skip to content

Commit

Permalink
Include lattice state in server payload
Browse files Browse the repository at this point in the history
Remove file extensions from the load API.

ref #722
  • Loading branch information
frostburn committed Jun 10, 2024
1 parent e7e013c commit dd99135
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/components/ExporterButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const uploadBody = computed(() => {
state: state.toJSON(),
'ji-lattice': jiLattice.toJSON(),
grid: grid.toJSON(),
'edo-cycles': cycles.toJSON(),
'edo-cycles': cycles.toJSON()
},
envelope: makeEnvelope(state.shareStatistics)
})
Expand Down
2 changes: 1 addition & 1 deletion src/stores/edo-cycles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const useCyclesStore = defineStore('edo-cycles', () => {
labelOffset,
showLabels,
valString,
generator,
generator
}

/**
Expand Down
20 changes: 10 additions & 10 deletions src/stores/grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export const useGridStore = defineStore('grid', () => {
gridlines1,
gridlines2,
diagonals1,
diagonals2,
diagonals2
}

/**
Expand All @@ -279,15 +279,15 @@ export const useGridStore = defineStore('grid', () => {
return result
}

/**
* Apply revived state to current state.
* @param data JSON data as an Object instance.
*/
function fromJSON(data: any) {
for (const key in LIVE_STATE) {
LIVE_STATE[key as keyof typeof LIVE_STATE].value = data[key]
/**
* Apply revived state to current state.
* @param data JSON data as an Object instance.
*/
function fromJSON(data: any) {
for (const key in LIVE_STATE) {
LIVE_STATE[key as keyof typeof LIVE_STATE].value = data[key]
}
}
}

return {
// State
Expand All @@ -309,6 +309,6 @@ function fromJSON(data: any) {
autoTonnetz,
// sw-server
toJSON,
fromJSON,
fromJSON
}
})
30 changes: 15 additions & 15 deletions src/stores/ji-lattice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,26 +285,26 @@ export const useJiLatticeStore = defineStore('ji-lattice', () => {
rotation,
drawArrows,
grayExtras,
depth,
depth
}

/**
* Convert live state to a format suitable for storing on the server.
*/
function toJSON() {
const result: any = {
horizontalCoordinates,
verticalCoordinates,
xCoords,
yCoords,
zCoords,
}
for (const [key, value] of Object.entries(LIVE_STATE)) {
result[key] = value.value
}
return result
function toJSON() {
const result: any = {
horizontalCoordinates,
verticalCoordinates,
xCoords,
yCoords,
zCoords
}

for (const [key, value] of Object.entries(LIVE_STATE)) {
result[key] = value.value
}
return result
}

/**
* Apply revived state to current state.
* @param data JSON data as an Object instance.
Expand Down Expand Up @@ -354,6 +354,6 @@ export const useJiLatticeStore = defineStore('ji-lattice', () => {
yaw,
roll,
toJSON,
fromJSON,
fromJSON
}
})
2 changes: 1 addition & 1 deletion src/stores/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const useStateStore = defineStore('state', () => {
* Convert live state to a format suitable for storing on the server.
*/
function toJSON() {
return {latticeType: latticeType.value}
return { latticeType: latticeType.value }
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/views/LoadScaleView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ onMounted(async () => {
} else {
try {
// XXX: Dashes are not filesystem friendly, but that's a problem for sw-server to solve.
// XXX: The api should probably be extensionless now that compression negotation makes sw-server bypassing much harder.
const res = await fetch(new URL(`scale/${id}.json.gz`, API_URL))
const res = await fetch(new URL(`scale/${id}`, API_URL))
if (res.ok) {
text.value = 'Scale loaded. Redirecting...'
const body = await res.text()
Expand Down

0 comments on commit dd99135

Please sign in to comment.