mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-18 12:11:35 +00:00
CR
This commit is contained in:
parent
09776e9c8f
commit
605a3b69a1
@ -18,7 +18,7 @@ class ChatSerializer(serializers.ModelSerializer):
|
||||
class PostMessageSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Message
|
||||
fields = ("PGP_message", "order_id", "offset")
|
||||
fields = ("PGP_message", "order", "offset")
|
||||
depth = 0
|
||||
|
||||
offset = serializers.IntegerField(
|
||||
|
@ -66,7 +66,7 @@ class OrderPage extends Component {
|
||||
openStoreToken: false,
|
||||
tabValue: 1,
|
||||
orderId: this.props.match.params.orderId,
|
||||
chat_offset: 0,
|
||||
chatOffset: 0,
|
||||
};
|
||||
|
||||
// Refresh delays according to Order status
|
||||
@ -110,7 +110,7 @@ class OrderPage extends Component {
|
||||
currencyCode: this.getCurrencyCode(newStateVars.currency),
|
||||
penalty: newStateVars.penalty, // in case penalty time has finished, it goes back to null
|
||||
invoice_expired: newStateVars.invoice_expired, // in case invoice had expired, it goes back to null when it is valid again
|
||||
chat_offset: this.state.chat_offset + newStateVars?.chat?.messages.length,
|
||||
chatOffset: this.state.chatOffset + (newStateVars?.chat?.messages.length ?? 0),
|
||||
};
|
||||
|
||||
const completeStateVars = Object.assign({}, newStateVars, otherStateVars);
|
||||
@ -121,7 +121,7 @@ class OrderPage extends Component {
|
||||
this.setState({ orderId: id });
|
||||
|
||||
apiClient
|
||||
.get('/api/order/?order_id=' + id + '&offset=' + this.state.chat_offset)
|
||||
.get('/api/order/?order_id=' + id + '&offset=' + this.state.chatOffset)
|
||||
.then(this.orderDetailsReceived);
|
||||
};
|
||||
|
||||
|
@ -70,16 +70,16 @@ const EncryptedTurtleChat: React.FC<Props> = ({
|
||||
}, [serverMessages, peerPubKey]);
|
||||
|
||||
useEffect(() => {
|
||||
if (chatOffset > lastIndex) {
|
||||
if (chatOffset === 0 || chatOffset > lastIndex) {
|
||||
loadMessages();
|
||||
}
|
||||
}, [chatOffset]);
|
||||
|
||||
const loadMessages: () => void = () => {
|
||||
apiClient.get(`/api/chat?order_id=${orderId}&offset=${lastIndex}`).then((results: any) => {
|
||||
apiClient.get(`/api/chat/?order_id=${orderId}&offset=${lastIndex}`).then((results: any) => {
|
||||
if (results) {
|
||||
setPeerConnected(results.peer_connected);
|
||||
setPeerPubKey(results.peer_public_key);
|
||||
setPeerPubKey(results.peer_pubkey.split('\\').join('\n'));
|
||||
setServerMessages(results.messages);
|
||||
}
|
||||
});
|
||||
@ -181,8 +181,9 @@ const EncryptedTurtleChat: React.FC<Props> = ({
|
||||
encryptMessage(value, ownPubKey, peerPubKey, ownEncPrivKey, token).then(
|
||||
(encryptedMessage) => {
|
||||
apiClient
|
||||
.post(`/api/chat`, {
|
||||
.post(`/api/chat/`, {
|
||||
PGP_message: encryptedMessage.toString().split('\n').join('\\'),
|
||||
order: orderId,
|
||||
})
|
||||
.finally(() => {
|
||||
setWaitingEcho(false);
|
@ -1,6 +1,6 @@
|
||||
import React, { useState } from 'react';
|
||||
import EncryptedSocketChat from './EncryptedSocketChat';
|
||||
import EncryptedTrutleChat from './EncryptedTrutleChat';
|
||||
import EncryptedTurtleChat from './EncryptedTurtleChat';
|
||||
|
||||
interface Props {
|
||||
turtleMode: boolean;
|
||||
@ -35,7 +35,7 @@ const EncryptedChat: React.FC<Props> = ({
|
||||
const [messages, setMessages] = useState<EncryptedChatMessage[]>([]);
|
||||
|
||||
return turtleMode ? (
|
||||
<EncryptedTrutleChat
|
||||
<EncryptedTurtleChat
|
||||
messages={messages}
|
||||
setMessages={setMessages}
|
||||
orderId={orderId}
|
||||
|
@ -75,7 +75,7 @@ class TradeBox extends Component {
|
||||
badInvoice: false,
|
||||
badAddress: false,
|
||||
badStatement: false,
|
||||
turtle_mode: false,
|
||||
turtleMode: true,
|
||||
};
|
||||
}
|
||||
|
||||
@ -1458,8 +1458,8 @@ class TradeBox extends Component {
|
||||
<Switch
|
||||
size='small'
|
||||
disabled={false}
|
||||
checked={this.state.turtle_mode}
|
||||
onChange={() => this.setState({ turtle_mode: !this.state.turtle_mode })}
|
||||
checked={this.state.turtleMode}
|
||||
onChange={() => this.setState({ turtleMode: !this.state.turtleMode })}
|
||||
/>
|
||||
<WifiTetheringErrorIcon sx={{ color: 'text.secondary' }} />
|
||||
</div>
|
||||
@ -1497,8 +1497,8 @@ class TradeBox extends Component {
|
||||
</Grid>
|
||||
|
||||
<EncryptedChat
|
||||
turtleMode={this.state.turtle_mode}
|
||||
chatOffset={this.props.data.chat_offset}
|
||||
turtleMode={this.state.turtleMode}
|
||||
chatOffset={this.props.data.chatOffset}
|
||||
orderId={this.props.data.id}
|
||||
takerNick={this.props.data.taker_nick}
|
||||
makerNick={this.props.data.maker_nick}
|
||||
|
@ -15,7 +15,7 @@ services:
|
||||
environment:
|
||||
TOR_PROXY_IP: 127.0.0.1
|
||||
TOR_PROXY_PORT: 9050
|
||||
ROBOSATS_ONION: robosats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion
|
||||
ROBOSATS_ONION: robotestagw3dcxmd66r4rgksb4nmmr43fh77bzn2ia2eucduyeafnyd.onion
|
||||
network_mode: service:tor
|
||||
volumes:
|
||||
- ../frontend/static:/usr/src/robosats/static
|
||||
|
Loading…
Reference in New Issue
Block a user