Fix deleting gallery project from trash
@@ -14,6 +14,7 @@ import com.google.appinventor.client.settings.project.ProjectSettings;
import com.google.appinventor.client.tracking.Tracking;
import com.google.appinventor.shared.rpc.project.ProjectNode;
import com.google.appinventor.shared.rpc.project.ProjectRootNode;
+import com.google.appinventor.shared.rpc.project.ProjectServiceAsync;
import com.google.appinventor.shared.rpc.project.UserProject;
import java.util.ArrayList;
@@ -263,28 +264,26 @@ public final class Project {
public void deleteFromTrash() {
Tracking.trackEvent(Tracking.PROJECT_EVENT,
Tracking.PROJECT_ACTION_DELETE_PROJECT_YA, getProjectName());
+ final ProjectServiceAsync projectService = Ode.getInstance().getProjectService();
+ final OdeAsyncCallback<Void> deleteCallback = new OdeAsyncCallback<Void>() {
+ @Override
+ public void onSuccess(Void result) {
+ Ode.getInstance().getProjectManager().removeDeletedProject(getProjectId());
+ }
+ };
if (isPublished()) {
Ode.getInstance().getGalleryService().deleteApp(projectInfo.getGalleryId(),
- new OdeAsyncCallback<Void>(
- // failure message
- MESSAGES.galleryDeleteError()) {
+ new OdeAsyncCallback<Void>(MESSAGES.galleryDeleteError()) {
@Override
public void onSuccess(Void result) {
// need to update gallery list
- GalleryClient gallery = GalleryClient.getInstance();
- gallery.appWasChanged();
+ GalleryClient.getInstance().appWasChanged();
+ // Delete the app
+ projectService.deleteProject(getProjectId(), deleteCallback);
}
});
} else {
- Ode.getInstance().getProjectService().deleteProject(getProjectId(),
- new OdeAsyncCallback<Void>(
- // failure message
- MESSAGES.deleteProjectError()) {
- @Override
- public void onSuccess(Void result) {
- Ode.getInstance().getProjectManager().removeDeletedProject(getProjectId());
- }
- });
+ Ode.getInstance().getProjectService().deleteProject(getProjectId(), deleteCallback);
}
}
