mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-12-22 19:49:32 +00:00
show popup for error notifications sent through notification service
This commit is contained in:
parent
88f0ad543a
commit
e2a8dc702b
9 changed files with 59 additions and 17 deletions
|
@ -67,7 +67,6 @@ import java.util.concurrent.TimeoutException;
|
|||
import java.util.function.Consumer;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
|
@ -346,10 +345,6 @@ public class CoreApi {
|
|||
// Notifications
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public interface NotificationListener {
|
||||
void onMessage(@NonNull NotificationMessage message);
|
||||
}
|
||||
|
||||
public void addNotificationListener(NotificationListener listener) {
|
||||
notificationService.addListener(listener);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package bisq.core.api;
|
||||
|
||||
import bisq.core.api.CoreApi.NotificationListener;
|
||||
import bisq.core.api.model.TradeInfo;
|
||||
import bisq.core.trade.Trade;
|
||||
import bisq.core.support.messages.ChatMessage;
|
||||
|
@ -55,7 +54,8 @@ public class CoreNotificationService {
|
|||
.setTrade(TradeInfo.toTradeInfo(trade).toProtoMessage())
|
||||
.setTimestamp(System.currentTimeMillis())
|
||||
.setTitle(title)
|
||||
.setMessage(message).build());
|
||||
.setMessage(message)
|
||||
.build());
|
||||
}
|
||||
|
||||
public void sendChatNotification(ChatMessage chatMessage) {
|
||||
|
@ -65,4 +65,13 @@ public class CoreNotificationService {
|
|||
.setChatMessage(chatMessage.toProtoChatMessageBuilder())
|
||||
.build());
|
||||
}
|
||||
|
||||
public void sendErrorNotification(String title, String errorMessage) {
|
||||
sendNotification(NotificationMessage.newBuilder()
|
||||
.setType(NotificationType.ERROR)
|
||||
.setTimestamp(System.currentTimeMillis())
|
||||
.setTitle(title)
|
||||
.setMessage(errorMessage)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
|
25
core/src/main/java/bisq/core/api/NotificationListener.java
Normal file
25
core/src/main/java/bisq/core/api/NotificationListener.java
Normal file
|
@ -0,0 +1,25 @@
|
|||
package bisq.core.api;
|
||||
|
||||
import bisq.proto.grpc.NotificationMessage;
|
||||
import lombok.NonNull;
|
||||
|
||||
/*
|
||||
* This file is part of Haveno.
|
||||
*
|
||||
* Haveno is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Haveno is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Haveno. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
public interface NotificationListener {
|
||||
void onMessage(@NonNull NotificationMessage message);
|
||||
}
|
|
@ -831,6 +831,7 @@ public abstract class Trade implements Tradable, Model {
|
|||
log.warn(e.getMessage());
|
||||
e.printStackTrace();
|
||||
setErrorMessage(e.getMessage());
|
||||
processModel.getTradeManager().getNotificationService().sendErrorNotification("Error", e.getMessage());
|
||||
}
|
||||
} else {
|
||||
log.warn("Multisig wallet to delete for trade {} does not exist", getId());
|
||||
|
|
|
@ -125,6 +125,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
|||
private final KeyRing keyRing;
|
||||
private final CoreAccountService accountService;
|
||||
private final XmrWalletService xmrWalletService;
|
||||
@Getter
|
||||
private final CoreNotificationService notificationService;
|
||||
private final OfferBookService offerBookService;
|
||||
private final OpenOfferManager openOfferManager;
|
||||
|
@ -328,7 +329,6 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
|||
trade.shutDown();
|
||||
} catch (Exception e) {
|
||||
log.warn("Error closing trade subprocess. Was Haveno stopped manually with ctrl+c?");
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
HavenoUtils.executeTasks(tasks);
|
||||
|
|
|
@ -33,7 +33,6 @@ import bisq.core.support.dispute.arbitration.arbitrator.ArbitratorManager;
|
|||
import bisq.core.support.dispute.mediation.mediator.MediatorManager;
|
||||
import bisq.core.support.dispute.messages.DisputeClosedMessage;
|
||||
import bisq.core.support.dispute.refund.refundagent.RefundAgentManager;
|
||||
import bisq.core.trade.MakerTrade;
|
||||
import bisq.core.trade.Trade;
|
||||
import bisq.core.trade.TradeManager;
|
||||
import bisq.core.trade.messages.PaymentReceivedMessage;
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package bisq.daemon.grpc;
|
||||
|
||||
import bisq.core.api.CoreApi;
|
||||
import bisq.core.api.CoreApi.NotificationListener;
|
||||
|
||||
import bisq.core.api.NotificationListener;
|
||||
import bisq.proto.grpc.NotificationMessage;
|
||||
import bisq.proto.grpc.NotificationsGrpc.NotificationsImplBase;
|
||||
import bisq.proto.grpc.RegisterNotificationListenerRequest;
|
||||
|
|
|
@ -19,6 +19,7 @@ package bisq.desktop.main.overlays.notifications;
|
|||
|
||||
import bisq.desktop.Navigation;
|
||||
import bisq.desktop.main.MainView;
|
||||
import bisq.desktop.main.overlays.popups.Popup;
|
||||
import bisq.desktop.main.portfolio.PortfolioView;
|
||||
import bisq.desktop.main.portfolio.pendingtrades.PendingTradesView;
|
||||
import bisq.desktop.main.support.SupportView;
|
||||
|
@ -27,7 +28,9 @@ import bisq.desktop.main.support.dispute.agent.arbitration.ArbitratorView;
|
|||
import bisq.desktop.main.support.dispute.client.arbitration.ArbitrationClientView;
|
||||
import bisq.desktop.main.support.dispute.client.mediation.MediationClientView;
|
||||
import bisq.desktop.main.support.dispute.client.refund.RefundClientView;
|
||||
|
||||
import bisq.proto.grpc.NotificationMessage;
|
||||
import bisq.proto.grpc.NotificationMessage.NotificationType;
|
||||
import bisq.core.api.NotificationListener;
|
||||
import bisq.core.locale.Res;
|
||||
import bisq.core.support.dispute.Dispute;
|
||||
import bisq.core.support.dispute.arbitration.ArbitrationManager;
|
||||
|
@ -58,6 +61,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -165,6 +169,16 @@ public class NotificationCenter {
|
|||
tradePhaseSubscriptionsMap.put(tradeId, tradePhaseSubscription);
|
||||
}
|
||||
);
|
||||
|
||||
// show popup for error notifications
|
||||
tradeManager.getNotificationService().addListener(new NotificationListener() {
|
||||
@Override
|
||||
public void onMessage(@NonNull NotificationMessage message) {
|
||||
if (message.getType() == NotificationType.ERROR) {
|
||||
new Popup().warning(message.getMessage()).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -319,5 +333,4 @@ public class NotificationCenter {
|
|||
notification.show();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -255,10 +255,11 @@ message RegisterNotificationListenerRequest {
|
|||
|
||||
message NotificationMessage {
|
||||
enum NotificationType {
|
||||
APP_INITIALIZED = 0;
|
||||
KEEP_ALIVE = 1;
|
||||
TRADE_UPDATE = 2;
|
||||
CHAT_MESSAGE = 3;
|
||||
ERROR = 0;
|
||||
APP_INITIALIZED = 1;
|
||||
KEEP_ALIVE = 2;
|
||||
TRADE_UPDATE = 3;
|
||||
CHAT_MESSAGE = 4;
|
||||
}
|
||||
|
||||
string id = 1;
|
||||
|
|
Loading…
Reference in a new issue