-
- ${status.account.display_name}
-
+
+
+
+ ${status.account.display_name}
+
-
- ${status.account.acct}
-
-
+
+ ${status.account.acct}
+
+
-
-
-
+
+
+
-
-
+
+
-
${status.content}
-
- ${status.media_attachments}
-
- Link to status
-
-
+
${status.content}
+
+ ${status.media_attachments}
+
+ Link to status
+
+
+
@@ -866,24 +888,34 @@ function beginStreaming(filter, lang) {
}
});
+ // Remove status if it's deleted
+ evtSource.addEventListener("delete", (event) => {
+ document.querySelectorAll(`[data-id="${event.data}"]`).forEach((el) => el.remove());
+
+ // Log
+ console.log('Status deleted: ' + event.data);
+ });
+
// Update status if it gets updated
evtSource.addEventListener("status.update", (event) => {
var status = JSON.parse(event.data);
- if (!document.querySelector(`[data-id="${status.id}"]`)) return; // Status isn't rendered (filtered out or just too old)
- console.log(status.id);
- // Remove divs
- document.querySelectorAll(`div[data-id="${status.id}"]`).forEach((el) => el.remove());
+ const updatedStatus = document.querySelector(`[data-id="${status.id}"]`);
- // Replace anchor tag with new HTML
- const anchor = document.querySelector(`a[data-id="${status.id}"]`);
+ // If updatedStatus does not exist, return
+ if (!updatedStatus) {
+ return;
+ }
- anchor.outerHTML = statusToHtml(status);
- });
+ // Update content
+ document.querySelector(`[data-id="${status.id}"] .target .whitespace-pre-line`).innerHTML = status.content;
+
+ // Add orange border to updated status
+ document.querySelector(`[data-id="${status.id}"] .target .whitespace-pre-line`).outerHTML = '
[updated] ' + status.content;
+
+ // Log
+ console.log('Status updated: ' + status.id);
- // Remove status if it's deleted
- evtSource.addEventListener("delete", (event) => {
- document.querySelectorAll(`[data-id="${event.data}"]`).forEach((el) => el.remove());
});
}