show popup for error notifications sent through notification service

This commit is contained in:
woodser 2023-02-10 10:48:54 -05:00
parent 88f0ad543a
commit e2a8dc702b
9 changed files with 59 additions and 17 deletions

View file

@ -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);
}

View file

@ -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());
}
}

View 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);
}

View file

@ -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());

View file

@ -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);

View file

@ -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;