Skip to content

Commit 00082f5

Browse files
Merge pull request #6810 from microsoft/fixes-endgame-202207
Remove status listener in app service file node, AB#1973168
2 parents 02191c0 + e512caf commit 00082f5

File tree

1 file changed

+16
-19
lines changed
  • Utils/azure-toolkit-ide-libs/azure-toolkit-ide-appservice-lib/src/main/java/com/microsoft/azure/toolkit/ide/appservice/file

1 file changed

+16
-19
lines changed

Utils/azure-toolkit-ide-libs/azure-toolkit-ide-appservice-lib/src/main/java/com/microsoft/azure/toolkit/ide/appservice/file/AppServiceFileNode.java

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
import com.microsoft.azure.toolkit.ide.common.component.NodeView;
1010
import com.microsoft.azure.toolkit.lib.appservice.AppServiceAppBase;
1111
import com.microsoft.azure.toolkit.lib.appservice.model.AppServiceFile;
12+
import com.microsoft.azure.toolkit.lib.common.bundle.AzureString;
1213
import com.microsoft.azure.toolkit.lib.common.event.AzureEvent;
1314
import com.microsoft.azure.toolkit.lib.common.event.AzureEventBus;
15+
import com.microsoft.azure.toolkit.lib.common.messager.AzureMessager;
1416
import com.microsoft.azure.toolkit.lib.common.task.AzureTaskManager;
1517
import lombok.Getter;
1618
import lombok.Setter;
@@ -68,26 +70,31 @@ public AppServiceFileNode(@Nonnull AppServiceFile data) {
6870

6971
@Override
7072
public boolean hasChildren() {
71-
return file.getType() == AppServiceFile.Type.DIRECTORY && appService.getFormalStatus().isRunning();
73+
return file.getType() == AppServiceFile.Type.DIRECTORY;
7274
}
7375

7476
@Override
7577
public List<Node<?>> getChildren() {
76-
return file.getType() != AppServiceFile.Type.DIRECTORY ? Collections.emptyList() :
77-
appService.getFilesInDirectory(file.getPath()).stream()
78-
.sorted((first, second) -> first.getType() == second.getType() ?
79-
StringUtils.compare(first.getName(), second.getName()) :
80-
first.getType() == AppServiceFile.Type.DIRECTORY ? -1 : 1)
81-
.map(AppServiceFileNode::new)
82-
.collect(Collectors.toList());
78+
if (file.getType() != AppServiceFile.Type.DIRECTORY) {
79+
return Collections.emptyList();
80+
}
81+
if (!appService.getFormalStatus().isRunning()) {
82+
AzureMessager.getMessager().warning(AzureString.format("Can not list files for app service with status %s", appService.getStatus()));
83+
return Collections.emptyList();
84+
}
85+
return appService.getFilesInDirectory(file.getPath()).stream()
86+
.sorted((first, second) -> first.getType() == second.getType() ?
87+
StringUtils.compare(first.getName(), second.getName()) :
88+
first.getType() == AppServiceFile.Type.DIRECTORY ? -1 : 1)
89+
.map(AppServiceFileNode::new)
90+
.collect(Collectors.toList());
8391
}
8492

8593
static class AppServiceFileLabelView implements NodeView {
8694
@Nonnull
8795
@Getter
8896
private final AppServiceFile file;
8997
private final AzureEventBus.EventListener listener;
90-
private final AzureEventBus.EventListener appStatusListener;
9198

9299
@Nullable
93100
@Setter
@@ -97,19 +104,10 @@ static class AppServiceFileLabelView implements NodeView {
97104
public AppServiceFileLabelView(@Nonnull AppServiceFile file) {
98105
this.file = file;
99106
this.listener = new AzureEventBus.EventListener(this::onEvent);
100-
this.appStatusListener= new AzureEventBus.EventListener(this::onAppStatusChanged);
101107
AzureEventBus.on("resource.refreshed.resource", listener);
102-
AzureEventBus.on("resource.status_changed.resource", appStatusListener);
103108
this.refreshView();
104109
}
105110

106-
private void onAppStatusChanged(AzureEvent event) {
107-
final Object source = event.getSource();
108-
if ((source instanceof AppServiceAppBase && StringUtils.equalsIgnoreCase(((AppServiceAppBase<?, ?, ?>) source).getId(), this.file.getApp().getId()))) {
109-
AzureTaskManager.getInstance().runLater(this::refreshChildren);
110-
}
111-
}
112-
113111
private void onEvent(AzureEvent event) {
114112
final String type = event.getType();
115113
final Object source = event.getSource();
@@ -150,7 +148,6 @@ private static String formatDateTime(@Nullable final String dateTime) {
150148
@Override
151149
public void dispose() {
152150
AzureEventBus.off("resource.refreshed.resource", listener);
153-
AzureEventBus.off("resource.status_changed.resource", appStatusListener);
154151
this.refresher = null;
155152
}
156153
}

0 commit comments

Comments
 (0)