Jelajahi Sumber

Oasis release 0.4.7

psy 3 hari lalu
induk
melakukan
4a90681d09
3 mengubah file dengan 32 tambahan dan 20 penghapusan
  1. 2 0
      docs/CHANGELOG.md
  2. 21 15
      src/models/activity_model.js
  3. 9 5
      src/views/activity_view.js

+ 2 - 0
docs/CHANGELOG.md

@@ -23,6 +23,7 @@ All notable changes to this project will be documented in this file.
 ### Fixed
 
  + Fixed mentioning (mentions plugin).
+ + Forum feed (activity plugin).
  
 ### Changed
 
@@ -30,6 +31,7 @@ All notable changes to this project will be documented in this file.
 - Mentions.
 - Peers.
 - Invites.
+- Activity.
 
 ## v0.4.6 - 2025-08-24
  

+ 21 - 15
src/models/activity_model.js

@@ -115,21 +115,27 @@ module.exports = ({ cooler }) => {
       }
 
       const latest = [];
-      for (const a of idToAction.values()) {
-        if (tombstoned.has(a.id)) continue;
-        const c = a.content || {};
-        if (c.root && tombstoned.has(c.root)) continue;
-        if (a.type === 'vote' && tombstoned.has(c.vote?.link)) continue;
-        if (c.key && tombstoned.has(c.key)) continue;
-        if (c.branch && tombstoned.has(c.branch)) continue;
-        if (c.target && tombstoned.has(c.target)) continue;
-        if (a.type === 'document') {
-          const url = c.url;
-          const ok = await hasBlob(ssbClient, url);
-          if (!ok) continue;
-        }
-        latest.push({ ...a, tipId: idToTipId.get(a.id) || a.id });
-      }
+	for (const a of idToAction.values()) {
+	  if (tombstoned.has(a.id)) continue;
+	  const c = a.content || {};
+	  if (c.root && tombstoned.has(c.root)) continue;
+	  if (a.type === 'vote' && tombstoned.has(c.vote?.link)) continue;
+	  if (c.key && tombstoned.has(c.key)) continue;
+	  if (c.branch && tombstoned.has(c.branch)) continue;
+	  if (c.target && tombstoned.has(c.target)) continue;
+	  if (a.type === 'document') {
+	    const url = c.url;
+	    const ok = await hasBlob(ssbClient, url);
+	    if (!ok) continue;
+	  }
+	  if (a.type === 'forum' && c.root) {
+	    const rootId = typeof c.root === 'string' ? c.root : (c.root?.key || c.root?.id || '');
+	    const rootAction = idToAction.get(rootId);
+	    a.content.rootTitle = rootAction?.content?.title || a.content.rootTitle || '';
+	    a.content.rootKey = rootId || a.content.rootKey || '';
+	  }
+	  latest.push({ ...a, tipId: idToTipId.get(a.id) || a.id });
+	}
 
       let deduped = latest.filter(a => !a.tipId || a.tipId === a.id);
 

+ 9 - 5
src/views/activity_view.js

@@ -327,24 +327,28 @@ function renderActionCards(actions, userId) {
     }
 
     if (type === 'forum') {
-      const { root, category, title, text, key } = content;
+      const { root, category, title, text, key, rootTitle, rootKey } = content;
       if (!root) {
+        const linkKey = key || action.id;
+        const linkText = (title && String(title).trim()) ? title : '(sin título)';
         cardBody.push(
           div({ class: 'card-section forum' },
             div({ class: 'card-field', style: "font-size:1.12em; margin-bottom:5px;" },
               span({ class: 'card-label', style: "font-weight:800;color:#ff9800;" }, i18n.title + ': '),
-              a({ href: `/forum/${encodeURIComponent(key || action.id)}`, style: "font-weight:800;color:#4fc3f7;" }, title)
+              a({ href: `/forum/${encodeURIComponent(linkKey)}`, style: "font-weight:800;color:#4fc3f7;" }, linkText)
             )
           )
         );
       } else {
-        let parentForum = actions.find(a => a.type === 'forum' && !a.content.root && (a.id === root || a.content.key === root));
-        let parentTitle = parentForum?.content?.title || '';
+        const rootId = typeof root === 'string' ? root : (root?.key || root?.id || '');
+        const parentForum = actions.find(a => a.type === 'forum' && !a.content?.root && (a.id === rootId || a.content?.key === rootId));
+        const parentTitle = (parentForum?.content?.title && String(parentForum.content.title).trim()) ? parentForum.content.title : ((rootTitle && String(rootTitle).trim()) ? rootTitle : '(sin título)');
+        const hrefKey = rootKey || rootId;
         cardBody.push(
           div({ class: 'card-section forum' },
             div({ class: 'card-field', style: "font-size:1.12em; margin-bottom:5px;" },
               span({ class: 'card-label', style: "font-weight:800;color:#ff9800;" }, i18n.title + ': '),
-              a({ href: `/forum/${encodeURIComponent(root)}`, style: "font-weight:800;color:#4fc3f7;" }, parentTitle)
+              a({ href: `/forum/${encodeURIComponent(hrefKey)}`, style: "font-weight:800;color:#4fc3f7;" }, parentTitle)
             ),
             br(),
             div({ class: 'card-field', style: 'margin-bottom:12px;' },