mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-18 12:11:35 +00:00
Fixes for API chatroom initialization
This commit is contained in:
parent
edc9659beb
commit
c2fb0e27a0
@ -48,7 +48,17 @@ class ChatView(viewsets.ViewSet):
|
||||
)
|
||||
|
||||
queryset = Message.objects.filter(order=order, index__gt=offset)
|
||||
chatroom = ChatRoom.objects.get(order=order)
|
||||
chatroom, created = ChatRoom.objects.get_or_create(
|
||||
id=order_id,
|
||||
order=order,
|
||||
room_group_name=f"chat_order_{order_id}",
|
||||
defaults={
|
||||
"maker": order.maker,
|
||||
"maker_connected": order.maker == request.user,
|
||||
"taker": order.taker,
|
||||
"taker_connected": order.taker == request.user,
|
||||
},
|
||||
)
|
||||
|
||||
# Poor idea: is_peer_connected() mockup. Update connection status based on last time a GET request was sent
|
||||
if chatroom.maker == request.user:
|
||||
@ -171,7 +181,7 @@ class ChatView(viewsets.ViewSet):
|
||||
|
||||
# if offset is given, reply with messages
|
||||
offset = serializer.data.get("offset", None)
|
||||
if offset:
|
||||
if offset or offset == 0:
|
||||
queryset = Message.objects.filter(order=order, index__gt=offset)
|
||||
messages = []
|
||||
for message in queryset:
|
||||
|
@ -333,7 +333,13 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => {
|
||||
appear={slideDirection.in != undefined}
|
||||
>
|
||||
<div>
|
||||
<OrderPage theme={theme} history={history} {...props} baseUrl={baseUrl} />
|
||||
<OrderPage
|
||||
theme={theme}
|
||||
history={history}
|
||||
{...props}
|
||||
setPage={setPage}
|
||||
baseUrl={baseUrl}
|
||||
/>
|
||||
</div>
|
||||
</Slide>
|
||||
)}
|
||||
|
@ -514,11 +514,11 @@ class OrderPage extends Component {
|
||||
};
|
||||
|
||||
tokenDialog = () => {
|
||||
return systemClient.getCookie('robot_token') ? (
|
||||
return systemClient.getItem('robot_token') ? (
|
||||
<StoreTokenDialog
|
||||
open={this.state.openStoreToken}
|
||||
onClose={() => this.setState({ openStoreToken: false })}
|
||||
onClickCopy={() => systemClient.copyToClipboard(systemClient.getCookie('robot_token'))}
|
||||
onClickCopy={() => systemClient.copyToClipboard(systemClient.getItem('robot_token'))}
|
||||
copyIconColor={this.props.copiedToken ? 'inherit' : 'primary'}
|
||||
onClickBack={() => this.setState({ openStoreToken: false })}
|
||||
onClickDone={() =>
|
||||
@ -532,6 +532,7 @@ class OrderPage extends Component {
|
||||
<NoRobotDialog
|
||||
open={this.state.openStoreToken}
|
||||
onClose={() => this.setState({ openStoreToken: false })}
|
||||
setPage={this.props.setPage}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
@ -169,12 +169,14 @@ const EncryptedTurtleChat: React.FC<Props> = ({
|
||||
apiClient
|
||||
.post(baseUrl, `/api/chat`, {
|
||||
PGP_message: value,
|
||||
offset: lastIndex
|
||||
offset: lastIndex,
|
||||
})
|
||||
.then((response) => {
|
||||
if (response) {
|
||||
if (response) {
|
||||
setPeerConnected(response.peer_connected);
|
||||
setServerMessages(response.messages);
|
||||
if (response.messages) {
|
||||
setServerMessages(response.messages);
|
||||
}
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
@ -192,12 +194,14 @@ const EncryptedTurtleChat: React.FC<Props> = ({
|
||||
.post(baseUrl, `/api/chat/`, {
|
||||
PGP_message: encryptedMessage.toString().split('\n').join('\\'),
|
||||
order_id: orderId,
|
||||
offset: lastIndex
|
||||
offset: lastIndex,
|
||||
})
|
||||
.then((response) => {
|
||||
if (response) {
|
||||
if (response) {
|
||||
setPeerConnected(response.peer_connected);
|
||||
setServerMessages(response.messages);
|
||||
if (response.messages) {
|
||||
setServerMessages(response.messages);
|
||||
}
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
|
@ -74,7 +74,7 @@ class TradeBox extends Component {
|
||||
badInvoice: false,
|
||||
badAddress: false,
|
||||
badStatement: false,
|
||||
turtleMode: window.ReactNativeWebView !== undefined
|
||||
turtleMode: window.ReactNativeWebView !== undefined,
|
||||
};
|
||||
}
|
||||
|
||||
@ -1245,7 +1245,7 @@ class TradeBox extends Component {
|
||||
return (
|
||||
<Grid container spacing={1}>
|
||||
<Grid item xs={12} align='center'>
|
||||
<Button
|
||||
<LoadingButton
|
||||
loading={this.state.loadingButtonFiatSent}
|
||||
defaultValue='confirm'
|
||||
variant='contained'
|
||||
@ -1265,7 +1265,7 @@ class TradeBox extends Component {
|
||||
),
|
||||
),
|
||||
})}
|
||||
</Button>
|
||||
</LoadingButton>
|
||||
</Grid>
|
||||
</Grid>
|
||||
);
|
||||
@ -1467,7 +1467,9 @@ class TradeBox extends Component {
|
||||
</div>
|
||||
</Tooltip>
|
||||
</div>
|
||||
) : <></>}
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
<Typography variant='subtitle1'>
|
||||
<b>
|
||||
{' '}
|
||||
|
Loading…
Reference in New Issue
Block a user