mirror of
https://github.com/RoboSats/robosats.git
synced 2025-07-18 08:43:14 +00:00
Refresh roboname
This commit is contained in:
@ -90,7 +90,7 @@ const RobotProfile = ({
|
|||||||
sx={{ width: '100%' }}
|
sx={{ width: '100%' }}
|
||||||
>
|
>
|
||||||
<Grid item sx={{ height: '2.3em', position: 'relative' }}>
|
<Grid item sx={{ height: '2.3em', position: 'relative' }}>
|
||||||
{slot?.hashId ? (
|
{slot?.nickname ? (
|
||||||
<Typography align='center' component='h5' variant='h5'>
|
<Typography align='center' component='h5' variant='h5'>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
|
@ -59,7 +59,9 @@ class Garage {
|
|||||||
const rawSlots = JSON.parse(slotsDump);
|
const rawSlots = JSON.parse(slotsDump);
|
||||||
Object.values(rawSlots).forEach((rawSlot: Record<any, any>) => {
|
Object.values(rawSlots).forEach((rawSlot: Record<any, any>) => {
|
||||||
if (rawSlot?.token) {
|
if (rawSlot?.token) {
|
||||||
this.slots[rawSlot.token] = new Slot(rawSlot.token, Object.keys(rawSlot.robots), {});
|
this.slots[rawSlot.token] = new Slot(rawSlot.token, Object.keys(rawSlot.robots), {}, () =>
|
||||||
|
this.triggerHook('onRobotUpdate'),
|
||||||
|
);
|
||||||
|
|
||||||
Object.keys(rawSlot.robots).forEach((shortAlias) => {
|
Object.keys(rawSlot.robots).forEach((shortAlias) => {
|
||||||
const rawRobot = rawSlot.robots[shortAlias];
|
const rawRobot = rawSlot.robots[shortAlias];
|
||||||
@ -113,9 +115,10 @@ class Garage {
|
|||||||
if (!token || !shortAliases) return;
|
if (!token || !shortAliases) return;
|
||||||
|
|
||||||
if (this.getSlot(token) === null) {
|
if (this.getSlot(token) === null) {
|
||||||
this.slots[token] = new Slot(token, shortAliases, attributes);
|
this.slots[token] = new Slot(token, shortAliases, attributes, () =>
|
||||||
|
this.triggerHook('onRobotUpdate'),
|
||||||
|
);
|
||||||
this.save();
|
this.save();
|
||||||
this.triggerHook('onRobotUpdate');
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,13 +3,19 @@ import { Robot, type Order } from '.';
|
|||||||
import { roboidentitiesClient } from '../services/Roboidentities/Web';
|
import { roboidentitiesClient } from '../services/Roboidentities/Web';
|
||||||
|
|
||||||
class Slot {
|
class Slot {
|
||||||
constructor(token: string, shortAliases: string[], robotAttributes: Record<any, any>) {
|
constructor(
|
||||||
|
token: string,
|
||||||
|
shortAliases: string[],
|
||||||
|
robotAttributes: Record<any, any>,
|
||||||
|
onRobotUpdate: () => void,
|
||||||
|
) {
|
||||||
this.token = token;
|
this.token = token;
|
||||||
|
|
||||||
this.hashId = sha256(sha256(this.token));
|
this.hashId = sha256(sha256(this.token));
|
||||||
this.nickname = null;
|
this.nickname = null;
|
||||||
roboidentitiesClient.generateRoboname(this.hashId).then((nickname) => {
|
roboidentitiesClient.generateRoboname(this.hashId).then((nickname) => {
|
||||||
this.nickname = nickname;
|
this.nickname = nickname;
|
||||||
|
onRobotUpdate();
|
||||||
});
|
});
|
||||||
roboidentitiesClient.generateRobohash(this.hashId, 'small');
|
roboidentitiesClient.generateRobohash(this.hashId, 'small');
|
||||||
roboidentitiesClient.generateRobohash(this.hashId, 'large');
|
roboidentitiesClient.generateRobohash(this.hashId, 'large');
|
||||||
@ -23,6 +29,7 @@ class Slot {
|
|||||||
this.activeShortAlias = null;
|
this.activeShortAlias = null;
|
||||||
this.lastShortAlias = null;
|
this.lastShortAlias = null;
|
||||||
this.copiedToken = false;
|
this.copiedToken = false;
|
||||||
|
onRobotUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
token: string | null;
|
token: string | null;
|
||||||
|
Reference in New Issue
Block a user