You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by pa...@apache.org on 2022/06/30 20:56:29 UTC

[beam] branch master updated: Do not re-create PlaygroundState (#21950)

This is an automated email from the ASF dual-hosted git repository.

pabloem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 830a030cfb2 Do not re-create PlaygroundState (#21950)
     new fa7d1b5dbd8 Merge pull request #21956 from [Playground] Do not re-create PlaygroundState (#21950)
830a030cfb2 is described below

commit 830a030cfb2a9ae666577f66d5bbad19d3197cfa
Author: Alexey Inkin <al...@akvelon.com>
AuthorDate: Tue Jun 21 12:22:41 2022 +0400

    Do not re-create PlaygroundState (#21950)
---
 .../pages/embedded_playground/embedded_page_providers.dart | 14 +++-----------
 .../playground/components/playground_page_providers.dart   | 12 +++---------
 2 files changed, 6 insertions(+), 20 deletions(-)

diff --git a/playground/frontend/lib/pages/embedded_playground/embedded_page_providers.dart b/playground/frontend/lib/pages/embedded_playground/embedded_page_providers.dart
index 365b0417f2f..dbf497632e5 100644
--- a/playground/frontend/lib/pages/embedded_playground/embedded_page_providers.dart
+++ b/playground/frontend/lib/pages/embedded_playground/embedded_page_providers.dart
@@ -45,18 +45,11 @@ class EmbeddedPageProviders extends StatelessWidget {
 
             if (playground.selectedExample == null) {
               final example = _getEmbeddedExample();
-              final newPlayground = PlaygroundState(
-                codeRepository: kCodeRepository,
-                sdk: playground.sdk,
-                selectedExample: null,
-              );
               _loadExampleData(
                 example,
                 exampleState,
                 playground,
-                newPlayground,
               );
-              return newPlayground;
             }
             return playground;
           },
@@ -76,7 +69,7 @@ class EmbeddedPageProviders extends StatelessWidget {
     return isEditableString == 'true';
   }
 
-  ExampleModel? _getEmbeddedExample() {
+  ExampleModel _getEmbeddedExample() {
     final examplePath = Uri.base.queryParameters[kExampleParam];
 
     return ExampleModel(
@@ -91,7 +84,6 @@ class EmbeddedPageProviders extends StatelessWidget {
     ExampleModel? example,
     ExampleState exampleState,
     PlaygroundState playground,
-    PlaygroundState newPlayground,
   ) {
     if (example == null) {
       return;
@@ -100,7 +92,7 @@ class EmbeddedPageProviders extends StatelessWidget {
     if (example.path.isEmpty) {
       String source = Uri.base.queryParameters[kSourceCode] ?? '';
       example.setSource(source);
-      newPlayground.setExample(example);
+      playground.setExample(example);
     } else {
       exampleState
           .getExample(example.path, playground.sdk)
@@ -108,7 +100,7 @@ class EmbeddedPageProviders extends StatelessWidget {
                 example,
                 playground.sdk,
               ))
-          .then((exampleWithInfo) => newPlayground.setExample(exampleWithInfo));
+          .then((exampleWithInfo) => playground.setExample(exampleWithInfo));
     }
   }
 }
diff --git a/playground/frontend/lib/pages/playground/components/playground_page_providers.dart b/playground/frontend/lib/pages/playground/components/playground_page_providers.dart
index e2455f4f0b1..76156b839eb 100644
--- a/playground/frontend/lib/pages/playground/components/playground_page_providers.dart
+++ b/playground/frontend/lib/pages/playground/components/playground_page_providers.dart
@@ -59,22 +59,16 @@ class PlaygroundPageProviders extends StatelessWidget {
 
             if (playground.selectedExample == null &&
                 !Uri.base.toString().contains(kIsEmbedded)) {
-              final newPlayground = PlaygroundState(
-                codeRepository: kCodeRepository,
-                sdk: playground.sdk,
-                selectedExample: null,
-              );
-              final example = _getExample(exampleState, newPlayground);
+              final example = _getExample(exampleState, playground);
               if (example != null) {
                 exampleState
                     .loadExampleInfo(
                       example,
-                      newPlayground.sdk,
+                      playground.sdk,
                     )
                     .then((exampleWithInfo) =>
-                        newPlayground.setExample(exampleWithInfo));
+                        playground.setExample(exampleWithInfo));
               }
-              return newPlayground;
             }
             return playground;
           },