kinda setup for get
This commit is contained in:
parent
c41928295f
commit
68e843dbc8
3 changed files with 33 additions and 7 deletions
|
@ -21,9 +21,9 @@ function createWindow() {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Open the DevTools.
|
// Open the DevTools.
|
||||||
if (IS_DEV) {
|
// if (IS_DEV) {
|
||||||
mainWindow.webContents.openDevTools();
|
// mainWindow.webContents.openDevTools();
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Emitted when the window is closed.
|
// Emitted when the window is closed.
|
||||||
mainWindow.on("closed", function() {
|
mainWindow.on("closed", function() {
|
||||||
|
|
|
@ -16,8 +16,10 @@
|
||||||
<div id="resolve">
|
<div id="resolve">
|
||||||
<input id="resolve-input" />
|
<input id="resolve-input" />
|
||||||
<button id="resolve-button">Resolve</button>
|
<button id="resolve-button">Resolve</button>
|
||||||
<p id="resolve-help"></p>
|
<button id="get-button">Get</button>
|
||||||
|
<p id="help"></p>
|
||||||
|
|
||||||
|
<div id="image-wrapper"></div>
|
||||||
<pre id="claim"></pre>
|
<pre id="claim"></pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -22,18 +22,21 @@ function checkSDKStarted() {
|
||||||
|
|
||||||
const resolveInput = document.getElementById("resolve-input");
|
const resolveInput = document.getElementById("resolve-input");
|
||||||
const resolveButton = document.getElementById("resolve-button");
|
const resolveButton = document.getElementById("resolve-button");
|
||||||
const resolveHelp = document.getElementById("resolve-help");
|
const getButton = document.getElementById("get-button");
|
||||||
|
const help = document.getElementById("help");
|
||||||
const claimData = document.getElementById("claim");
|
const claimData = document.getElementById("claim");
|
||||||
|
const imageWrapper = document.getElementById("image-wrapper");
|
||||||
|
|
||||||
resolveInput.addEventListener("input", e => {
|
resolveInput.addEventListener("input", e => {
|
||||||
const { value } = e.target;
|
const { value } = e.target;
|
||||||
const helpText = `Would resolve <b>lbry://${value}</b>`;
|
const helpText = `Would resolve?? <b>lbry://${value}</b>`;
|
||||||
resolveHelp.innerHTML = helpText;
|
help.innerHTML = helpText;
|
||||||
});
|
});
|
||||||
|
|
||||||
resolveButton.addEventListener("click", () => {
|
resolveButton.addEventListener("click", () => {
|
||||||
const value = resolveInput.value;
|
const value = resolveInput.value;
|
||||||
if (!value) {
|
if (!value) {
|
||||||
|
help.innerHTML = "You need to enter a name before resolving a claim.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,3 +49,24 @@ resolveButton.addEventListener("click", () => {
|
||||||
claimData.innerText = JSON.stringify(error, null, 2);
|
claimData.innerText = JSON.stringify(error, null, 2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
getButton.addEventListener("click", () => {
|
||||||
|
const value = resolveInput.value;
|
||||||
|
if (!value) {
|
||||||
|
help.innerHTML = "You need to enter a name before getting the file.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
claimData.innerText = "Loading...";
|
||||||
|
Lbry.get({ uri: `lbry://${value}` })
|
||||||
|
.then(res => {
|
||||||
|
// TODO: add simplest way to get an image and display it.
|
||||||
|
// Then add it to the page.
|
||||||
|
// const image = document.createElement("img");
|
||||||
|
// image.src = `${downloadDirectory}/${fileName}`
|
||||||
|
// imageWrapper.appendChild(image);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
claimData.innerText = JSON.stringify(error, null, 2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue