-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(visualizer): paused visualizer behaves weirdly when reaching max …
…blocks (#1202) * fix: colorQueue leak Signed-off-by: Eugene Panteleymonchuk <[email protected]> * fix: colorQueue on pause. Prevent overwrite colors by new block. Signed-off-by: Eugene Panteleymonchuk <[email protected]> * fix: colorQueue on play again. Checkpoint. Signed-off-by: Eugene Panteleymonchuk <[email protected]> * fix: colorQueue, check conditions in loop. Signed-off-by: Eugene Panteleymonchuk <[email protected]> * fix: update block metadata when slot finalized. Signed-off-by: Eugene Panteleymonchuk <[email protected]> * fix: update all active blocks when unpause. Signed-off-by: Eugene Panteleymonchuk <[email protected]> --------- Signed-off-by: Eugene Panteleymonchuk <[email protected]> Co-authored-by: Begoña Álvarez de la Cruz <[email protected]>
- Loading branch information
1 parent
82b4c21
commit cfb5f7d
Showing
5 changed files
with
98 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
client/src/features/visualizer-threejs/hooks/usePlayPause.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { useTangleStore, useConfigStore, IAddToColorQueueBulkItem } from "~features/visualizer-threejs/store"; | ||
|
||
const usePlayPause = () => { | ||
const isPlaying = useConfigStore((state) => state.isPlaying); | ||
const setIsPlaying = useConfigStore((state) => state.setIsPlaying); | ||
const addToColorQueueBulk = useTangleStore((state) => state.addToColorQueueBulk); | ||
const setVisibleBlockIdsOnPause = useTangleStore((state) => state.setVisibleBlockIdsOnPause); | ||
const blockMetadata = useTangleStore((state) => state.blockMetadata); | ||
|
||
const onToggle = () => { | ||
if (isPlaying) { | ||
const visibleBlockIds = blockMetadata.keys(); | ||
setIsPlaying(false); | ||
setVisibleBlockIdsOnPause([...visibleBlockIds]); | ||
} else { | ||
const colorsQueue: IAddToColorQueueBulkItem[] = []; | ||
blockMetadata.forEach((metadata, id) => { | ||
if (metadata.treeColor) { | ||
colorsQueue.push({ id, color: metadata.treeColor }); | ||
} | ||
}); | ||
addToColorQueueBulk(colorsQueue); | ||
setVisibleBlockIdsOnPause(undefined); | ||
setIsPlaying(true); | ||
} | ||
}; | ||
|
||
return { | ||
onToggle, | ||
}; | ||
}; | ||
|
||
export default usePlayPause; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters