mirror of
https://github.com/RoboSats/robosats.git
synced 2025-02-20 12:19:00 +00:00
Fix last order
This commit is contained in:
parent
7c06c229b4
commit
88833a5a10
@ -46,9 +46,13 @@ const OrderPage = (): JSX.Element => {
|
||||
} else {
|
||||
coordinator
|
||||
.fetchOrder(Number(params.orderId) ?? null, garage.getRobot())
|
||||
.then((response) => {
|
||||
setCurrentOrder(response);
|
||||
garage.updateOrder(response as Order);
|
||||
.then((order) => {
|
||||
if (order?.bad_request !== undefined) {
|
||||
setBadOrder(order.bad_request);
|
||||
} else {
|
||||
setCurrentOrder(order);
|
||||
garage.updateOrder(order as Order);
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
@ -57,8 +61,12 @@ const OrderPage = (): JSX.Element => {
|
||||
} else {
|
||||
coordinator
|
||||
.fetchOrder(Number(params.orderId) ?? null, garage.getRobot())
|
||||
.then((response) => {
|
||||
setCurrentOrder(response);
|
||||
.then((order) => {
|
||||
if (order?.bad_request !== undefined) {
|
||||
setBadOrder(order.bad_request);
|
||||
} else {
|
||||
setCurrentOrder(order);
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
|
@ -170,13 +170,13 @@ const RobotProfile = ({
|
||||
<Button
|
||||
onClick={() => {
|
||||
navigate(
|
||||
`/order/${String(garage.getRobot()?.shortAlias)}/${String(
|
||||
garage.getRobot()?.lastOrderId,
|
||||
`/order/${String(garage.getSlot().lastOrderShortAlias)}/${String(
|
||||
garage.getSlot().lastOrderId,
|
||||
)}`,
|
||||
);
|
||||
}}
|
||||
>
|
||||
{t('Last order #{{orderID}}', { orderID: garage.getRobot().lastOrderId })}
|
||||
{t('Last order #{{orderID}}', { orderID: garage.getSlot().lastOrderId })}
|
||||
</Button>
|
||||
</Grid>
|
||||
<Grid item>
|
||||
|
@ -68,11 +68,11 @@ const RobotAvatar: React.FC<Props> = ({
|
||||
setNicknameReady(true);
|
||||
} else if (focusedCoordinator != null) {
|
||||
setNicknameReady(true);
|
||||
const { url } = federation
|
||||
const { url, basePath } = federation
|
||||
.getCoordinator(focusedCoordinator)
|
||||
.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl);
|
||||
void apiClient
|
||||
.fileImageUrl(url, `${path}${nickname}${small ? '.small' : ''}.webp`)
|
||||
.fileImageUrl(url + basePath, `${path}${nickname}${small ? '.small' : ''}.webp`)
|
||||
.then(setAvatarSrc);
|
||||
}
|
||||
} else {
|
||||
|
@ -82,11 +82,11 @@ const EncryptedTurtleChat: React.FC<Props> = ({
|
||||
}, [chatOffset]);
|
||||
|
||||
const loadMessages: () => void = () => {
|
||||
const { url } = federation
|
||||
const { url, basePath } = federation
|
||||
.getCoordinator(focusedCoordinator)
|
||||
.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl);
|
||||
apiClient
|
||||
.get(url, `/api/chat/?order_id=${orderId}&offset=${lastIndex}`, {
|
||||
.get(url + basePath, `/api/chat/?order_id=${orderId}&offset=${lastIndex}`, {
|
||||
tokenSHA256: robot.tokenSHA256,
|
||||
})
|
||||
.then((results: any) => {
|
||||
@ -177,12 +177,12 @@ const EncryptedTurtleChat: React.FC<Props> = ({
|
||||
}
|
||||
// If input string contains '#' send unencrypted and unlogged message
|
||||
else if (value.substring(0, 1) === '#') {
|
||||
const { url } = federation
|
||||
const { url, basePath } = federation
|
||||
.getCoordinator(focusedCoordinator)
|
||||
.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl);
|
||||
apiClient
|
||||
.post(
|
||||
url,
|
||||
url + basePath,
|
||||
`/api/chat/`,
|
||||
{
|
||||
PGP_message: value,
|
||||
@ -210,12 +210,12 @@ const EncryptedTurtleChat: React.FC<Props> = ({
|
||||
setLastSent(value);
|
||||
encryptMessage(value, robot.pubKey, peerPubKey, robot.encPrivKey, robot.token)
|
||||
.then((encryptedMessage) => {
|
||||
const { url } = federation
|
||||
const { url, basePath } = federation
|
||||
.getCoordinator(focusedCoordinator)
|
||||
.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl);
|
||||
apiClient
|
||||
.post(
|
||||
url,
|
||||
url + basePath,
|
||||
`/api/chat/`,
|
||||
{
|
||||
PGP_message: String(encryptedMessage).split('\n').join('\\'),
|
||||
|
@ -165,12 +165,12 @@ const TradeBox = ({
|
||||
statement,
|
||||
rating,
|
||||
}: SubmitActionProps): void {
|
||||
const { url } = federation
|
||||
const { url, basePath } = federation
|
||||
.getCoordinator(currentOrder.shortAlias)
|
||||
.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl);
|
||||
void apiClient
|
||||
.post(
|
||||
url,
|
||||
url + basePath,
|
||||
`/api/order/?order_id=${Number(currentOrder.id)}`,
|
||||
{
|
||||
action,
|
||||
|
@ -112,13 +112,17 @@ class Garage {
|
||||
const robot = this.getSlot(index).robot;
|
||||
if (robot != null) {
|
||||
robot.update(attributes);
|
||||
if (attributes.activeOrderId != null) {
|
||||
this.slots[index].activeOrderId = attributes.activeOrderId;
|
||||
this.slots[index].activeOrderShortAlias = attributes.shortAlias;
|
||||
}
|
||||
if (attributes.lastOrderId != null) {
|
||||
if (attributes.lastOrderId && attributes.lastOrderId != null) {
|
||||
this.slots[index].lastOrderId = attributes.lastOrderId;
|
||||
this.slots[index].lastOrderShortAlias = attributes.shortAlias;
|
||||
if (attributes.lastOrderId === this.slots[index].activeOrderId) {
|
||||
this.slots[index].activeOrderId = null;
|
||||
this.slots[index].activeOrderShortAlias = null;
|
||||
}
|
||||
}
|
||||
if (attributes.activeOrderId && attributes.activeOrderId != null) {
|
||||
this.slots[index].activeOrderId = attributes.activeOrderId;
|
||||
this.slots[index].activeOrderShortAlias = attributes.shortAlias;
|
||||
}
|
||||
this.triggerHook('onRobotUpdate');
|
||||
this.save();
|
||||
|
@ -105,6 +105,7 @@ export interface Order {
|
||||
address: string;
|
||||
network: 'mainnet' | 'testnet';
|
||||
shortAlias: string;
|
||||
bad_request?: string;
|
||||
}
|
||||
|
||||
export const defaultOrder: Order = {
|
||||
|
@ -39,7 +39,6 @@ class Robot {
|
||||
public last_login: string = '';
|
||||
public copiedToken: boolean = false;
|
||||
public avatarLoaded: boolean = false;
|
||||
public shortAlias: string = '';
|
||||
|
||||
update = (attributes: Record<string, any>): void => {
|
||||
Object.assign(this, attributes);
|
||||
|
Loading…
Reference in New Issue
Block a user