From 35448395b6f2a2d610233f45af1ea69ad1242a4a Mon Sep 17 00:00:00 2001 From: divyanshu_Kumar <154233802+d1vyanshu-kumar@users.noreply.github.com> Date: Tue, 14 Jan 2025 18:33:25 +0530 Subject: [PATCH] Solved Auto-loading project from Trash #3208 --- .../src/com/google/appinventor/client/Ode.java | 13 +++++++++++-- .../client/explorer/project/ProjectManager.java | 5 +++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/appinventor/appengine/src/com/google/appinventor/client/Ode.java b/appinventor/appengine/src/com/google/appinventor/client/Ode.java index ca858387ba9..e1f742fc36b 100644 --- a/appinventor/appengine/src/com/google/appinventor/client/Ode.java +++ b/appinventor/appengine/src/com/google/appinventor/client/Ode.java @@ -554,8 +554,17 @@ private void openPreviousProject() { return; } final String value = userSettings.getSettings(SettingsConstants.USER_GENERAL_SETTINGS) - .getPropertyValue(SettingsConstants.GENERAL_SETTINGS_CURRENT_PROJECT_ID); - openProject(value); + .getPropertyValue(SettingsConstants.GENERAL_SETTINGS_CURRENT_PROJECT_ID); + if (value.isEmpty()) { + switchToProjectsView(); + return; + } + long projectId = Long.parseLong(value); + if (projectManager.isProjectInTrash(projectId)) { + switchToProjectsView(); + } else { + openProject(value); + } } private void openProject(String projectIdString) { diff --git a/appinventor/appengine/src/com/google/appinventor/client/explorer/project/ProjectManager.java b/appinventor/appengine/src/com/google/appinventor/client/explorer/project/ProjectManager.java index 78fc69072de..28605963018 100644 --- a/appinventor/appengine/src/com/google/appinventor/client/explorer/project/ProjectManager.java +++ b/appinventor/appengine/src/com/google/appinventor/client/explorer/project/ProjectManager.java @@ -239,4 +239,9 @@ private void fireProjectDeleted(Project project) { listener.onProjectDeleted(project); } } + + public boolean isProjectInTrash(long projectId) { + Project project = projectsMap.get(projectId); + return project != null && project.isInTrash(); + } }