Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
chore: add loading indicator when generating freezed file (#5978)
Lucas.Xuf7a2d9e58188
diff --git a/frontend/scripts/code_generation/freezed/generate_freezed.sh b/frontend/scripts/code_generation/freezed/generate_freezed.shindex 391aea08b2..abc0126325 100755--- a/frontend/scripts/code_generation/freezed/generate_freezed.sh+++ b/frontend/scripts/code_generation/freezed/generate_freezed.sh@@ -75,6 +75,21 @@ if [ "$exclude_packages" = false ]; thencd ..fi+# Function to display animated loading text+display_loading() {+ local pid=$1+ local delay=0.5+ local spinstr='|/-\'+ while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do+ local temp=${spinstr#?}+ printf " [%c] Generating freezed files..." "$spinstr"+ local spinstr=$temp${spinstr%"$temp"}+ sleep $delay+ printf "\r"+ done+ printf " \r"+}+# Navigate to the appflowy_flutter directory and generate filesecho "🧊 Start generating freezed files (AppFlowy)."@@ -86,13 +101,28 @@ if [ "$skip_pub_packages_get" = false ]; thenfifi+# Start the build_runner in the backgroundif [ "$verbose" = true ]; then- dart run build_runner build -d+ dart run build_runner build -d &else- dart run build_runner build >/dev/null 2>&1+ dart run build_runner build >/dev/null 2>&1 &fi-# Return to the original directory+# Get the PID of the background process+build_pid=$!++# Start the loading animation+display_loading $build_pid &++# Get the PID of the loading animation+loading_pid=$!++# Wait for the build_runner to finish+wait $build_pid++# Clear the line+printf "\r%*s\r" $(($(tput cols))) ""+cd "$original_dir"echo "🧊 Done generating freezed files."