mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-13 12:33:25 +02:00
Implement rename peer (#2196)
* Implement rename peer * Update frontend build
This commit is contained in:
parent
c09ab3f209
commit
5231850d13
15 changed files with 6954 additions and 5458 deletions
|
|
@ -165,6 +165,8 @@ import {
|
|||
GetReceivedPaymentsForPeerReply,
|
||||
DownloadSqueakSecretKeyRequest,
|
||||
DownloadSqueakSecretKeyReply,
|
||||
RenamePeerRequest,
|
||||
RenamePeerReply,
|
||||
} from '../proto/squeak_admin_pb';
|
||||
|
||||
import axios from 'axios'
|
||||
|
|
@ -718,8 +720,20 @@ export const getPrivateKey = (id) => {
|
|||
});
|
||||
}
|
||||
|
||||
export const getPeer = (network, host, port) => {
|
||||
export const getPeer = (peerId) => {
|
||||
console.log('Calling getPeer');
|
||||
const request = new GetPeerRequest();
|
||||
request.setPeerId(peerId);
|
||||
const deser = GetPeerReply.deserializeBinary;
|
||||
return baseRequest({
|
||||
url: '/getpeer',
|
||||
req: request,
|
||||
deser: deser,
|
||||
});
|
||||
}
|
||||
|
||||
export const getPeerByAddress = (network, host, port) => {
|
||||
console.log('Calling getPeerByAddress');
|
||||
const request = new GetPeerByAddressRequest();
|
||||
const peerAddress = new PeerAddress();
|
||||
peerAddress.setNetwork(network);
|
||||
|
|
@ -734,6 +748,19 @@ export const getPeer = (network, host, port) => {
|
|||
});
|
||||
}
|
||||
|
||||
export const renamePeer = (peerId, peerName) => {
|
||||
console.log('Calling renamePeer');
|
||||
const request = new RenamePeerRequest();
|
||||
request.setPeerId(peerId);
|
||||
request.setPeerName(peerName);
|
||||
const deser = RenamePeerReply.deserializeBinary;
|
||||
return baseRequest({
|
||||
url: '/renamepeer',
|
||||
req: request,
|
||||
deser: deser,
|
||||
});
|
||||
}
|
||||
|
||||
export const getConnectedPeers = () => {
|
||||
console.log('Calling getConnectedPeers');
|
||||
const request = new GetConnectedPeersRequest();
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import {
|
|||
setDeletePeer,
|
||||
setPeerAutoconnectEnabled,
|
||||
setPeerAutoconnectDisabled,
|
||||
setRenamePeer,
|
||||
} from '../../features/peers/peersSlice'
|
||||
import {
|
||||
fetchPaymentSummaryForPeer,
|
||||
|
|
@ -121,13 +122,10 @@ const Peer = (props) => {
|
|||
|
||||
const editPeer = ({values}) => {
|
||||
console.log('Calling editPeer with name:', values.name);
|
||||
// TODO: call rename action.
|
||||
alert('Rename peer not yet implemented!');
|
||||
// dispatch(setRenameProfile({
|
||||
// peerId: user.getPeerId(),
|
||||
// profileName: editName,
|
||||
// }));
|
||||
// TODO: chain action to update profile squeaks with the new name.
|
||||
dispatch(setRenamePeer({
|
||||
peerId: peer.getPeerId(),
|
||||
peerName: values.name,
|
||||
}));
|
||||
setSaved(true)
|
||||
toggleEditModal()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,14 @@ import {
|
|||
} from '@reduxjs/toolkit'
|
||||
import {
|
||||
getPeer,
|
||||
getPeerByAddress,
|
||||
getConnectedPeers,
|
||||
connectPeer,
|
||||
disconnectPeer,
|
||||
getSavedPeers,
|
||||
savePeer,
|
||||
deletePeer,
|
||||
renamePeer,
|
||||
enableAutoconnectPeer,
|
||||
disableAutoconnectPeer,
|
||||
} from '../../api/client'
|
||||
|
|
@ -37,7 +39,7 @@ export const fetchPeer = createAsyncThunk(
|
|||
let network = values.network;
|
||||
let host = values.host;
|
||||
let port = values.port;
|
||||
const response = await getPeer(
|
||||
const response = await getPeerByAddress(
|
||||
network,
|
||||
host,
|
||||
port,
|
||||
|
|
@ -153,6 +155,22 @@ export const setPeerAutoconnectDisabled = createAsyncThunk(
|
|||
}
|
||||
)
|
||||
|
||||
export const setRenamePeer = createAsyncThunk(
|
||||
'profile/setRenamePeer',
|
||||
async (values) => {
|
||||
console.log('Renaming peer');
|
||||
console.log(values.peerId);
|
||||
console.log(values.peerName);
|
||||
let peerId = values.peerId;
|
||||
let peerName = values.peerName;
|
||||
await renamePeer(peerId, peerName);
|
||||
console.log('Getting renamed peer');
|
||||
const response = await getPeer(peerId);
|
||||
console.log(response);
|
||||
return response.getSqueakPeer();
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
const peersSlice = createSlice({
|
||||
name: 'peers',
|
||||
|
|
@ -262,6 +280,14 @@ const peersSlice = createSlice({
|
|||
state.currentPeer = newSavedPeer;
|
||||
state.savedPeers = newSavedPeers;
|
||||
})
|
||||
.addCase(setRenamePeer.pending, (state, action) => {
|
||||
state.currentPeerStatus = 'loading'
|
||||
})
|
||||
.addCase(setRenamePeer.fulfilled, (state, action) => {
|
||||
const newPeer = action.payload;
|
||||
state.currentPeer = newPeer;
|
||||
state.currentPeerStatus = 'idle';
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
|||
12317
frontend/yarn.lock
12317
frontend/yarn.lock
File diff suppressed because it is too large
Load diff
|
|
@ -1,26 +1,26 @@
|
|||
{
|
||||
"files": {
|
||||
"main.css": "/static/css/main.fe6c5463.css",
|
||||
"main.js": "/static/js/main.f6f1567b.js",
|
||||
"main.js": "/static/js/main.e69a9816.js",
|
||||
"static/css/306.7f7715a0.chunk.css": "/static/css/306.7f7715a0.chunk.css",
|
||||
"static/js/306.90b2a66c.chunk.js": "/static/js/306.90b2a66c.chunk.js",
|
||||
"static/css/900.5027b0a1.chunk.css": "/static/css/900.5027b0a1.chunk.css",
|
||||
"static/js/900.1b104345.chunk.js": "/static/js/900.1b104345.chunk.js",
|
||||
"static/css/841.693c3c31.chunk.css": "/static/css/841.693c3c31.chunk.css",
|
||||
"static/js/841.9f23f674.chunk.js": "/static/js/841.9f23f674.chunk.js",
|
||||
"static/js/841.91f0aab2.chunk.js": "/static/js/841.91f0aab2.chunk.js",
|
||||
"static/media/icon.svg": "/static/media/icon.982210ec9275956e4d3cc77fa90167fd.svg",
|
||||
"index.html": "/index.html",
|
||||
"main.fe6c5463.css.map": "/static/css/main.fe6c5463.css.map",
|
||||
"main.f6f1567b.js.map": "/static/js/main.f6f1567b.js.map",
|
||||
"main.e69a9816.js.map": "/static/js/main.e69a9816.js.map",
|
||||
"306.7f7715a0.chunk.css.map": "/static/css/306.7f7715a0.chunk.css.map",
|
||||
"306.90b2a66c.chunk.js.map": "/static/js/306.90b2a66c.chunk.js.map",
|
||||
"900.5027b0a1.chunk.css.map": "/static/css/900.5027b0a1.chunk.css.map",
|
||||
"900.1b104345.chunk.js.map": "/static/js/900.1b104345.chunk.js.map",
|
||||
"841.693c3c31.chunk.css.map": "/static/css/841.693c3c31.chunk.css.map",
|
||||
"841.9f23f674.chunk.js.map": "/static/js/841.9f23f674.chunk.js.map"
|
||||
"841.91f0aab2.chunk.js.map": "/static/js/841.91f0aab2.chunk.js.map"
|
||||
},
|
||||
"entrypoints": [
|
||||
"static/css/main.fe6c5463.css",
|
||||
"static/js/main.f6f1567b.js"
|
||||
"static/js/main.e69a9816.js"
|
||||
]
|
||||
}
|
||||
|
|
@ -1 +1 @@
|
|||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#1da1f2"/><meta nam="description" content="Squeaknode!"/><meta name="og:title" content="Squeaknode"/><meta name="og:description" content="check out my the Squeaknode I made"/><link href="https://fonts.googleapis.com/css2?family=Assistant&display=swap" rel="stylesheet"><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Squeaknode</title><script defer="defer" src="/static/js/main.f6f1567b.js"></script><link href="/static/css/main.fe6c5463.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
||||
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#1da1f2"/><meta nam="description" content="Squeaknode!"/><meta name="og:title" content="Squeaknode"/><meta name="og:description" content="check out my the Squeaknode I made"/><link href="https://fonts.googleapis.com/css2?family=Assistant&display=swap" rel="stylesheet"><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Squeaknode</title><script defer="defer" src="/static/js/main.e69a9816.js"></script><link href="/static/css/main.fe6c5463.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue