Skip to content

Commit

Permalink
fix save history from UI
Browse files Browse the repository at this point in the history
  • Loading branch information
chetbox committed Dec 27, 2023
1 parent 40781a3 commit 7f0771f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions hosting/src/components/Canvas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,18 @@ export default class Canvas extends Vue {
public setPixelColor(row: number, column: number, color: Color) {
const xOffsets = row.toString(2).padStart(this.data.canvasDepth, '0');
const yOffsets = column.toString(2).padStart(this.data.canvasDepth, '0');
const canvasRef = this.placeRef.child('canvas');
let pixelRef = canvasRef;
let pixelRef = this.placeRef.child('canvas');
for (let i = 0; i < this.data.canvasDepth; i++) {
pixelRef = pixelRef.child(xOffsets[i] + yOffsets[i]);
}
pixelRef.set(color);
// Save history
const historyRef = canvasRef.child('history');
const historyRef = this.placeRef.child('history');
const historyItemRef = historyRef.push();
historyItemRef.set({
x: row,
y: column,
x: column,
y: row,
value: color,
timestamp: firebase.database.ServerValue.TIMESTAMP,
});
Expand Down

0 comments on commit 7f0771f

Please sign in to comment.