mirror of
https://github.com/yzernik/squeaknode.git
synced 2026-08-13 12:33:25 +02:00
Show num replies (#2144)
* Got show num replies working on squeak page * Fix group by squeak hash * Fix db queries for get num replies * Update frontend build
This commit is contained in:
parent
f252aba9ba
commit
d626147c71
14 changed files with 102 additions and 16 deletions
|
|
@ -172,7 +172,7 @@ const SqueakCard = React.memo(function SqueakCard(props) {
|
|||
<ICON_REPLY styles={{fill:'rgb(101, 119, 134)'}}/>
|
||||
</div>
|
||||
<div className="card-icon-value">
|
||||
0
|
||||
{props.squeak.getNumReplies()}
|
||||
</div>
|
||||
</div>
|
||||
<div onClick={(e)=>resqueak(e,props.id)} className="card-button-wrap resqueak-wrap">
|
||||
|
|
|
|||
|
|
@ -236,6 +236,7 @@ import { ICON_ARROWBACK, ICON_HEART, ICON_REPLY, ICON_RETWEET, ICON_HEARTFULL,
|
|||
<div className="squeak-interactions">
|
||||
<div onClick={()=>toggleReplyModal()} className="squeak-int-icon">
|
||||
<div className="card-icon reply-icon"> <ICON_REPLY /> </div>
|
||||
{squeak.getNumReplies()}
|
||||
</div>
|
||||
<div onClick={()=>resqueak(squeak.getSqueakHash())} className="squeak-int-icon">
|
||||
<div className="card-icon resqueak-icon">
|
||||
|
|
|
|||
|
|
@ -643,6 +643,9 @@ message SqueakDisplayEntry {
|
|||
|
||||
/// The recipient name
|
||||
SqueakProfile recipient = 19;
|
||||
|
||||
/// Number of replies
|
||||
int32 num_replies = 20;
|
||||
}
|
||||
|
||||
message GetTimelineSqueakDisplaysRequest {
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ def squeak_entry_to_message(squeak_entry: SqueakEntry) -> squeak_admin_pb2.Squea
|
|||
author=(squeak_profile_to_message(squeak_entry.squeak_profile)
|
||||
if squeak_entry.squeak_profile else None),
|
||||
liked_time_ms=squeak_entry.liked_time_ms, # type: ignore
|
||||
num_replies=squeak_entry.num_replies,
|
||||
is_private=(squeak_entry.recipient_public_key is not None),
|
||||
recipient_pubkey=(squeak_entry.recipient_public_key.to_bytes(
|
||||
).hex() if squeak_entry.recipient_public_key else None),
|
||||
|
|
@ -194,6 +195,7 @@ def message_to_squeak_entry(msg: squeak_admin_pb2.SqueakDisplayEntry) -> SqueakE
|
|||
squeak_profile=None, # TODO: message to squeak profile
|
||||
recipient_squeak_profile=None, # TODO: message to squeak profile
|
||||
liked_time_ms=(msg.liked_time_ms if msg.liked_time_ms > 0 else None),
|
||||
num_replies=0,
|
||||
content=(msg.content_str if len(msg.content_str) > 0 else None),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"files": {
|
||||
"main.css": "/static/css/main.206389cd.css",
|
||||
"main.js": "/static/js/main.60a41f28.js",
|
||||
"main.js": "/static/js/main.c6481849.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.b66ac5fb.chunk.css": "/static/css/900.b66ac5fb.chunk.css",
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
"static/media/icon.svg": "/static/media/icon.982210ec9275956e4d3cc77fa90167fd.svg",
|
||||
"index.html": "/index.html",
|
||||
"main.206389cd.css.map": "/static/css/main.206389cd.css.map",
|
||||
"main.60a41f28.js.map": "/static/js/main.60a41f28.js.map",
|
||||
"main.c6481849.js.map": "/static/js/main.c6481849.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.b66ac5fb.chunk.css.map": "/static/css/900.b66ac5fb.chunk.css.map",
|
||||
|
|
@ -21,6 +21,6 @@
|
|||
},
|
||||
"entrypoints": [
|
||||
"static/css/main.206389cd.css",
|
||||
"static/js/main.60a41f28.js"
|
||||
"static/js/main.c6481849.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.60a41f28.js"></script><link href="/static/css/main.206389cd.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.c6481849.js"></script><link href="/static/css/main.206389cd.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
|
|
@ -41,5 +41,6 @@ class SqueakEntry(NamedTuple):
|
|||
secret_key: Optional[bytes]
|
||||
squeak_profile: Optional[SqueakProfile]
|
||||
recipient_squeak_profile: Optional[SqueakProfile]
|
||||
num_replies: int
|
||||
liked_time_ms: Optional[int] = None
|
||||
content: Optional[str] = None
|
||||
|
|
|
|||
|
|
@ -88,6 +88,10 @@ class SqueakDb:
|
|||
self.author_profiles = self.profiles.alias()
|
||||
self.recipient_profiles = self.profiles.alias()
|
||||
|
||||
# Create aliases for squeaks
|
||||
self.display_squeaks = self.squeaks.alias()
|
||||
self.reply_squeaks = self.squeaks.alias()
|
||||
|
||||
def init_with_retries(
|
||||
self,
|
||||
num_retries=INIT_NUM_RETRIES,
|
||||
|
|
@ -266,7 +270,12 @@ class SqueakDb:
|
|||
# recipient_profiles = self.profiles.alias()
|
||||
|
||||
s = (
|
||||
select([self.squeaks, self.author_profiles, self.recipient_profiles])
|
||||
select([
|
||||
self.squeaks,
|
||||
self.author_profiles,
|
||||
self.recipient_profiles,
|
||||
func.count(self.reply_squeaks.c.hash).label("num_replies"),
|
||||
])
|
||||
.select_from(
|
||||
self.squeaks
|
||||
.outerjoin(
|
||||
|
|
@ -277,7 +286,12 @@ class SqueakDb:
|
|||
self.recipient_profiles,
|
||||
self.recipient_profiles.c.public_key == self.squeaks.c.recipient_public_key,
|
||||
)
|
||||
.outerjoin(
|
||||
self.reply_squeaks,
|
||||
self.reply_squeaks.c.reply_hash == self.squeaks.c.hash,
|
||||
)
|
||||
)
|
||||
.group_by(self.squeaks.c.hash)
|
||||
.where(self.squeaks.c.hash == squeak_hash)
|
||||
)
|
||||
with self.get_connection() as connection:
|
||||
|
|
@ -285,6 +299,9 @@ class SqueakDb:
|
|||
row = result.fetchone()
|
||||
if row is None:
|
||||
return None
|
||||
print("row:")
|
||||
print(row)
|
||||
logger.info("row: {}".format(row))
|
||||
return self._parse_squeak_entry(
|
||||
row,
|
||||
# author_profiles_table=author_profiles,
|
||||
|
|
@ -313,7 +330,12 @@ class SqueakDb:
|
|||
))
|
||||
s = (
|
||||
# select([self.squeaks, self.profiles])
|
||||
select([self.squeaks, self.author_profiles, self.recipient_profiles])
|
||||
select([
|
||||
self.squeaks,
|
||||
self.author_profiles,
|
||||
self.recipient_profiles,
|
||||
func.count(self.reply_squeaks.c.hash).label("num_replies"),
|
||||
])
|
||||
.select_from(
|
||||
# self.squeaks.outerjoin(
|
||||
# self.profiles,
|
||||
|
|
@ -328,7 +350,12 @@ class SqueakDb:
|
|||
self.recipient_profiles,
|
||||
self.recipient_profiles.c.public_key == self.squeaks.c.recipient_public_key,
|
||||
)
|
||||
.outerjoin(
|
||||
self.reply_squeaks,
|
||||
self.reply_squeaks.c.reply_hash == self.squeaks.c.hash,
|
||||
)
|
||||
)
|
||||
.group_by(self.squeaks.c.hash)
|
||||
.where(self.profile_is_following(self.author_profiles))
|
||||
.where(
|
||||
tuple_(
|
||||
|
|
@ -372,7 +399,12 @@ class SqueakDb:
|
|||
))
|
||||
s = (
|
||||
# select([self.squeaks, self.profiles])
|
||||
select([self.squeaks, self.author_profiles, self.recipient_profiles])
|
||||
select([
|
||||
self.squeaks,
|
||||
self.author_profiles,
|
||||
self.recipient_profiles,
|
||||
func.count(self.reply_squeaks.c.hash).label("num_replies"),
|
||||
])
|
||||
.select_from(
|
||||
# self.squeaks.outerjoin(
|
||||
# self.profiles,
|
||||
|
|
@ -387,7 +419,12 @@ class SqueakDb:
|
|||
self.recipient_profiles,
|
||||
self.recipient_profiles.c.public_key == self.squeaks.c.recipient_public_key,
|
||||
)
|
||||
.outerjoin(
|
||||
self.reply_squeaks,
|
||||
self.reply_squeaks.c.reply_hash == self.squeaks.c.hash,
|
||||
)
|
||||
)
|
||||
.group_by(self.squeaks.c.hash)
|
||||
.where(
|
||||
self.squeak_is_liked,
|
||||
)
|
||||
|
|
@ -436,7 +473,12 @@ class SqueakDb:
|
|||
))
|
||||
s = (
|
||||
# select([self.squeaks, self.profiles])
|
||||
select([self.squeaks, self.author_profiles, self.recipient_profiles])
|
||||
select([
|
||||
self.squeaks,
|
||||
self.author_profiles,
|
||||
self.recipient_profiles,
|
||||
func.count(self.reply_squeaks.c.hash).label("num_replies"),
|
||||
])
|
||||
.select_from(
|
||||
# self.squeaks.outerjoin(
|
||||
# self.profiles,
|
||||
|
|
@ -451,7 +493,12 @@ class SqueakDb:
|
|||
self.recipient_profiles,
|
||||
self.recipient_profiles.c.public_key == self.squeaks.c.recipient_public_key,
|
||||
)
|
||||
.outerjoin(
|
||||
self.reply_squeaks,
|
||||
self.reply_squeaks.c.reply_hash == self.squeaks.c.hash,
|
||||
)
|
||||
)
|
||||
.group_by(self.squeaks.c.hash)
|
||||
.where(self.squeaks.c.author_public_key == public_key.to_bytes())
|
||||
.where(
|
||||
tuple_(
|
||||
|
|
@ -501,7 +548,12 @@ class SqueakDb:
|
|||
))
|
||||
s = (
|
||||
# select([self.squeaks, self.profiles])
|
||||
select([self.squeaks, self.author_profiles, self.recipient_profiles])
|
||||
select([
|
||||
self.squeaks,
|
||||
self.author_profiles,
|
||||
self.recipient_profiles,
|
||||
func.count(self.reply_squeaks.c.hash).label("num_replies"),
|
||||
])
|
||||
.select_from(
|
||||
# self.squeaks.outerjoin(
|
||||
# self.profiles,
|
||||
|
|
@ -516,7 +568,12 @@ class SqueakDb:
|
|||
self.recipient_profiles,
|
||||
self.recipient_profiles.c.public_key == self.squeaks.c.recipient_public_key,
|
||||
)
|
||||
.outerjoin(
|
||||
self.reply_squeaks,
|
||||
self.reply_squeaks.c.reply_hash == self.squeaks.c.hash,
|
||||
)
|
||||
)
|
||||
.group_by(self.squeaks.c.hash)
|
||||
.where(self.squeaks.c.content.ilike(f'%{search_text}%'))
|
||||
.where(
|
||||
tuple_(
|
||||
|
|
@ -568,7 +625,12 @@ class SqueakDb:
|
|||
|
||||
s = (
|
||||
# select([self.squeaks, self.profiles])
|
||||
select([self.squeaks, self.author_profiles, self.recipient_profiles])
|
||||
select([
|
||||
self.squeaks,
|
||||
self.author_profiles,
|
||||
self.recipient_profiles,
|
||||
func.count(self.reply_squeaks.c.hash).label("num_replies"),
|
||||
])
|
||||
.select_from(
|
||||
self.squeaks.join(
|
||||
ancestors,
|
||||
|
|
@ -585,7 +647,12 @@ class SqueakDb:
|
|||
self.recipient_profiles,
|
||||
self.recipient_profiles.c.public_key == self.squeaks.c.recipient_public_key,
|
||||
)
|
||||
.outerjoin(
|
||||
self.reply_squeaks,
|
||||
self.reply_squeaks.c.reply_hash == self.squeaks.c.hash,
|
||||
)
|
||||
)
|
||||
.group_by(self.squeaks.c.hash)
|
||||
.order_by(
|
||||
ancestors.c.depth.desc(),
|
||||
)
|
||||
|
|
@ -639,7 +706,12 @@ class SqueakDb:
|
|||
))
|
||||
s = (
|
||||
# select([self.squeaks, self.profiles])
|
||||
select([self.squeaks, self.author_profiles, self.recipient_profiles])
|
||||
select([
|
||||
self.squeaks,
|
||||
self.author_profiles,
|
||||
self.recipient_profiles,
|
||||
func.count(self.reply_squeaks.c.hash).label("num_replies"),
|
||||
])
|
||||
.select_from(
|
||||
# self.squeaks.outerjoin(
|
||||
# self.profiles,
|
||||
|
|
@ -654,7 +726,12 @@ class SqueakDb:
|
|||
self.recipient_profiles,
|
||||
self.recipient_profiles.c.public_key == self.squeaks.c.recipient_public_key,
|
||||
)
|
||||
.outerjoin(
|
||||
self.reply_squeaks,
|
||||
self.reply_squeaks.c.reply_hash == self.squeaks.c.hash,
|
||||
)
|
||||
)
|
||||
.group_by(self.squeaks.c.hash)
|
||||
.where(self.squeaks.c.reply_hash == squeak_hash)
|
||||
.where(
|
||||
tuple_(
|
||||
|
|
@ -1838,6 +1915,7 @@ class SqueakDb:
|
|||
is_unlocked=is_locked,
|
||||
secret_key=(row["secret_key"]),
|
||||
liked_time_ms=liked_time_ms,
|
||||
num_replies=row["num_replies"],
|
||||
content=row["content"],
|
||||
squeak_profile=profile,
|
||||
recipient_squeak_profile=recipient_profile,
|
||||
|
|
|
|||
|
|
@ -306,6 +306,7 @@ def squeak_entry_locked(
|
|||
squeak_profile=signing_profile,
|
||||
recipient_squeak_profile=recipient_contact_profile,
|
||||
liked_time_ms=None,
|
||||
num_replies=0,
|
||||
content=None,
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue