Skip to content

Commit

Permalink
fix broken openhub action + actions type as any (#126)
Browse files Browse the repository at this point in the history
* fix broken openhub action + actons type as any

* remove type check

* remove unused lambda
  • Loading branch information
dimacodota authored Mar 2, 2021
1 parent 436a574 commit c8cefcc
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package com.tabnine.binary.requests.notifications

data class NotificationOptions(
var key: String? = null,
var actions: List<String>? = null
var actions: List<Any>? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ data class HoverActionRequest(
val message: String?,
@SerializedName("notification_type")
val notificationType: String?,
val actions: Array<String>,
val actions: Array<Any>,
) : BinaryRequest<EmptyResponse> {
override fun response(): Class<EmptyResponse> {
return EmptyResponse::class.java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ data class NotificationActionRequest(
var selected: String?,
var message: String?,
@SerializedName("notification_type") var notificationType: String?,
var actions: List<String>?
var actions: List<Any>?
) : BinaryRequest<EmptyResponse> {
override fun response(): Class<EmptyResponse> {
return EmptyResponse::class.java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.tabnine.binary.requests.statusBar
import com.tabnine.binary.BinaryRequest
import com.tabnine.binary.requests.EmptyResponse

data class StatusBarPromotionActionRequest(var id: String?, var selected: String?, var actions: List<String>?) :
data class StatusBarPromotionActionRequest(var id: String?, var selected: String?, var actions: List<Any>?) :
BinaryRequest<EmptyResponse> {
override fun response(): Class<EmptyResponse> {
return EmptyResponse::class.java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.tabnine.binary.BinaryResponse
data class StatusBarPromotionBinaryResponse(
val id: String?,
val message: String?,
val actions: List<String>?,
val actions: List<Any>?,
@SerializedName("notification_type") val notificationType: String?,
val state: Object?,
@SerializedName("duration_seconds") val durationSeconds: Long?,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/tabnine/general/NotificationOption.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package com.tabnine.general

data class NotificationOption(
val key: String,
val actions: Array<String>
val actions: Array<Any>
)
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class BinaryNotificationsLifecycle(
o.actions
)
)
if (o.actions?.contains(OPEN_HUB_ACTION) ?: false) {
if (o.actions?.any { it == OPEN_HUB_ACTION } == true) {
actionVisitor.openHub()
}
notification.expire()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ public Consumer<MouseEvent> getClickConsumer() {
if (!e.isPopupTrigger() && MouseEvent.BUTTON1 == e.getButton()) {
binaryRequestFacade.executeRequest(new StatusBarPromotionActionRequest(
component.getId(), component.getText(), component.getActions()));
clearMessage();
if (component.getActions().contains(StaticConfig.OPEN_HUB_ACTION)) {
List<Object> actions = component.getActions();
if(actions != null && actions.stream().anyMatch(StaticConfig.OPEN_HUB_ACTION::equals)){
actionVisitor.openHub();
}
clearMessage();
}
};
}
Expand All @@ -108,7 +109,7 @@ public static class StatusBarPromotionComponent extends TextPanel.WithIconAndArr
@Nullable
private String id;
@Nullable
private List<String> actions;
private List<Object> actions;
@Nullable
private String notificationType;

Expand All @@ -120,11 +121,11 @@ public void setId(@Nullable String id) {
this.id = id;
}

public @Nullable List<String> getActions() {
public @Nullable List<Object> getActions() {
return actions;
}

public void setActions(@Nullable List<String> actions) {
public void setActions(@Nullable List<Object> actions) {
this.actions = actions;
}

Expand Down

0 comments on commit c8cefcc

Please sign in to comment.