all repos — underbbs @ 09c7eb8318d096aa31786101c4ede959c537aacd

decentralized social media client

start implementing boost carousel
Iris Lightshard nilix@nilfm.cc
PGP Signature
-----BEGIN PGP SIGNATURE-----

iHUEABYKAB0WIQT/foVVmI9pK13hPWFohAcXSWbK8wUCZtNMawAKCRBohAcXSWbK
8/2YAP0UzUIeFH16mLepFKk9uqOnyKr7ar7EgmugxCG2u74m/AD+MDRq41lqcb2C
wlXt//FJ7GHnLVgDTBg8pesHgcgk8wg=
=cTSy
-----END PGP SIGNATURE-----
commit

09c7eb8318d096aa31786101c4ede959c537aacd

parent

7a2eb99eb6d60d23c034f6255d5b52aea08e24d5

M adapter/misskey.goadapter/misskey.go

@@ -216,6 +216,7 @@ Visibility: n.Visibility,

ReplyTo: n.ReplyID, ReplyCount: int(n.RepliesCount), Replies: []string{}, + RenoteId: (*string)(n.RenoteID), } for _, f := range n.Files {
M frontend/ts/adapter-element.tsfrontend/ts/adapter-element.ts

@@ -24,6 +24,7 @@

// TODO: use visibility of the thread to organize into DMs and public threads private _threads: MessageThread[] = []; private _orphans: Message[] = []; + private _boosts: Message[] = []; constructor() { super();

@@ -102,6 +103,7 @@ if (tse) {

tse.setAttribute("data-author", this._latest); } } + // also update any boosts by this author case "thread": case "profile": break;

@@ -113,7 +115,7 @@ }

} setIdxView() { - this.innerHTML = "<ul id='dm_list'></ul><ul id='public_list'></ul>" + this.innerHTML = "<ul id='boost_carousel'></ul><ul id='dm_list'></ul><ul id='public_list'></ul>" } setThreadView() {

@@ -132,6 +134,8 @@ }

} populateIdxView() { + // populate boost carousel + // skip dm list for now // public/unified list const pl = util.$("public_list");

@@ -149,11 +153,12 @@ const threadSelector = `underbbs-thread-summary[data-msg='${rootId}']`

const existingThread = document.querySelector(threadSelector); const thread = this._threads.find(t=>t.root.data.id == rootId); if (existingThread && thread) { - debugger; existingThread.setAttribute("data-latest", `${thread.latest}`); existingThread.setAttribute("data-len", `${thread.messageCount}`); existingThread.setAttribute("data-new", "true"); } else { + // if latest is a boost, put it in the carousel + // unified/public list for now const pl = util.$("public_list"); if (pl && thread) {

@@ -190,14 +195,14 @@ util.errMsg(this._name + " has no datastore!");

return; } // make multiple passes over the store until every message is either - // placed in a thread, or orphaned and waiting for its parent to be returned + // placed in a thread, the boost carousel, or orphaned and waiting for its parent to be returned do{ for (let k of datastore.messages.keys()) { this.placeMsg(k); } } while (this._threads.reduce((sum: number, thread: MessageThread)=>{ return sum + thread.messageCount; - }, 0) + this._orphans.length < datastore.messages.size); + }, 0) + this._boosts.length + this._orphans.length < datastore.messages.size); } placeMsg(k: string): string | null {

@@ -211,11 +216,20 @@ if (!msg) {

util.errMsg(`message [${this._name}:${k}] doesn't exist`); return null; } + if (msg.renoteId) { + // fetch the referent thread and put the boost in the carousel + this._convoyBatchTimer.queue(msg.renoteId, 2000); + if (!this._boosts.some(m=>m.id == msg.id)) { + this._boosts.push(msg); + } + return null; + } for (let t of this._threads) { // avoid processing nodes again on subsequent passes if (!msg || t.findNode(t.root, msg.id)) { return null; } + if (msg.replyTo) { let x = t.addReply(msg.replyTo, msg); if (x) {
A frontend/ts/boost-tile-element.ts

@@ -0,0 +1,14 @@

+export class BoostTileElement extends HTMLElement { + + static observedAttributes = [ "data-boostid", "data-msgid", "data-author", "data-booster" ]; + + constructor() { + this.innerHTML = "<div class='boost_booster'></div><div class='boost_author'></div><div class='boost_content'></div>"; + } + + connectedCallback() { + } + + attributeChangedCallback(attr: string, prev: string, next: string) { + } +}
M frontend/ts/message.tsfrontend/ts/message.ts

@@ -12,6 +12,7 @@ public mentions: string[] = [];

public created: number = 0; public edited: number | null = null; public visibility: string = "public"; + public renoteId: string | null = null; } export class Author {
M frontend/ts/websocket.tsfrontend/ts/websocket.ts

@@ -58,13 +58,12 @@ }

} static connect(): void { - - - const wsProto = location.protocol == "https:" ? "wss" : "ws"; const _conn = new WebSocket(`${wsProto}://${location.host}/subscribe`, "underbbs"); + _conn.addEventListener("open", DatagramSocket.onOpen); _conn.addEventListener("message", DatagramSocket.onMsg); + _conn.addEventListener("error", (e: any) => { console.log("websocket connection error"); console.log(JSON.stringify(e));
M models/msg.gomodels/msg.go

@@ -25,6 +25,7 @@ Replies []string `json:"replies"`

ReplyCount int `json:"replyCount"` Mentions []string `json:"mentions"` Visibility string `json:"visibility"` + RenoteId *string `json:"renoteId,omitempty"` } type Author struct {