Skip to content

Commit

Permalink
feat: add delay to image processing to reduce UI blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-i committed Jan 24, 2024
1 parent 3c12bfb commit c8864b7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/lib/views/widgets/paint_window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ class PaintWindowState extends State<PaintWindow> {
// Convert points to a suitable format and call OpenAI method
// For example, you might convert points to an image and then to base64
//String imageBase64 = await convertToBase64Jpeg(points);

if (drawingImage != null) {
// Introduce a delay before executing the code
await Future.delayed(const Duration(milliseconds: 800));
}
String imageBase64 =
await Utils.convertToBase64JpegWeb(points, drawingImage, width, height);

Expand Down Expand Up @@ -300,7 +305,9 @@ class PaintWindowState extends State<PaintWindow> {
),
),
actions: <Widget>[
if (isLoading)
if (isLoading && drawingImage != null)
const Text('Loading...')
else if (isLoading)
const CircularProgressIndicator()
else
TextButton(
Expand Down

0 comments on commit c8864b7

Please sign in to comment.