Use nested profile msg in squeak display msg (#767)

* Use nested squeak profile msg inside squeak display entry in rpc proto

* Include author address in squeak display entry msg

* Use nested squeak profile in squeak display message in frontend

* Update static build with nested squeak profile in squeak display msg
This commit is contained in:
Jonathan Zernik 2021-01-30 21:29:57 -08:00 committed by GitHub
parent f6cd2bc7db
commit a07e73faa4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 56 additions and 64 deletions

View file

@ -120,11 +120,7 @@ export default function SqueakDetailItem({
const onDownloadClick = (event) => {
event.preventDefault();
console.log("Handling download click...");
// goToBuyPage(squeak.getSqueakHash());
console.log("syncSqueakRequest with hash: " + hash);
syncSqueakRequest(hash, (response) => {
console.log("response:");
console.log(response);
reloadRoute();
});
}
@ -207,7 +203,7 @@ export default function SqueakDetailItem({
return "Author unknown"
}
return squeak.getIsAuthorKnown()
? squeak.getAuthorName()
? squeak.getAuthor().getProfileName()
: squeak.getAuthorAddress()
}

View file

@ -151,7 +151,7 @@ export default function SqueakThreadItem({
return "Author unknown"
}
return squeak.getIsAuthorKnown()
? squeak.getAuthorName()
? squeak.getAuthor().getProfileName()
: squeak.getAuthorAddress()
}

View file

@ -9,29 +9,29 @@ import Avatar from '@material-ui/core/Avatar';
import {useHistory} from "react-router-dom";
import {
getAuthorImageSrcString,
getProfileImageSrcString,
} from "../../squeakimages/images"
export default function SqueakUserAvatar({
squeak,
squeakProfile,
...props
}) {
const history = useHistory();
const goToSqueakAddressPage = () => {
history.push("/app/squeakaddress/" + squeak.getAuthorAddress());
const goToSqueakAddressPage = (squeakAddress) => {
history.push("/app/squeakaddress/" + squeakAddress);
};
const handleAvatarClick = () => {
if (squeak) {
goToSqueakAddressPage(squeak.getAuthorAddress());
if (squeakProfile) {
goToSqueakAddressPage(squeakProfile.getAddress());
}
};
function AvatarImage() {
return (
<Avatar src={`${getAuthorImageSrcString(squeak)}`} />
<Avatar src={`${getProfileImageSrcString(squeakProfile)}`} />
)
}
@ -40,7 +40,7 @@ export default function SqueakUserAvatar({
onClick={handleAvatarClick}
style={{cursor: 'pointer'}}
>
{squeak ?
{squeakProfile ?
AvatarImage() :
<HelpIcon fontSize="large" />
}

View file

@ -89,8 +89,6 @@ export default function SqueakPage() {
if (!oldestKnownAncestor) {
return null;
}
console.log(oldestKnownAncestor);
console.log("oldestKnownAncestor");
return oldestKnownAncestor.getReplyTo();
};
@ -223,7 +221,7 @@ export default function SqueakPage() {
></TimelineOppositeContent>
<TimelineSeparator>
<SqueakUserAvatar
squeak={ancestorSqueak}
squeakProfile={ancestorSqueak.getAuthor()}
/>
<TimelineConnector />
</TimelineSeparator>
@ -254,7 +252,7 @@ export default function SqueakPage() {
></TimelineOppositeContent>
<TimelineSeparator>
<SqueakUserAvatar
squeak={squeak}
squeakProfile={squeak && squeak.getAuthor()}
/>
</TimelineSeparator>
<TimelineContent>
@ -274,7 +272,6 @@ export default function SqueakPage() {
}
function RepliesContent() {
console.log("replySqueaks: " + replySqueaks);
return (
<>
{replySqueaks
@ -288,7 +285,7 @@ export default function SqueakPage() {
></TimelineOppositeContent>
<TimelineSeparator>
<SqueakUserAvatar
squeak={replySqueak}
squeakProfile={replySqueak.getAuthor()}
/>
</TimelineSeparator>
<TimelineContent>

View file

@ -141,7 +141,7 @@ export default function SqueakAddressPage() {
></TimelineOppositeContent>
<TimelineSeparator>
<SqueakUserAvatar
squeak={squeak}
squeakProfile={squeak.getAuthor()}
/>
</TimelineSeparator>
<TimelineContent>

View file

@ -136,7 +136,7 @@ export default function TimelinePage() {
></TimelineOppositeContent>
<TimelineSeparator>
<SqueakUserAvatar
squeak={squeak}
squeakProfile={squeak.getAuthor()}
/>
</TimelineSeparator>
<TimelineContent>

View file

@ -5,11 +5,6 @@ function getImageSrcString(imageBase64) {
return "data:image/jpeg;base64," + imageBase64;
}
export function getAuthorImageSrcString(squeak) {
const authorImage = squeak.getAuthorImage();
return getImageSrcString(authorImage);
}
export function getProfileImageSrcString(squeakProfile) {
const profileImage = squeakProfile.getProfileImage();
return getImageSrcString(profileImage);

View file

@ -279,9 +279,12 @@ def test_make_squeak(server_stub, admin_stub, signing_profile_id):
assert (
get_squeak_display_response.squeak_display_entry.content_str == "Hello from the profile on the server!"
)
print("get_squeak_display_response.squeak_display_entry.author_image: {}".format(
get_squeak_display_response.squeak_display_entry.author_image,
))
assert get_squeak_display_response.squeak_display_entry.author_address == str(
get_squeak_response_squeak.GetAddress())
assert get_squeak_display_response.squeak_display_entry.is_author_known
assert get_squeak_display_response.squeak_display_entry.author is not None
assert len(
get_squeak_display_response.squeak_display_entry.author.profile_image) > 0
# Get the squeak profile
get_squeak_profile_response = admin_stub.GetSqueakProfile(
@ -301,8 +304,8 @@ def test_make_squeak(server_stub, admin_stub, signing_profile_id):
for (
squeak_display_entry
) in get_address_squeak_display_response.squeak_display_entries:
assert squeak_display_entry.author_name == squeak_profile_name
assert squeak_display_entry.author_address == squeak_profile_address
assert squeak_display_entry.author.profile_name == squeak_profile_name
assert squeak_display_entry.author.address == squeak_profile_address
def test_make_reply_squeak(

View file

@ -463,17 +463,14 @@ message SqueakDisplayEntry {
/// Block time
int64 block_time = 8;
/// The author name
string author_address = 9;
/// Is author address known
bool is_author_known = 9;
bool is_author_known = 10;
/// The author name
string author_address = 10;
/// The author name
string author_name = 11;
/// The author image
string author_image = 12;
SqueakProfile author = 11;
}
message GetTimelineSqueakDisplaysRequest {

View file

@ -25,17 +25,22 @@ def squeak_entry_to_message(squeak_entry_with_profile: SqueakEntryWithProfile):
is_unlocked = squeak.HasDecryptionKey()
content_str = squeak.GetDecryptedContentStr() if is_unlocked else None
squeak_profile = squeak_entry_with_profile.squeak_profile
is_author_known = squeak_profile is not None
author_name = squeak_profile.profile_name if squeak_profile else None
author_address = str(squeak.GetAddress())
# author_name = squeak_profile.profile_name if squeak_profile else None
is_reply = squeak.is_reply
reply_to = squeak.hashReplySqk.hex() if is_reply else None
if squeak_profile:
profile_image = squeak_profile.profile_image or DEFAULT_PROFILE_IMAGE
# if squeak_profile:
# profile_image = squeak_profile.profile_image or DEFAULT_PROFILE_IMAGE
# else:
# profile_image = DEFAULT_PROFILE_IMAGE
# # has_custom_profile_image = squeak_profile.profile_image is not None
# image_base64_str = bytes_to_base64_string(profile_image)
author_address = str(squeak.GetAddress())
if squeak_profile is not None:
is_author_known = True
profile_msg = squeak_profile_to_message(squeak_profile)
else:
profile_image = DEFAULT_PROFILE_IMAGE
# has_custom_profile_image = squeak_profile.profile_image is not None
image_base64_str = bytes_to_base64_string(profile_image)
is_author_known = False
profile_msg = None
return squeak_admin_pb2.SqueakDisplayEntry(
squeak_hash=get_hash(squeak).hex(),
is_unlocked=squeak.HasDecryptionKey(),
@ -43,12 +48,11 @@ def squeak_entry_to_message(squeak_entry_with_profile: SqueakEntryWithProfile):
block_height=squeak.nBlockHeight,
block_hash=squeak.hashBlock.hex(),
block_time=block_header.nTime,
is_author_known=is_author_known,
author_name=author_name,
author_address=author_address,
is_reply=is_reply,
reply_to=reply_to,
author_image=image_base64_str,
author_address=author_address,
is_author_known=is_author_known,
author=profile_msg,
)

View file

@ -1,14 +1,14 @@
{
"files": {
"main.js": "/static/js/main.41662449.chunk.js",
"main.js.map": "/static/js/main.41662449.chunk.js.map",
"main.js": "/static/js/main.eded99b8.chunk.js",
"main.js.map": "/static/js/main.eded99b8.chunk.js.map",
"runtime-main.js": "/static/js/runtime-main.9f0ba400.js",
"runtime-main.js.map": "/static/js/runtime-main.9f0ba400.js.map",
"static/css/2.15110fae.chunk.css": "/static/css/2.15110fae.chunk.css",
"static/js/2.c9e1641e.chunk.js": "/static/js/2.c9e1641e.chunk.js",
"static/js/2.c9e1641e.chunk.js.map": "/static/js/2.c9e1641e.chunk.js.map",
"index.html": "/index.html",
"precache-manifest.cb12e5a2e3dbd7f837deabb1b6f88869.js": "/precache-manifest.cb12e5a2e3dbd7f837deabb1b6f88869.js",
"precache-manifest.080d77f3564e4c51ce2439dea250eb4b.js": "/precache-manifest.080d77f3564e4c51ce2439dea250eb4b.js",
"service-worker.js": "/service-worker.js",
"static/css/2.15110fae.chunk.css.map": "/static/css/2.15110fae.chunk.css.map",
"static/js/2.c9e1641e.chunk.js.LICENSE.txt": "/static/js/2.c9e1641e.chunk.js.LICENSE.txt",
@ -20,6 +20,6 @@
"static/js/runtime-main.9f0ba400.js",
"static/css/2.15110fae.chunk.css",
"static/js/2.c9e1641e.chunk.js",
"static/js/main.41662449.chunk.js"
"static/js/main.eded99b8.chunk.js"
]
}

View file

@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/manifest.json"/><title>Squeak Node</title><meta name="description" content="Squeak Node is a frontend for accessing a squeak node"><meta name="keywords" content="squeak, bitcoin, lightning"><meta name="author" content="Flatlogic LLC."><link href="/static/css/2.15110fae.chunk.css" rel="stylesheet"></head><body style="font-family:Roboto,sans-serif"><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,f,l=r[0],a=r[1],i=r[2],c=0,s=[];c<l.length;c++)f=l[c],Object.prototype.hasOwnProperty.call(o,f)&&o[f]&&s.push(o[f][0]),o[f]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,i||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var a=t[l];0!==o[a]&&(n=!1)}n&&(u.splice(r--,1),e=f(f.s=t[0]))}return e}var n={},o={1:0},u=[];function f(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.m=e,f.c=n,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,r){if(1&r&&(e=f(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)f.d(t,n,function(r){return e[r]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var l=this["webpackJsonpsqueak-node-frontend"]=this["webpackJsonpsqueak-node-frontend"]||[],a=l.push.bind(l);l.push=r,l=l.slice();for(var i=0;i<l.length;i++)r(l[i]);var p=a;t()}([])</script><script src="/static/js/2.c9e1641e.chunk.js"></script><script src="/static/js/main.41662449.chunk.js"></script></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/manifest.json"/><title>Squeak Node</title><meta name="description" content="Squeak Node is a frontend for accessing a squeak node"><meta name="keywords" content="squeak, bitcoin, lightning"><meta name="author" content="Flatlogic LLC."><link href="/static/css/2.15110fae.chunk.css" rel="stylesheet"></head><body style="font-family:Roboto,sans-serif"><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,f,l=r[0],a=r[1],i=r[2],c=0,s=[];c<l.length;c++)f=l[c],Object.prototype.hasOwnProperty.call(o,f)&&o[f]&&s.push(o[f][0]),o[f]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,i||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var a=t[l];0!==o[a]&&(n=!1)}n&&(u.splice(r--,1),e=f(f.s=t[0]))}return e}var n={},o={1:0},u=[];function f(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.m=e,f.c=n,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(e,r){if(1&r&&(e=f(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)f.d(t,n,function(r){return e[r]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var l=this["webpackJsonpsqueak-node-frontend"]=this["webpackJsonpsqueak-node-frontend"]||[],a=l.push.bind(l);l.push=r,l=l.slice();for(var i=0;i<l.length;i++)r(l[i]);var p=a;t()}([])</script><script src="/static/js/2.c9e1641e.chunk.js"></script><script src="/static/js/main.eded99b8.chunk.js"></script></body></html>

View file

@ -1,6 +1,6 @@
self.__precacheManifest = (self.__precacheManifest || []).concat([
{
"revision": "e1f16823d0a9e463684284c5a96da4df",
"revision": "eb5b8e40138183a8dd27e3717d22dfce",
"url": "/index.html"
},
{
@ -16,8 +16,8 @@ self.__precacheManifest = (self.__precacheManifest || []).concat([
"url": "/static/js/2.c9e1641e.chunk.js.LICENSE.txt"
},
{
"revision": "6908d16f83095fd46bce",
"url": "/static/js/main.41662449.chunk.js"
"revision": "048beb95feb2fb6c164c",
"url": "/static/js/main.eded99b8.chunk.js"
},
{
"revision": "cc9816de5a8639d377ea",

View file

@ -14,7 +14,7 @@
importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");
importScripts(
"/precache-manifest.cb12e5a2e3dbd7f837deabb1b6f88869.js"
"/precache-manifest.080d77f3564e4c51ce2439dea250eb4b.js"
);
self.addEventListener('message', (event) => {

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