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