Compare commits
8 Commits
548ac39d19
...
bobbyd-not
| Author | SHA1 | Date | |
|---|---|---|---|
| e27cf391ef | |||
| 1353acc4d1 | |||
| 4dda9af788 | |||
| eb4dbb2448 | |||
| 3fef295b59 | |||
|
|
f22d8b9ba6 | ||
|
|
9c15ed2cd2 | ||
|
|
f387d9ea48 |
20
deno.lock
generated
20
deno.lock
generated
@@ -11,6 +11,7 @@
|
||||
"jsr:@std/streams@^1.0.7": "1.0.17",
|
||||
"jsr:@std/tar@0.1.3": "0.1.3",
|
||||
"jsr:@zip-js/zip-js@2.7.53": "2.7.53",
|
||||
"npm:playwright@*": "1.59.1",
|
||||
"npm:typescript@*": "6.0.2"
|
||||
},
|
||||
"jsr": {
|
||||
@@ -60,6 +61,25 @@
|
||||
}
|
||||
},
|
||||
"npm": {
|
||||
"fsevents@2.3.2": {
|
||||
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
||||
"os": ["darwin"],
|
||||
"scripts": true
|
||||
},
|
||||
"playwright-core@1.59.1": {
|
||||
"integrity": "sha512-HBV/RJg81z5BiiZ9yPzIiClYV/QMsDCKUyogwH9p3MCP6IYjUFu/MActgYAvK0oWyV9NlwM3GLBjADyWgydVyg==",
|
||||
"bin": true
|
||||
},
|
||||
"playwright@1.59.1": {
|
||||
"integrity": "sha512-C8oWjPR3F81yljW9o5OxcWzfh6avkVwDD2VYdwIGqTkl+OGFISgypqzfu7dOe4QNLL2aqcWBmI3PMtLIK233lw==",
|
||||
"dependencies": [
|
||||
"playwright-core"
|
||||
],
|
||||
"optionalDependencies": [
|
||||
"fsevents"
|
||||
],
|
||||
"bin": true
|
||||
},
|
||||
"typescript@6.0.2": {
|
||||
"integrity": "sha512-bGdAIrZ0wiGDo5l8c++HWtbaNCWTS4UTv7RaTH/ThVIgjkveJt83m74bBHMJkuCbslY8ixgLBVZJIOiQlQTjfQ==",
|
||||
"bin": true
|
||||
|
||||
@@ -292,12 +292,14 @@ function connectWebsocket(request: Request) {
|
||||
|
||||
}
|
||||
|
||||
const projectRoot = new URL('..', import.meta.url).pathname;
|
||||
|
||||
async function devServerWatchFiles() {
|
||||
const watcher = Deno.watchFs(["../static/", "../src/"]);
|
||||
for await (const event of watcher) {
|
||||
if (event.kind === "modify") {
|
||||
for (const path of event.paths) {
|
||||
const cachedPath = path.replace(Deno.cwd() + '/..', '')
|
||||
const cachedPath = path.replace(projectRoot, '/');
|
||||
filepathResponseCache.delete(cachedPath);
|
||||
console.log('Purging updated file:', cachedPath)
|
||||
}
|
||||
|
||||
257
src/App.ts
257
src/App.ts
@@ -1,8 +1,8 @@
|
||||
import { generateID } from "IDUtils";
|
||||
import { PeerManager, PeerEventTypes } from "PeerManager";
|
||||
import { Sync } from "Sync";
|
||||
import { openDatabase, getData, addData, addDataArray, clearData, deleteData, mergeDataArray, getAllData, checkPostIds, getAllIds, getPostsByIds, getPostForUser } from "db";
|
||||
import { arrayBufferToBase64, compressString } from "dataUtils";
|
||||
import { openDatabase, getData, addData, addDataArray, clearData, deleteData, mergeDataArray, getAllData, checkPostIds, getAllIds, getPostsByIds, getPostForUser, getPostById, getRepliesForPost, buildReplyCountMap, getNotificationsForUser } from "db";
|
||||
import { arrayBufferToBase64, compressString, decompressBuffer, base64ToArrayBuffer } from "dataUtils";
|
||||
import { log, logID, renderLog, setLogVisibility } from "log"
|
||||
|
||||
declare let marked: any;
|
||||
@@ -14,6 +14,7 @@ class Post {
|
||||
post_timestamp: Date;
|
||||
post_id: string;
|
||||
reply_to_id: string|null;
|
||||
root_id: string|null;
|
||||
author: string;
|
||||
author_id: string;
|
||||
text: string;
|
||||
@@ -29,7 +30,8 @@ class Post {
|
||||
imageData: ArrayBuffer | null = null,
|
||||
importedFrom: "twitter" | null = null,
|
||||
importSource: any = null,
|
||||
reply_to_id:string|null = null) {
|
||||
reply_to_id: string|null = null,
|
||||
root_id: string|null = null) {
|
||||
|
||||
this.post_timestamp = post_timestamp;
|
||||
this.post_id = generateID();
|
||||
@@ -42,6 +44,7 @@ class Post {
|
||||
this.importedFrom = importedFrom;
|
||||
this.importSource = importSource;
|
||||
this.reply_to_id = reply_to_id;
|
||||
this.root_id = root_id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,6 +123,7 @@ export class App {
|
||||
userID: string = '';
|
||||
peerID: string = '';
|
||||
replyToID: string|null = null;
|
||||
replyRootID: string|null = null;
|
||||
following: Set<string> = new Set();
|
||||
posts: StoragePost[] = [];
|
||||
isHeadless: boolean = false;
|
||||
@@ -524,8 +528,22 @@ export class App {
|
||||
globalThis.URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
async importPostsForUser(userID: string, posts: string) {
|
||||
async importPostsForUser(userID: string, buffer: ArrayBuffer) {
|
||||
console.log.apply(null, log("Importing posts"));
|
||||
const json = await decompressBuffer(buffer);
|
||||
const posts = JSON.parse(json);
|
||||
|
||||
for (let post of posts) {
|
||||
if (post.image_data && typeof post.image_data === 'string') {
|
||||
post.image_data = await base64ToArrayBuffer(post.image_data);
|
||||
}
|
||||
if (post.post_timestamp && typeof post.post_timestamp === 'string') {
|
||||
post.post_timestamp = new Date(post.post_timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
await mergeDataArray(userID, posts);
|
||||
console.log.apply(null, log(`Imported ${posts.length} posts`));
|
||||
}
|
||||
|
||||
async exportPostsForUser(userID: string) {
|
||||
@@ -723,7 +741,7 @@ export class App {
|
||||
}
|
||||
}
|
||||
|
||||
async createPost(userID: string, postText: string, mediaData?: ArrayBuffer, mimeType?: "image/svg+xml" | "image/png" | "image/gif" | "image/jpg" | "image/jpeg" | "video/mp4", replyToID:string|null = null) {
|
||||
async createPost(userID: string, postText: string, mediaData?: ArrayBuffer, mimeType?: "image/svg+xml" | "image/png" | "image/gif" | "image/jpg" | "image/jpeg" | "video/mp4", replyToID: string|null = null, replyRootID: string|null = null) {
|
||||
if ((typeof postText !== "string") || postText.length === 0) {
|
||||
console.log.apply(null, log("Not posting an empty string..."));
|
||||
return;
|
||||
@@ -738,7 +756,7 @@ export class App {
|
||||
}
|
||||
}
|
||||
|
||||
let post = new Post(this.username, userID, postText, new Date(), mediaData, null, null, replyToID);
|
||||
let post = new Post(this.username, userID, postText, new Date(), mediaData, null, null, replyToID, replyRootID);
|
||||
// this.posts.push(post);
|
||||
// localStorage.setItem(key, JSON.stringify(posts));
|
||||
addData(userID, post);
|
||||
@@ -916,6 +934,15 @@ export class App {
|
||||
});
|
||||
}
|
||||
|
||||
hideInfo() {
|
||||
const infoElement = document.getElementById('info');
|
||||
if (infoElement && infoElement.style.display !== 'none') {
|
||||
infoElement.style.display = 'none';
|
||||
setLogVisibility(false);
|
||||
this.showLog = false;
|
||||
}
|
||||
}
|
||||
|
||||
showInfo() {
|
||||
let infoElement = document.getElementById('info');
|
||||
|
||||
@@ -962,6 +989,15 @@ export class App {
|
||||
let profileButton = this.div('profile-button');
|
||||
profileButton.addEventListener('click', e => globalThis.location.href = `${globalThis.location.origin}/user/${this.userID}`)
|
||||
|
||||
let notificationsButton = this.div('notifications-button');
|
||||
notificationsButton.addEventListener('click', () => {
|
||||
this.hideInfo();
|
||||
navContainer.classList.remove('active');
|
||||
history.pushState({}, '', '/notifications');
|
||||
this.getRoute();
|
||||
this.render();
|
||||
});
|
||||
|
||||
let monitorButton = this.div('monitor_button');
|
||||
monitorButton.addEventListener('click', async () => {
|
||||
navContainer.classList.toggle('active');
|
||||
@@ -972,6 +1008,16 @@ export class App {
|
||||
let burgerMenuButton = this.div('burger-menu-button');
|
||||
burgerMenuButton.addEventListener('click', e => navContainer.classList.toggle('active'));
|
||||
|
||||
let importFilePicker = document.getElementById('import-file-input') as HTMLInputElement;
|
||||
importFilePicker?.addEventListener('change', async () => {
|
||||
const file = importFilePicker.files?.[0];
|
||||
if (!file) return;
|
||||
const buffer = await file.arrayBuffer();
|
||||
await this.importPostsForUser(this.userID, buffer);
|
||||
importFilePicker.value = '';
|
||||
this.render();
|
||||
});
|
||||
|
||||
let exportButton = this.button("export-button");
|
||||
exportButton.addEventListener('click', async e => {
|
||||
|
||||
@@ -988,7 +1034,7 @@ export class App {
|
||||
filePicker?.addEventListener('change', async (event: any) => {
|
||||
for (let file of filePicker.files as any) {
|
||||
let buffer = await file.arrayBuffer();
|
||||
await this.createPost(this.userID, 'image...', buffer, file.type);
|
||||
await this.createPost(this.userID, 'image...', buffer, file.type, this.replyToID, this.replyRootID);
|
||||
}
|
||||
|
||||
// Reset so that if they pick the same image again, we still get the change event.
|
||||
@@ -1047,12 +1093,21 @@ export class App {
|
||||
const dataTransfer = e.clipboardData
|
||||
const file = dataTransfer!.files[0];
|
||||
let buffer = await file.arrayBuffer();
|
||||
await this.createPost(this.userID, 'image...', buffer, file.type as any);
|
||||
await this.createPost(this.userID, 'image...', buffer, file.type as any, this.replyToID, this.replyRootID);
|
||||
});
|
||||
|
||||
postButton.addEventListener("click", () => {
|
||||
this.createPost(userID, postText.value, undefined, undefined, this.replyToID);
|
||||
const submitPost = () => {
|
||||
this.createPost(userID, postText.value, undefined, undefined, this.replyToID, this.replyRootID);
|
||||
this.exitCompose();
|
||||
};
|
||||
|
||||
postButton.addEventListener("click", submitPost);
|
||||
|
||||
postText.addEventListener("keydown", (e) => {
|
||||
if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
submitPost();
|
||||
}
|
||||
});
|
||||
|
||||
// updateApp.addEventListener("click", () => {
|
||||
@@ -1068,21 +1123,24 @@ export class App {
|
||||
|
||||
|
||||
// Change this all to a template so we're not toggling state in this crazy way!
|
||||
enterCompose(replyToID:string|null=null) {
|
||||
enterCompose(replyToID: string|null = null, replyRootID: string|null = null) {
|
||||
this.replyToID = replyToID;
|
||||
this.replyRootID = replyRootID;
|
||||
|
||||
if (replyToID) {
|
||||
this.renderComposeReplyArea(replyToID);
|
||||
document.getElementById("compose-reply-area")!.style.display = "block";
|
||||
}
|
||||
|
||||
replyToID = replyToID;
|
||||
|
||||
document.getElementById('compose')!.style.display = 'block';
|
||||
document.getElementById('compose')!.style.display = 'flex';
|
||||
document.getElementById('textarea_post')?.focus();
|
||||
document.getElementById('compose-dimmer')?.classList.add("compose-dimmer-dimmed");
|
||||
document.body.classList.add("no-scroll");
|
||||
}
|
||||
|
||||
exitCompose() {
|
||||
this.replyToID = null;
|
||||
this.replyRootID = null;
|
||||
let postText = document.getElementById("textarea_post") as HTMLTextAreaElement;
|
||||
postText.value = "";
|
||||
document.getElementById('compose')!.style.display = 'none';
|
||||
@@ -1276,6 +1334,8 @@ export class App {
|
||||
|
||||
await this.initDB();
|
||||
|
||||
window.addEventListener('popstate', () => { this.hideInfo(); this.getRoute(); this.render(); });
|
||||
|
||||
this.connectURL = `${document.location.origin}/connect/${this.userID}`;
|
||||
document.getElementById('connectURL')!.innerHTML = `<a href="${this.connectURL}">connect</a>`;
|
||||
|
||||
@@ -1420,6 +1480,11 @@ export class App {
|
||||
compose.style.display = "none";
|
||||
break;
|
||||
}
|
||||
case App.Route.NOTIFICATIONS: {
|
||||
this.posts = await getNotificationsForUser(this.userID);
|
||||
document.getElementById('compose')!.style.display = "none";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
console.log.apply(null, log("Render: got a route I didn't understand. Rendering HOME:", this.router.route));
|
||||
this.posts = await this.loadPostsFromStorage(this.userID) ?? [];
|
||||
@@ -1430,6 +1495,21 @@ export class App {
|
||||
if (!contentDiv) {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
if (this.router.route === App.Route.NOTIFICATIONS) {
|
||||
contentDiv.innerHTML = '';
|
||||
if (this.posts.length === 0) {
|
||||
contentDiv.innerHTML = '<div style="padding:20px;color:gray">No notifications yet.</div>';
|
||||
} else {
|
||||
let first = true;
|
||||
for (const postRecord of this.posts) {
|
||||
contentDiv.appendChild(this.renderNotificationItem(postRecord.data, first));
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.posts.length === 0) {
|
||||
this.renderWelcome(contentDiv as HTMLDivElement);
|
||||
return;
|
||||
@@ -1460,13 +1540,19 @@ export class App {
|
||||
contentDiv.innerHTML = "";
|
||||
let count = 0;
|
||||
|
||||
const isPostView = this.router.route === App.Route.POST;
|
||||
contentDiv.classList.toggle('post-view', isPostView);
|
||||
|
||||
const replyCountMap = await buildReplyCountMap();
|
||||
|
||||
this.renderedPosts.clear();
|
||||
let first = true;
|
||||
for (let i = this.posts.length - 1; i >= 0; i--) {
|
||||
let postData = this.posts[i];
|
||||
if (!isPostView && postData.data.reply_to_id) continue;
|
||||
// this.postsSet.add(postData);
|
||||
// TODO return promises for all image loads and await those.
|
||||
let post = this.renderPost(postData.data, first);
|
||||
let post = this.renderPost(postData.data, first, replyCountMap.recursive.get(postData.data.post_id) ?? 0);
|
||||
first = false;
|
||||
// this.renderedPosts.set(postData.post_id, post);
|
||||
if (post) {
|
||||
@@ -1485,6 +1571,39 @@ export class App {
|
||||
|
||||
contentDiv.appendChild(fragment);
|
||||
|
||||
if (isPostView && this.posts.length > 0) {
|
||||
const currentPost = this.posts[0].data;
|
||||
if (currentPost.root_id) {
|
||||
const rootRecord = await getPostById(currentPost.root_id);
|
||||
if (rootRecord) {
|
||||
const rootEl = this.renderPost(rootRecord.data, true, replyCountMap.recursive.get(rootRecord.data.post_id) ?? 0);
|
||||
contentDiv.insertBefore(rootEl, contentDiv.firstChild);
|
||||
}
|
||||
}
|
||||
|
||||
const renderReplies = async (postID: string, depth: number) => {
|
||||
if (depth > 2) return;
|
||||
const replies = await getRepliesForPost(postID);
|
||||
// Top-level replies: newest first. Nested replies: oldest first (readable order).
|
||||
if (depth === 0) {
|
||||
replies.sort((a, b) =>
|
||||
new Date(b.data.post_timestamp).getTime() - new Date(a.data.post_timestamp).getTime()
|
||||
);
|
||||
} else {
|
||||
replies.sort((a, b) =>
|
||||
new Date(a.data.post_timestamp).getTime() - new Date(b.data.post_timestamp).getTime()
|
||||
);
|
||||
}
|
||||
for (const reply of replies) {
|
||||
const el = this.renderPost(reply.data, false, replyCountMap.direct.get(reply.data.post_id) ?? 0);
|
||||
if (depth > 0) el.style.marginLeft = `${depth * 20}px`;
|
||||
contentDiv.appendChild(el);
|
||||
await renderReplies(reply.data.post_id, depth + 1);
|
||||
}
|
||||
};
|
||||
await renderReplies(this.posts[0].data.post_id, currentPost.root_id ? 1 : 0);
|
||||
}
|
||||
|
||||
let renderTime = this.timerDelta();
|
||||
|
||||
console.log.apply(null, log(`render took: ${renderTime.toFixed(2)}ms`));;
|
||||
@@ -1505,13 +1624,75 @@ export class App {
|
||||
this.render();
|
||||
}
|
||||
|
||||
renderComposeReplyArea(replyToID:string) {
|
||||
let composeReplyArea = document.getElementById('compose-reply-area') as HTMLElement;
|
||||
composeReplyArea.innerText = replyToID;
|
||||
composeReplyArea.classList.add("show");
|
||||
async renderComposeReplyArea(replyToID: string) {
|
||||
const composeReplyArea = document.getElementById('compose-reply-area') as HTMLElement;
|
||||
composeReplyArea.innerHTML = '';
|
||||
|
||||
const record = await getPostById(replyToID);
|
||||
if (!record) return;
|
||||
const postData = record.data;
|
||||
|
||||
const authorDiv = document.createElement('div');
|
||||
authorDiv.className = 'compose-reply-author';
|
||||
authorDiv.textContent = `@${postData.author}`;
|
||||
composeReplyArea.appendChild(authorDiv);
|
||||
|
||||
const previewDiv = document.createElement('div');
|
||||
previewDiv.className = 'compose-reply-preview';
|
||||
|
||||
const textDiv = document.createElement('div');
|
||||
textDiv.className = 'compose-reply-preview-text';
|
||||
textDiv.innerHTML = this.markedAvailable ? marked.parse(postData.text) : postData.text;
|
||||
previewDiv.appendChild(textDiv);
|
||||
|
||||
if (postData.image_data) {
|
||||
const img = document.createElement('img');
|
||||
img.className = 'compose-reply-preview-image';
|
||||
const blob = new Blob([postData.image_data as ArrayBuffer]);
|
||||
img.src = URL.createObjectURL(blob);
|
||||
previewDiv.appendChild(img);
|
||||
}
|
||||
|
||||
renderPost(post: Post, first: boolean) {
|
||||
composeReplyArea.appendChild(previewDiv);
|
||||
}
|
||||
|
||||
renderNotificationItem(post: Post, first: boolean): HTMLElement {
|
||||
const el = document.createElement('div');
|
||||
el.style.cssText = 'padding: 8px 10px; cursor: pointer;';
|
||||
if (!first) el.innerHTML = '<hr>';
|
||||
|
||||
const authorDiv = document.createElement('div');
|
||||
authorDiv.className = 'compose-reply-author';
|
||||
authorDiv.textContent = `@${post.author} · ${post.post_timestamp.toLocaleDateString()}`;
|
||||
el.appendChild(authorDiv);
|
||||
|
||||
const previewDiv = document.createElement('div');
|
||||
previewDiv.className = 'compose-reply-preview';
|
||||
|
||||
const textDiv = document.createElement('div');
|
||||
textDiv.className = 'compose-reply-preview-text';
|
||||
textDiv.style.maxHeight = 'none';
|
||||
textDiv.innerHTML = this.markedAvailable ? marked.parse(post.text) : post.text;
|
||||
previewDiv.appendChild(textDiv);
|
||||
|
||||
if (post.image_data) {
|
||||
const img = document.createElement('img');
|
||||
img.className = 'compose-reply-preview-image';
|
||||
img.src = URL.createObjectURL(new Blob([post.image_data as ArrayBuffer]));
|
||||
previewDiv.appendChild(img);
|
||||
}
|
||||
|
||||
el.appendChild(previewDiv);
|
||||
el.addEventListener('click', () => {
|
||||
history.pushState({}, '', `/user/${post.author_id}/post/${post.post_id}`);
|
||||
this.getRoute();
|
||||
this.render();
|
||||
});
|
||||
|
||||
return el;
|
||||
}
|
||||
|
||||
renderPost(post: Post, first: boolean, replyCount: number = 0) {
|
||||
if (!(post.hasOwnProperty("text"))) {
|
||||
throw new Error("Post is malformed!");
|
||||
}
|
||||
@@ -1530,13 +1711,11 @@ export class App {
|
||||
await navigator.clipboard.writeText(shareUrl)
|
||||
};
|
||||
|
||||
let replyButton = document.createElement('button'); replyButton.innerText = 'reply';
|
||||
let replyButton = document.createElement('button'); replyButton.innerText = replyCount > 0 ? `reply (${replyCount})` : 'reply';
|
||||
replyButton.onclick = async () => {
|
||||
console.log(`replying to post ${post.post_id}`);
|
||||
this.enterCompose(post.post_id);
|
||||
// let shareUrl = `${document.location.origin}/user/${post.author_id}/post/${post.post_id}`;
|
||||
|
||||
// await navigator.clipboard.writeText(shareUrl)
|
||||
const rootID = post.root_id ?? post.post_id;
|
||||
this.enterCompose(post.post_id, rootID);
|
||||
};
|
||||
|
||||
|
||||
@@ -1560,7 +1739,8 @@ export class App {
|
||||
let userURL = `${document.location.origin}/user/${post.author_id}/`
|
||||
|
||||
let postTemplate =
|
||||
`<div>${first ? '' : '<hr>'}
|
||||
`<div class="post-container">${first ? '' : '<hr>'}
|
||||
<div class="post-body">
|
||||
<div>
|
||||
<span class='header' title='${timestamp}'><img class="logo" src="/static/favicon.ico"><a class="username" href="${userURL}">@${post.author}</a> -
|
||||
<span style="color:rgb(128,128,128)">${post.post_timestamp.toLocaleDateString()}</span>
|
||||
@@ -1574,12 +1754,18 @@ export class App {
|
||||
${ownPost ? `<span id="editButton"></span>` : ''}
|
||||
<span id="shareButton"></span>
|
||||
${ownPost ? `<span id="deleteButton"></span>` : ''}
|
||||
|
||||
|
||||
</div>
|
||||
</div>`
|
||||
|
||||
containerDiv.innerHTML = postTemplate;
|
||||
|
||||
const postBody = containerDiv.querySelector('.post-body') as HTMLElement;
|
||||
postBody.addEventListener('click', (e) => {
|
||||
if ((e.target as HTMLElement).closest('button, a')) return;
|
||||
history.pushState({}, '', `/user/${post.author_id}/post/${post.post_id}`);
|
||||
this.getRoute();
|
||||
this.render();
|
||||
});
|
||||
|
||||
if (ownPost) {
|
||||
containerDiv.querySelector('#deleteButton')?.appendChild(deleteButton);
|
||||
@@ -1631,6 +1817,15 @@ export class App {
|
||||
let path = document.location.pathname;
|
||||
console.log.apply(null, log("router: path ", path));
|
||||
|
||||
if (path === '/notifications') {
|
||||
this.router.route = App.Route.NOTIFICATIONS;
|
||||
this.router.userID = '';
|
||||
this.router.postID = '';
|
||||
this.router.mediaID = '';
|
||||
console.log.apply(null, log("router: NOTIFICATIONS"));
|
||||
return;
|
||||
}
|
||||
|
||||
const regex = "(user/([a-zA-Z0-9\-]+)/?(post/([a-zA-Z0-9\-]+)?/?)?(media/([0-9]+)?)?)|(connect/([a-zA-Z0-9\-]+))";
|
||||
|
||||
const match = path.match(new RegExp(regex));
|
||||
@@ -1653,6 +1848,11 @@ export class App {
|
||||
this.router.route = App.Route.USER;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.router.route = App.Route.HOME;
|
||||
this.router.userID = '';
|
||||
this.router.postID = '';
|
||||
this.router.mediaID = '';
|
||||
}
|
||||
|
||||
console.log.apply(null, log("router: ", this.router.userID, this.router.postID, this.router.mediaID, App.Route[this.router.route]));
|
||||
@@ -1676,5 +1876,6 @@ export namespace App {
|
||||
GROUP = 8,
|
||||
HOME = 16,
|
||||
CONNECT = 32,
|
||||
NOTIFICATIONS = 64,
|
||||
}
|
||||
};
|
||||
@@ -39,6 +39,20 @@ export async function compressString(input: string) {
|
||||
return compressedArray;
|
||||
}
|
||||
|
||||
export async function decompressBuffer(input: ArrayBuffer): Promise<string> {
|
||||
const decompressionStream = new DecompressionStream('gzip');
|
||||
const writer = decompressionStream.writable.getWriter();
|
||||
writer.write(new Uint8Array(input));
|
||||
writer.close();
|
||||
const decompressedBuffer = await new Response(decompressionStream.readable).arrayBuffer();
|
||||
return new TextDecoder().decode(decompressedBuffer);
|
||||
}
|
||||
|
||||
export async function base64ToArrayBuffer(base64: string): Promise<ArrayBuffer> {
|
||||
const response = await fetch("data:application/octet-stream;base64," + base64);
|
||||
return response.arrayBuffer();
|
||||
}
|
||||
|
||||
// Base58 character set
|
||||
// const BASE58_ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
||||
// Base58 encoding
|
||||
|
||||
106
src/db.ts
106
src/db.ts
@@ -463,6 +463,112 @@ export async function getAllIds(userID: string): Promise<any | undefined> {
|
||||
});
|
||||
}
|
||||
|
||||
export async function buildReplyCountMap(): Promise<{ direct: Map<string, number>, recursive: Map<string, number> }> {
|
||||
const children = new Map<string, string[]>();
|
||||
const knownUsers = [...(await indexedDB.databases())]
|
||||
.map(db => db.name?.replace('user_', '')).filter(Boolean) as string[];
|
||||
for (const userID of knownUsers) {
|
||||
try {
|
||||
const { store } = await getDBTransactionStore(userID);
|
||||
const index = store.index("postReplyIndex");
|
||||
const replies: any[] = await new Promise((resolve, reject) => {
|
||||
const req = index.getAll();
|
||||
req.onsuccess = () => resolve(req.result);
|
||||
req.onerror = () => reject(req.error);
|
||||
});
|
||||
for (const r of replies) {
|
||||
const parentID = r.data.reply_to_id;
|
||||
const replyID = r.data.post_id;
|
||||
if (parentID && replyID) {
|
||||
if (!children.has(parentID)) children.set(parentID, []);
|
||||
children.get(parentID)!.push(replyID);
|
||||
}
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
const direct = new Map<string, number>();
|
||||
for (const [parentID, kids] of children) {
|
||||
direct.set(parentID, kids.length);
|
||||
}
|
||||
|
||||
const countDescendants = (postID: string): number => {
|
||||
const kids = children.get(postID) ?? [];
|
||||
return kids.reduce((sum, kid) => sum + 1 + countDescendants(kid), 0);
|
||||
};
|
||||
|
||||
const recursive = new Map<string, number>();
|
||||
for (const postID of children.keys()) {
|
||||
recursive.set(postID, countDescendants(postID));
|
||||
}
|
||||
|
||||
return { direct, recursive };
|
||||
}
|
||||
|
||||
export async function getPostById(postID: string): Promise<any | undefined> {
|
||||
const knownUsers = [...(await indexedDB.databases())]
|
||||
.map(db => db.name?.replace('user_', '')).filter(Boolean) as string[];
|
||||
for (const userID of knownUsers) {
|
||||
try {
|
||||
const { store } = await getDBTransactionStore(userID);
|
||||
const index = store.index("postIDIndex");
|
||||
const result: any = await new Promise((resolve, reject) => {
|
||||
const req = index.get(postID);
|
||||
req.onsuccess = () => resolve(req.result);
|
||||
req.onerror = () => reject(req.error);
|
||||
});
|
||||
if (result) return result;
|
||||
} catch (_) {}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export async function getRepliesForPost(postID: string): Promise<any[]> {
|
||||
const knownUsers = [...(await indexedDB.databases())]
|
||||
.map(db => db.name?.replace('user_', '')).filter(Boolean) as string[];
|
||||
let replies: any[] = [];
|
||||
for (const userID of knownUsers) {
|
||||
try {
|
||||
const { store } = await getDBTransactionStore(userID);
|
||||
const index = store.index("postReplyIndex");
|
||||
const results: any[] = await new Promise((resolve, reject) => {
|
||||
const req = index.getAll(postID);
|
||||
req.onsuccess = () => resolve(req.result);
|
||||
req.onerror = () => reject(req.error);
|
||||
});
|
||||
replies = replies.concat(results);
|
||||
} catch (_) {}
|
||||
}
|
||||
return replies;
|
||||
}
|
||||
|
||||
export async function getNotificationsForUser(userID: string): Promise<any[]> {
|
||||
const userPostIds = new Set(await getAllIds(userID));
|
||||
const knownUsers = [...(await indexedDB.databases())]
|
||||
.map(db => db.name?.replace('user_', '')).filter(Boolean) as string[];
|
||||
let notifications: any[] = [];
|
||||
for (const dbUserID of knownUsers) {
|
||||
try {
|
||||
const { store } = await getDBTransactionStore(dbUserID);
|
||||
const index = store.index("postReplyIndex");
|
||||
const results: any[] = await new Promise((resolve, reject) => {
|
||||
const req = index.getAll();
|
||||
req.onsuccess = () => resolve(req.result);
|
||||
req.onerror = () => reject(req.error);
|
||||
});
|
||||
for (const r of results) {
|
||||
if (r.data.reply_to_id && userPostIds.has(r.data.reply_to_id)) {
|
||||
notifications.push(r);
|
||||
}
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
notifications.sort((a, b) =>
|
||||
new Date(b.data.post_timestamp).getTime() - new Date(a.data.post_timestamp).getTime()
|
||||
);
|
||||
return notifications;
|
||||
}
|
||||
|
||||
export async function getPostsByIds(userID: string, postIDs: string[]) {
|
||||
const { store } = await getDBTransactionStore(userID);
|
||||
const index = store.index("postIDIndex");
|
||||
|
||||
104
src/sw.ts
104
src/sw.ts
@@ -38,102 +38,44 @@ self.addEventListener("install", (e: any) => {
|
||||
});
|
||||
|
||||
|
||||
async function staleWhileRevalidate(event: any) {
|
||||
|
||||
let cache = await caches.open(cacheName);
|
||||
|
||||
let response = await cache.match(event.request);
|
||||
|
||||
if (response) {
|
||||
debugLog ? console.log('Service Worker: Cache hit', event.request.url) : null;
|
||||
}
|
||||
|
||||
const fetchPromise = (async () => {
|
||||
debugLog ? console.log('Service Worker: Fetching', event.request.url) : null;
|
||||
|
||||
let networkResponse = null;
|
||||
async function fetchAndUpdateCache(request: Request): Promise<Response> {
|
||||
debugLog && console.log('Service Worker: Fetching', request.url);
|
||||
let networkResponse: Response;
|
||||
try {
|
||||
networkResponse = await fetch(event.request);
|
||||
networkResponse = await fetch(request);
|
||||
} catch (e) {
|
||||
debugLog ? console.log('Service Worker: Failed to fetch', e) : null;
|
||||
|
||||
debugLog && console.log('Service Worker: Failed to fetch', e);
|
||||
return new Response('Network error occurred', {
|
||||
status: 404,
|
||||
statusText: 'Cache miss and fetch failed',
|
||||
headers: { 'Content-Type': 'text/plain' }
|
||||
});
|
||||
}
|
||||
|
||||
debugLog ? console.log('Service Worker: Updating cache', event.request.url) : null;
|
||||
|
||||
debugLog && console.log('Service Worker: Updating cache', request.url);
|
||||
const cache = await caches.open(cacheName);
|
||||
try {
|
||||
await cache.put(event.request, networkResponse.clone());
|
||||
await cache.put(request, networkResponse.clone());
|
||||
} catch (e) {
|
||||
debugLog ? console.log('Service Worker: failed to update cache', event.request.url, e) : null;
|
||||
|
||||
debugLog && console.log('Service Worker: failed to update cache', request.url, e);
|
||||
}
|
||||
|
||||
debugLog ? console.log('Service Worker: Returning networkResponse', event.request.url) : null;
|
||||
return networkResponse;
|
||||
})();
|
||||
|
||||
|
||||
debugLog ? console.log('Service Worker: Returning return response || fetchPromise', event.request.url) : null;
|
||||
return response || fetchPromise;
|
||||
|
||||
// if (networkResponse) {
|
||||
// cache.put(event.request, networkResponse.clone())
|
||||
// return networkResponse;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// caches.open(cacheName)
|
||||
// .then(function (cache) {
|
||||
// return cache.match(event.request)
|
||||
// .then(function (response) {
|
||||
// var fetchPromise = fetch(event.request)
|
||||
// .then(function (networkResponse) {
|
||||
// cache.put(event.request, networkResponse.clone());
|
||||
// return networkResponse;
|
||||
// });
|
||||
// return response || fetchPromise;
|
||||
// });
|
||||
// })
|
||||
}
|
||||
|
||||
// async function responder(event: any) {
|
||||
// debugLog ? console.log('Fetching', event.request.url) : null;
|
||||
|
||||
// let response = await fetch(event.request);
|
||||
|
||||
// if (!response) {
|
||||
// debugLog ? console.log('Fetch failed, falling back to cache', event.request.url) : null;
|
||||
// let cacheMatch = await caches.match(event.request);
|
||||
// if (!cacheMatch) {
|
||||
// // DUnno what to return here!
|
||||
// }
|
||||
// return cacheMatch;
|
||||
// }
|
||||
|
||||
// if (response.status === 206) {
|
||||
// debugLog ? console.log('Not caching partial content') : null;
|
||||
// return response;
|
||||
// }
|
||||
|
||||
// debugLog ? console.log('Fetch successful, updating cache', event.request.url) : null;
|
||||
// const cache = await caches.open(cacheName);
|
||||
// try {
|
||||
// cache.put(event.request, response.clone()).catch((error) => debugLog ? console.log('failed to cache', event.request, error)) : null;
|
||||
// } catch (e) {
|
||||
// console.log('failed to cache', event.request)
|
||||
// }
|
||||
// return response;
|
||||
// }
|
||||
|
||||
self.addEventListener('fetch', function (event: any) {
|
||||
event.respondWith(staleWhileRevalidate(event));
|
||||
// event.respondWith(responder(event));
|
||||
const networkFetch = fetchAndUpdateCache(event.request);
|
||||
|
||||
event.respondWith(async function () {
|
||||
const cache = await caches.open(cacheName);
|
||||
const cached = await cache.match(event.request);
|
||||
if (cached) {
|
||||
debugLog && console.log('Service Worker: Cache hit', event.request.url);
|
||||
return cached;
|
||||
}
|
||||
return networkFetch;
|
||||
}());
|
||||
|
||||
// Keep the SW alive until the background cache update finishes
|
||||
event.waitUntil(networkFetch);
|
||||
});
|
||||
|
||||
addEventListener("message", async (e) => {
|
||||
|
||||
231
static/App.js
231
static/App.js
@@ -1,11 +1,11 @@
|
||||
import { generateID } from "IDUtils";
|
||||
import { PeerManager, PeerEventTypes } from "PeerManager";
|
||||
import { Sync } from "Sync";
|
||||
import { openDatabase, getData, addData, deleteData, getAllData, getPostForUser } from "db";
|
||||
import { arrayBufferToBase64, compressString } from "dataUtils";
|
||||
import { openDatabase, getData, addData, deleteData, mergeDataArray, getAllData, getPostForUser, getPostById, getRepliesForPost, buildReplyCountMap, getNotificationsForUser } from "db";
|
||||
import { arrayBufferToBase64, compressString, decompressBuffer, base64ToArrayBuffer } from "dataUtils";
|
||||
import { log, logID, renderLog, setLogVisibility } from "log";
|
||||
class Post {
|
||||
constructor(author, author_id, text, post_timestamp, imageData = null, importedFrom = null, importSource = null, reply_to_id = null) {
|
||||
constructor(author, author_id, text, post_timestamp, imageData = null, importedFrom = null, importSource = null, reply_to_id = null, root_id = null) {
|
||||
this.post_timestamp = post_timestamp;
|
||||
this.post_id = generateID();
|
||||
this.author = author;
|
||||
@@ -15,6 +15,7 @@ class Post {
|
||||
this.importedFrom = importedFrom;
|
||||
this.importSource = importSource;
|
||||
this.reply_to_id = reply_to_id;
|
||||
this.root_id = root_id;
|
||||
}
|
||||
}
|
||||
class StatusBar {
|
||||
@@ -70,6 +71,7 @@ export class App {
|
||||
this.userID = '';
|
||||
this.peerID = '';
|
||||
this.replyToID = null;
|
||||
this.replyRootID = null;
|
||||
this.following = new Set();
|
||||
this.posts = [];
|
||||
this.isHeadless = false;
|
||||
@@ -382,7 +384,20 @@ export class App {
|
||||
document.body.removeChild(link);
|
||||
globalThis.URL.revokeObjectURL(url);
|
||||
}
|
||||
async importPostsForUser(userID, posts) {
|
||||
async importPostsForUser(userID, buffer) {
|
||||
console.log.apply(null, log("Importing posts"));
|
||||
const json = await decompressBuffer(buffer);
|
||||
const posts = JSON.parse(json);
|
||||
for (let post of posts) {
|
||||
if (post.image_data && typeof post.image_data === 'string') {
|
||||
post.image_data = await base64ToArrayBuffer(post.image_data);
|
||||
}
|
||||
if (post.post_timestamp && typeof post.post_timestamp === 'string') {
|
||||
post.post_timestamp = new Date(post.post_timestamp);
|
||||
}
|
||||
}
|
||||
await mergeDataArray(userID, posts);
|
||||
console.log.apply(null, log(`Imported ${posts.length} posts`));
|
||||
}
|
||||
async exportPostsForUser(userID) {
|
||||
let posts = await getAllData(userID);
|
||||
@@ -525,7 +540,7 @@ export class App {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
async createPost(userID, postText, mediaData, mimeType, replyToID = null) {
|
||||
async createPost(userID, postText, mediaData, mimeType, replyToID = null, replyRootID = null) {
|
||||
if ((typeof postText !== "string") || postText.length === 0) {
|
||||
console.log.apply(null, log("Not posting an empty string..."));
|
||||
return;
|
||||
@@ -538,7 +553,7 @@ export class App {
|
||||
mediaData = compressedImage;
|
||||
}
|
||||
}
|
||||
let post = new Post(this.username, userID, postText, new Date(), mediaData, null, null, replyToID);
|
||||
let post = new Post(this.username, userID, postText, new Date(), mediaData, null, null, replyToID, replyRootID);
|
||||
// this.posts.push(post);
|
||||
// localStorage.setItem(key, JSON.stringify(posts));
|
||||
addData(userID, post);
|
||||
@@ -679,6 +694,14 @@ export class App {
|
||||
correctLevel: QRCode.CorrectLevel.H
|
||||
});
|
||||
}
|
||||
hideInfo() {
|
||||
const infoElement = document.getElementById('info');
|
||||
if (infoElement && infoElement.style.display !== 'none') {
|
||||
infoElement.style.display = 'none';
|
||||
setLogVisibility(false);
|
||||
this.showLog = false;
|
||||
}
|
||||
}
|
||||
showInfo() {
|
||||
let infoElement = document.getElementById('info');
|
||||
if (infoElement === null) {
|
||||
@@ -715,6 +738,14 @@ export class App {
|
||||
homeButton.addEventListener('click', e => globalThis.location.href = `${globalThis.location.origin}/`);
|
||||
let profileButton = this.div('profile-button');
|
||||
profileButton.addEventListener('click', e => globalThis.location.href = `${globalThis.location.origin}/user/${this.userID}`);
|
||||
let notificationsButton = this.div('notifications-button');
|
||||
notificationsButton.addEventListener('click', () => {
|
||||
this.hideInfo();
|
||||
navContainer.classList.remove('active');
|
||||
history.pushState({}, '', '/notifications');
|
||||
this.getRoute();
|
||||
this.render();
|
||||
});
|
||||
let monitorButton = this.div('monitor_button');
|
||||
monitorButton.addEventListener('click', async () => {
|
||||
navContainer.classList.toggle('active');
|
||||
@@ -723,6 +754,16 @@ export class App {
|
||||
let navContainer = this.div('nav-container');
|
||||
let burgerMenuButton = this.div('burger-menu-button');
|
||||
burgerMenuButton.addEventListener('click', e => navContainer.classList.toggle('active'));
|
||||
let importFilePicker = document.getElementById('import-file-input');
|
||||
importFilePicker?.addEventListener('change', async () => {
|
||||
const file = importFilePicker.files?.[0];
|
||||
if (!file)
|
||||
return;
|
||||
const buffer = await file.arrayBuffer();
|
||||
await this.importPostsForUser(this.userID, buffer);
|
||||
importFilePicker.value = '';
|
||||
this.render();
|
||||
});
|
||||
let exportButton = this.button("export-button");
|
||||
exportButton.addEventListener('click', async (e) => {
|
||||
await this.exportPostsForUser(this.userID);
|
||||
@@ -735,7 +776,7 @@ export class App {
|
||||
filePicker?.addEventListener('change', async (event) => {
|
||||
for (let file of filePicker.files) {
|
||||
let buffer = await file.arrayBuffer();
|
||||
await this.createPost(this.userID, 'image...', buffer, file.type);
|
||||
await this.createPost(this.userID, 'image...', buffer, file.type, this.replyToID, this.replyRootID);
|
||||
}
|
||||
// Reset so that if they pick the same image again, we still get the change event.
|
||||
filePicker.value = '';
|
||||
@@ -779,11 +820,18 @@ export class App {
|
||||
const dataTransfer = e.clipboardData;
|
||||
const file = dataTransfer.files[0];
|
||||
let buffer = await file.arrayBuffer();
|
||||
await this.createPost(this.userID, 'image...', buffer, file.type);
|
||||
await this.createPost(this.userID, 'image...', buffer, file.type, this.replyToID, this.replyRootID);
|
||||
});
|
||||
postButton.addEventListener("click", () => {
|
||||
this.createPost(userID, postText.value, undefined, undefined, this.replyToID);
|
||||
const submitPost = () => {
|
||||
this.createPost(userID, postText.value, undefined, undefined, this.replyToID, this.replyRootID);
|
||||
this.exitCompose();
|
||||
};
|
||||
postButton.addEventListener("click", submitPost);
|
||||
postText.addEventListener("keydown", (e) => {
|
||||
if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
submitPost();
|
||||
}
|
||||
});
|
||||
// updateApp.addEventListener("click", () => {
|
||||
// registration?.active?.postMessage({ type: "update_app" });
|
||||
@@ -793,18 +841,21 @@ export class App {
|
||||
// });
|
||||
}
|
||||
// Change this all to a template so we're not toggling state in this crazy way!
|
||||
enterCompose(replyToID = null) {
|
||||
enterCompose(replyToID = null, replyRootID = null) {
|
||||
this.replyToID = replyToID;
|
||||
this.replyRootID = replyRootID;
|
||||
if (replyToID) {
|
||||
this.renderComposeReplyArea(replyToID);
|
||||
document.getElementById("compose-reply-area").style.display = "block";
|
||||
}
|
||||
replyToID = replyToID;
|
||||
document.getElementById('compose').style.display = 'block';
|
||||
document.getElementById('compose').style.display = 'flex';
|
||||
document.getElementById('textarea_post')?.focus();
|
||||
document.getElementById('compose-dimmer')?.classList.add("compose-dimmer-dimmed");
|
||||
document.body.classList.add("no-scroll");
|
||||
}
|
||||
exitCompose() {
|
||||
this.replyToID = null;
|
||||
this.replyRootID = null;
|
||||
let postText = document.getElementById("textarea_post");
|
||||
postText.value = "";
|
||||
document.getElementById('compose').style.display = 'none';
|
||||
@@ -940,6 +991,7 @@ export class App {
|
||||
this.sync.setArchive(this.isArchivePeer);
|
||||
this.connect();
|
||||
await this.initDB();
|
||||
window.addEventListener('popstate', () => { this.hideInfo(); this.getRoute(); this.render(); });
|
||||
this.connectURL = `${document.location.origin}/connect/${this.userID}`;
|
||||
document.getElementById('connectURL').innerHTML = `<a href="${this.connectURL}">connect</a>`;
|
||||
let time = 0;
|
||||
@@ -1040,6 +1092,11 @@ export class App {
|
||||
compose.style.display = "none";
|
||||
break;
|
||||
}
|
||||
case App.Route.NOTIFICATIONS: {
|
||||
this.posts = await getNotificationsForUser(this.userID);
|
||||
document.getElementById('compose').style.display = "none";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
console.log.apply(null, log("Render: got a route I didn't understand. Rendering HOME:", this.router.route));
|
||||
this.posts = await this.loadPostsFromStorage(this.userID) ?? [];
|
||||
@@ -1050,6 +1107,20 @@ export class App {
|
||||
if (!contentDiv) {
|
||||
throw new Error();
|
||||
}
|
||||
if (this.router.route === App.Route.NOTIFICATIONS) {
|
||||
contentDiv.innerHTML = '';
|
||||
if (this.posts.length === 0) {
|
||||
contentDiv.innerHTML = '<div style="padding:20px;color:gray">No notifications yet.</div>';
|
||||
}
|
||||
else {
|
||||
let first = true;
|
||||
for (const postRecord of this.posts) {
|
||||
contentDiv.appendChild(this.renderNotificationItem(postRecord.data, first));
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (this.posts.length === 0) {
|
||||
this.renderWelcome(contentDiv);
|
||||
return;
|
||||
@@ -1072,13 +1143,18 @@ export class App {
|
||||
const fragment = document.createDocumentFragment();
|
||||
contentDiv.innerHTML = "";
|
||||
let count = 0;
|
||||
const isPostView = this.router.route === App.Route.POST;
|
||||
contentDiv.classList.toggle('post-view', isPostView);
|
||||
const replyCountMap = await buildReplyCountMap();
|
||||
this.renderedPosts.clear();
|
||||
let first = true;
|
||||
for (let i = this.posts.length - 1; i >= 0; i--) {
|
||||
let postData = this.posts[i];
|
||||
if (!isPostView && postData.data.reply_to_id)
|
||||
continue;
|
||||
// this.postsSet.add(postData);
|
||||
// TODO return promises for all image loads and await those.
|
||||
let post = this.renderPost(postData.data, first);
|
||||
let post = this.renderPost(postData.data, first, replyCountMap.recursive.get(postData.data.post_id) ?? 0);
|
||||
first = false;
|
||||
// this.renderedPosts.set(postData.post_id, post);
|
||||
if (post) {
|
||||
@@ -1093,6 +1169,36 @@ export class App {
|
||||
throw new Error("Couldn't get content div!");
|
||||
}
|
||||
contentDiv.appendChild(fragment);
|
||||
if (isPostView && this.posts.length > 0) {
|
||||
const currentPost = this.posts[0].data;
|
||||
if (currentPost.root_id) {
|
||||
const rootRecord = await getPostById(currentPost.root_id);
|
||||
if (rootRecord) {
|
||||
const rootEl = this.renderPost(rootRecord.data, true, replyCountMap.recursive.get(rootRecord.data.post_id) ?? 0);
|
||||
contentDiv.insertBefore(rootEl, contentDiv.firstChild);
|
||||
}
|
||||
}
|
||||
const renderReplies = async (postID, depth) => {
|
||||
if (depth > 2)
|
||||
return;
|
||||
const replies = await getRepliesForPost(postID);
|
||||
// Top-level replies: newest first. Nested replies: oldest first (readable order).
|
||||
if (depth === 0) {
|
||||
replies.sort((a, b) => new Date(b.data.post_timestamp).getTime() - new Date(a.data.post_timestamp).getTime());
|
||||
}
|
||||
else {
|
||||
replies.sort((a, b) => new Date(a.data.post_timestamp).getTime() - new Date(b.data.post_timestamp).getTime());
|
||||
}
|
||||
for (const reply of replies) {
|
||||
const el = this.renderPost(reply.data, false, replyCountMap.direct.get(reply.data.post_id) ?? 0);
|
||||
if (depth > 0)
|
||||
el.style.marginLeft = `${depth * 20}px`;
|
||||
contentDiv.appendChild(el);
|
||||
await renderReplies(reply.data.post_id, depth + 1);
|
||||
}
|
||||
};
|
||||
await renderReplies(this.posts[0].data.post_id, currentPost.root_id ? 1 : 0);
|
||||
}
|
||||
let renderTime = this.timerDelta();
|
||||
console.log.apply(null, log(`render took: ${renderTime.toFixed(2)}ms`));
|
||||
;
|
||||
@@ -1106,12 +1212,63 @@ export class App {
|
||||
deleteData(userID, postID);
|
||||
this.render();
|
||||
}
|
||||
renderComposeReplyArea(replyToID) {
|
||||
let composeReplyArea = document.getElementById('compose-reply-area');
|
||||
composeReplyArea.innerText = replyToID;
|
||||
composeReplyArea.classList.add("show");
|
||||
async renderComposeReplyArea(replyToID) {
|
||||
const composeReplyArea = document.getElementById('compose-reply-area');
|
||||
composeReplyArea.innerHTML = '';
|
||||
const record = await getPostById(replyToID);
|
||||
if (!record)
|
||||
return;
|
||||
const postData = record.data;
|
||||
const authorDiv = document.createElement('div');
|
||||
authorDiv.className = 'compose-reply-author';
|
||||
authorDiv.textContent = `@${postData.author}`;
|
||||
composeReplyArea.appendChild(authorDiv);
|
||||
const previewDiv = document.createElement('div');
|
||||
previewDiv.className = 'compose-reply-preview';
|
||||
const textDiv = document.createElement('div');
|
||||
textDiv.className = 'compose-reply-preview-text';
|
||||
textDiv.innerHTML = this.markedAvailable ? marked.parse(postData.text) : postData.text;
|
||||
previewDiv.appendChild(textDiv);
|
||||
if (postData.image_data) {
|
||||
const img = document.createElement('img');
|
||||
img.className = 'compose-reply-preview-image';
|
||||
const blob = new Blob([postData.image_data]);
|
||||
img.src = URL.createObjectURL(blob);
|
||||
previewDiv.appendChild(img);
|
||||
}
|
||||
renderPost(post, first) {
|
||||
composeReplyArea.appendChild(previewDiv);
|
||||
}
|
||||
renderNotificationItem(post, first) {
|
||||
const el = document.createElement('div');
|
||||
el.style.cssText = 'padding: 8px 10px; cursor: pointer;';
|
||||
if (!first)
|
||||
el.innerHTML = '<hr>';
|
||||
const authorDiv = document.createElement('div');
|
||||
authorDiv.className = 'compose-reply-author';
|
||||
authorDiv.textContent = `@${post.author} · ${post.post_timestamp.toLocaleDateString()}`;
|
||||
el.appendChild(authorDiv);
|
||||
const previewDiv = document.createElement('div');
|
||||
previewDiv.className = 'compose-reply-preview';
|
||||
const textDiv = document.createElement('div');
|
||||
textDiv.className = 'compose-reply-preview-text';
|
||||
textDiv.style.maxHeight = 'none';
|
||||
textDiv.innerHTML = this.markedAvailable ? marked.parse(post.text) : post.text;
|
||||
previewDiv.appendChild(textDiv);
|
||||
if (post.image_data) {
|
||||
const img = document.createElement('img');
|
||||
img.className = 'compose-reply-preview-image';
|
||||
img.src = URL.createObjectURL(new Blob([post.image_data]));
|
||||
previewDiv.appendChild(img);
|
||||
}
|
||||
el.appendChild(previewDiv);
|
||||
el.addEventListener('click', () => {
|
||||
history.pushState({}, '', `/user/${post.author_id}/post/${post.post_id}`);
|
||||
this.getRoute();
|
||||
this.render();
|
||||
});
|
||||
return el;
|
||||
}
|
||||
renderPost(post, first, replyCount = 0) {
|
||||
if (!(post.hasOwnProperty("text"))) {
|
||||
throw new Error("Post is malformed!");
|
||||
}
|
||||
@@ -1128,12 +1285,11 @@ export class App {
|
||||
await navigator.clipboard.writeText(shareUrl);
|
||||
};
|
||||
let replyButton = document.createElement('button');
|
||||
replyButton.innerText = 'reply';
|
||||
replyButton.innerText = replyCount > 0 ? `reply (${replyCount})` : 'reply';
|
||||
replyButton.onclick = async () => {
|
||||
console.log(`replying to post ${post.post_id}`);
|
||||
this.enterCompose(post.post_id);
|
||||
// let shareUrl = `${document.location.origin}/user/${post.author_id}/post/${post.post_id}`;
|
||||
// await navigator.clipboard.writeText(shareUrl)
|
||||
const rootID = post.root_id ?? post.post_id;
|
||||
this.enterCompose(post.post_id, rootID);
|
||||
};
|
||||
let ownPost = post.author_id === this.userID;
|
||||
let markdown = post.text;
|
||||
@@ -1148,7 +1304,8 @@ export class App {
|
||||
markdown = markdown.replace("<iframe", `<iframe style="width:100%;height:50px;display:none" onblur="this.style.display = 'inline';"`);
|
||||
}
|
||||
let userURL = `${document.location.origin}/user/${post.author_id}/`;
|
||||
let postTemplate = `<div>${first ? '' : '<hr>'}
|
||||
let postTemplate = `<div class="post-container">${first ? '' : '<hr>'}
|
||||
<div class="post-body">
|
||||
<div>
|
||||
<span class='header' title='${timestamp}'><img class="logo" src="/static/favicon.ico"><a class="username" href="${userURL}">@${post.author}</a> -
|
||||
<span style="color:rgb(128,128,128)">${post.post_timestamp.toLocaleDateString()}</span>
|
||||
@@ -1162,10 +1319,17 @@ export class App {
|
||||
${ownPost ? `<span id="editButton"></span>` : ''}
|
||||
<span id="shareButton"></span>
|
||||
${ownPost ? `<span id="deleteButton"></span>` : ''}
|
||||
|
||||
|
||||
</div>
|
||||
</div>`;
|
||||
containerDiv.innerHTML = postTemplate;
|
||||
const postBody = containerDiv.querySelector('.post-body');
|
||||
postBody.addEventListener('click', (e) => {
|
||||
if (e.target.closest('button, a'))
|
||||
return;
|
||||
history.pushState({}, '', `/user/${post.author_id}/post/${post.post_id}`);
|
||||
this.getRoute();
|
||||
this.render();
|
||||
});
|
||||
if (ownPost) {
|
||||
containerDiv.querySelector('#deleteButton')?.appendChild(deleteButton);
|
||||
// containerDiv.querySelector('#editButton')?.appendChild(editButton);
|
||||
@@ -1197,6 +1361,14 @@ export class App {
|
||||
getRoute() {
|
||||
let path = document.location.pathname;
|
||||
console.log.apply(null, log("router: path ", path));
|
||||
if (path === '/notifications') {
|
||||
this.router.route = App.Route.NOTIFICATIONS;
|
||||
this.router.userID = '';
|
||||
this.router.postID = '';
|
||||
this.router.mediaID = '';
|
||||
console.log.apply(null, log("router: NOTIFICATIONS"));
|
||||
return;
|
||||
}
|
||||
const regex = "(user/([a-zA-Z0-9\-]+)/?(post/([a-zA-Z0-9\-]+)?/?)?(media/([0-9]+)?)?)|(connect/([a-zA-Z0-9\-]+))";
|
||||
const match = path.match(new RegExp(regex));
|
||||
if (match) {
|
||||
@@ -1219,6 +1391,12 @@ export class App {
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.router.route = App.Route.HOME;
|
||||
this.router.userID = '';
|
||||
this.router.postID = '';
|
||||
this.router.mediaID = '';
|
||||
}
|
||||
console.log.apply(null, log("router: ", this.router.userID, this.router.postID, this.router.mediaID, App.Route[this.router.route]));
|
||||
// user = /user/<ID>
|
||||
// post = /user/<ID>/post/<ID>
|
||||
@@ -1237,6 +1415,7 @@ export class App {
|
||||
Route[Route["GROUP"] = 8] = "GROUP";
|
||||
Route[Route["HOME"] = 16] = "HOME";
|
||||
Route[Route["CONNECT"] = 32] = "CONNECT";
|
||||
Route[Route["NOTIFICATIONS"] = 64] = "NOTIFICATIONS";
|
||||
})(Route = App.Route || (App.Route = {}));
|
||||
})(App || (App = {}));
|
||||
;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -31,6 +31,18 @@ export async function compressString(input) {
|
||||
// Convert the compressed data to a Uint8Array
|
||||
return compressedArray;
|
||||
}
|
||||
export async function decompressBuffer(input) {
|
||||
const decompressionStream = new DecompressionStream('gzip');
|
||||
const writer = decompressionStream.writable.getWriter();
|
||||
writer.write(new Uint8Array(input));
|
||||
writer.close();
|
||||
const decompressedBuffer = await new Response(decompressionStream.readable).arrayBuffer();
|
||||
return new TextDecoder().decode(decompressedBuffer);
|
||||
}
|
||||
export async function base64ToArrayBuffer(base64) {
|
||||
const response = await fetch("data:application/octet-stream;base64," + base64);
|
||||
return response.arrayBuffer();
|
||||
}
|
||||
// Base58 character set
|
||||
// const BASE58_ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
||||
// Base58 encoding
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"dataUtils.js","sourceRoot":"","sources":["../src/dataUtils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,KAA8B,EAAE,IAAI,GAAG,0BAA0B;IAC1G,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,EAAE,EAAE;YAC7C,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;YACpC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;SACpC,CAAC,CAAC;QACH,MAAM,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,MAAmB;IAC3D,IAAI,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACnC,OAAO,CAAC,MAAM,oBAAoB,CAAC,KAAK,CAAY,CAAA,CAAC,OAAO,CAAC,uCAAuC,EAAE,EAAE,CAAC,CAAC;AAC5G,CAAC;AAED,6DAA6D;AAC7D,wFAAwF;AACxF,oDAAoD;AACpD,wBAAwB;AACxB,IAAI;AAEJ,MAAM,CAAC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;AACR,MAAM;AAEN,mBAAmB;AACnB,IAAI;AAEJ,4BAA4B;AAC5B,gDAAgD;AAChD,qCAAqC;AACrC,gCAAgC;AAChC,IAAI"}
|
||||
102
static/db.js
102
static/db.js
@@ -356,6 +356,108 @@ export async function getAllIds(userID) {
|
||||
};
|
||||
});
|
||||
}
|
||||
export async function buildReplyCountMap() {
|
||||
const children = new Map();
|
||||
const knownUsers = [...(await indexedDB.databases())]
|
||||
.map(db => db.name?.replace('user_', '')).filter(Boolean);
|
||||
for (const userID of knownUsers) {
|
||||
try {
|
||||
const { store } = await getDBTransactionStore(userID);
|
||||
const index = store.index("postReplyIndex");
|
||||
const replies = await new Promise((resolve, reject) => {
|
||||
const req = index.getAll();
|
||||
req.onsuccess = () => resolve(req.result);
|
||||
req.onerror = () => reject(req.error);
|
||||
});
|
||||
for (const r of replies) {
|
||||
const parentID = r.data.reply_to_id;
|
||||
const replyID = r.data.post_id;
|
||||
if (parentID && replyID) {
|
||||
if (!children.has(parentID))
|
||||
children.set(parentID, []);
|
||||
children.get(parentID).push(replyID);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (_) { }
|
||||
}
|
||||
const direct = new Map();
|
||||
for (const [parentID, kids] of children) {
|
||||
direct.set(parentID, kids.length);
|
||||
}
|
||||
const countDescendants = (postID) => {
|
||||
const kids = children.get(postID) ?? [];
|
||||
return kids.reduce((sum, kid) => sum + 1 + countDescendants(kid), 0);
|
||||
};
|
||||
const recursive = new Map();
|
||||
for (const postID of children.keys()) {
|
||||
recursive.set(postID, countDescendants(postID));
|
||||
}
|
||||
return { direct, recursive };
|
||||
}
|
||||
export async function getPostById(postID) {
|
||||
const knownUsers = [...(await indexedDB.databases())]
|
||||
.map(db => db.name?.replace('user_', '')).filter(Boolean);
|
||||
for (const userID of knownUsers) {
|
||||
try {
|
||||
const { store } = await getDBTransactionStore(userID);
|
||||
const index = store.index("postIDIndex");
|
||||
const result = await new Promise((resolve, reject) => {
|
||||
const req = index.get(postID);
|
||||
req.onsuccess = () => resolve(req.result);
|
||||
req.onerror = () => reject(req.error);
|
||||
});
|
||||
if (result)
|
||||
return result;
|
||||
}
|
||||
catch (_) { }
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
export async function getRepliesForPost(postID) {
|
||||
const knownUsers = [...(await indexedDB.databases())]
|
||||
.map(db => db.name?.replace('user_', '')).filter(Boolean);
|
||||
let replies = [];
|
||||
for (const userID of knownUsers) {
|
||||
try {
|
||||
const { store } = await getDBTransactionStore(userID);
|
||||
const index = store.index("postReplyIndex");
|
||||
const results = await new Promise((resolve, reject) => {
|
||||
const req = index.getAll(postID);
|
||||
req.onsuccess = () => resolve(req.result);
|
||||
req.onerror = () => reject(req.error);
|
||||
});
|
||||
replies = replies.concat(results);
|
||||
}
|
||||
catch (_) { }
|
||||
}
|
||||
return replies;
|
||||
}
|
||||
export async function getNotificationsForUser(userID) {
|
||||
const userPostIds = new Set(await getAllIds(userID));
|
||||
const knownUsers = [...(await indexedDB.databases())]
|
||||
.map(db => db.name?.replace('user_', '')).filter(Boolean);
|
||||
let notifications = [];
|
||||
for (const dbUserID of knownUsers) {
|
||||
try {
|
||||
const { store } = await getDBTransactionStore(dbUserID);
|
||||
const index = store.index("postReplyIndex");
|
||||
const results = await new Promise((resolve, reject) => {
|
||||
const req = index.getAll();
|
||||
req.onsuccess = () => resolve(req.result);
|
||||
req.onerror = () => reject(req.error);
|
||||
});
|
||||
for (const r of results) {
|
||||
if (r.data.reply_to_id && userPostIds.has(r.data.reply_to_id)) {
|
||||
notifications.push(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (_) { }
|
||||
}
|
||||
notifications.sort((a, b) => new Date(b.data.post_timestamp).getTime() - new Date(a.data.post_timestamp).getTime());
|
||||
return notifications;
|
||||
}
|
||||
export async function getPostsByIds(userID, postIDs) {
|
||||
const { store } = await getDBTransactionStore(userID);
|
||||
const index = store.index("postIDIndex");
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -3,7 +3,7 @@
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1, interactive-widget=resizes-content">
|
||||
|
||||
<title>Dandelion</title>
|
||||
|
||||
@@ -58,6 +58,10 @@
|
||||
<span class="nav-emoji emoji-fill" role="img" aria-label="Home">🏠</span>
|
||||
<span class="nav-label">Home</span>
|
||||
</a>
|
||||
<a class="nav-item" id="notifications-button">
|
||||
<span class="nav-emoji emoji-fill" role="img" aria-label="Notifications">🔔</span>
|
||||
<span class="nav-label">Notifications</span>
|
||||
</a>
|
||||
<!-- <a class="nav-item">
|
||||
<span class="nav-emoji" role="img" aria-label="Search">🔍</span>
|
||||
<span class="nav-label">Search</span>
|
||||
@@ -87,6 +91,8 @@
|
||||
|
||||
<div id="info" style="display:none">
|
||||
<button id="export-button">export</button>
|
||||
<label for="import-file-input" id="import-button" class="button">import</label>
|
||||
<input type="file" id="import-file-input" accept=".gz" style="display:none">
|
||||
|
||||
<div id="profile">
|
||||
<span class="form_label">username:</span><span class="form_field" id="username"
|
||||
@@ -129,7 +135,10 @@
|
||||
|
||||
|
||||
<div id="compose">
|
||||
<div id="compose-header">
|
||||
<div id="button_cancel_post" class="link">Cancel</div>
|
||||
<button id="button_post" class="button button-big">post</button>
|
||||
</div>
|
||||
|
||||
<div id="compose-reply-area"></div>
|
||||
<textarea cols="60" rows="6" id="textarea_post"></textarea>
|
||||
@@ -138,11 +147,6 @@
|
||||
<label for="file-input" id="file-input-label" class="button button-big">photo</label>
|
||||
<input type="file" id="file-input" accept="image/*" multiple style="display:none">
|
||||
</div>
|
||||
|
||||
<div class="compose-right-buttons">
|
||||
<!-- <button id="button_add_pic" >🏞️</button> -->
|
||||
<button id="button_post" class="button button-big">post</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
101
static/main.css
101
static/main.css
@@ -4,7 +4,9 @@
|
||||
|
||||
:root {
|
||||
--main-bg-color: white;
|
||||
--main-hover-color: rgb(64, 64, 64) --border-color: rgb(132, 136, 138);
|
||||
--main-hover-color: rgb(64, 64, 64);
|
||||
--post-hover-color: rgb(32,32,32);
|
||||
--border-color: rgb(132, 136, 138);
|
||||
--edge-color: rgb(60, 60, 60);
|
||||
--main-fg-color: black;
|
||||
--highlight-fg-color: rgb(255, 255, 255);
|
||||
@@ -124,6 +126,24 @@ hr {
|
||||
|
||||
.postImage {
|
||||
width: 100%;
|
||||
max-height: 500px;
|
||||
object-fit: contain;
|
||||
object-position: left;
|
||||
}
|
||||
|
||||
.post-view .postImage {
|
||||
max-height: none;
|
||||
}
|
||||
|
||||
.post-body {
|
||||
border-radius: 4px;
|
||||
padding: 4px;
|
||||
transition: background-color 0.1s;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.post-body:hover {
|
||||
background-color: var(--post-hover-color);
|
||||
}
|
||||
|
||||
#log {
|
||||
@@ -277,6 +297,7 @@ iframe {
|
||||
|
||||
#compose {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
position: fixed;
|
||||
top: 5%;
|
||||
left: 50%;
|
||||
@@ -296,8 +317,84 @@ iframe {
|
||||
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
#compose-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
|
||||
@media (pointer: coarse) {
|
||||
#compose {
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100dvh;
|
||||
max-height: 100dvh;
|
||||
box-sizing: border-box;
|
||||
overflow-y: hidden;
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
#textarea_post {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
height: auto;
|
||||
max-height: none;
|
||||
resize: none;
|
||||
border: none;
|
||||
}
|
||||
|
||||
#textarea_post:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
#compose-reply-area {
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
#compose-reply-area {
|
||||
display: none;
|
||||
padding: 8px 10px;
|
||||
margin-bottom: 8px;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
|
||||
.compose-reply-author {
|
||||
font-weight: bold;
|
||||
font-size: 0.85em;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.compose-reply-preview {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.compose-reply-preview-text {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
max-height: 80px;
|
||||
}
|
||||
|
||||
.compose-reply-preview-text iframe {
|
||||
height: 68px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.compose-reply-preview-image {
|
||||
width: 96px;
|
||||
height: 96px;
|
||||
max-width: 96px;
|
||||
max-height: 96px;
|
||||
object-fit: cover;
|
||||
object-position: top;
|
||||
border-radius: 4px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.show {
|
||||
@@ -322,7 +419,7 @@ iframe {
|
||||
/* border-right: 1px solid rgb(60, 60, 60); */
|
||||
/* transition: width 0.3s; */
|
||||
overflow: hidden;
|
||||
width: 130px;
|
||||
width: 185px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
|
||||
81
static/sw.js
81
static/sw.js
@@ -30,82 +30,43 @@ self.addEventListener("install", (e) => {
|
||||
}
|
||||
})());
|
||||
});
|
||||
async function staleWhileRevalidate(event) {
|
||||
let cache = await caches.open(cacheName);
|
||||
let response = await cache.match(event.request);
|
||||
if (response) {
|
||||
debugLog ? console.log('Service Worker: Cache hit', event.request.url) : null;
|
||||
}
|
||||
const fetchPromise = (async () => {
|
||||
debugLog ? console.log('Service Worker: Fetching', event.request.url) : null;
|
||||
let networkResponse = null;
|
||||
async function fetchAndUpdateCache(request) {
|
||||
debugLog && console.log('Service Worker: Fetching', request.url);
|
||||
let networkResponse;
|
||||
try {
|
||||
networkResponse = await fetch(event.request);
|
||||
networkResponse = await fetch(request);
|
||||
}
|
||||
catch (e) {
|
||||
debugLog ? console.log('Service Worker: Failed to fetch', e) : null;
|
||||
debugLog && console.log('Service Worker: Failed to fetch', e);
|
||||
return new Response('Network error occurred', {
|
||||
status: 404,
|
||||
statusText: 'Cache miss and fetch failed',
|
||||
headers: { 'Content-Type': 'text/plain' }
|
||||
});
|
||||
}
|
||||
debugLog ? console.log('Service Worker: Updating cache', event.request.url) : null;
|
||||
debugLog && console.log('Service Worker: Updating cache', request.url);
|
||||
const cache = await caches.open(cacheName);
|
||||
try {
|
||||
await cache.put(event.request, networkResponse.clone());
|
||||
await cache.put(request, networkResponse.clone());
|
||||
}
|
||||
catch (e) {
|
||||
debugLog ? console.log('Service Worker: failed to update cache', event.request.url, e) : null;
|
||||
debugLog && console.log('Service Worker: failed to update cache', request.url, e);
|
||||
}
|
||||
debugLog ? console.log('Service Worker: Returning networkResponse', event.request.url) : null;
|
||||
return networkResponse;
|
||||
})();
|
||||
debugLog ? console.log('Service Worker: Returning return response || fetchPromise', event.request.url) : null;
|
||||
return response || fetchPromise;
|
||||
// if (networkResponse) {
|
||||
// cache.put(event.request, networkResponse.clone())
|
||||
// return networkResponse;
|
||||
// }
|
||||
// caches.open(cacheName)
|
||||
// .then(function (cache) {
|
||||
// return cache.match(event.request)
|
||||
// .then(function (response) {
|
||||
// var fetchPromise = fetch(event.request)
|
||||
// .then(function (networkResponse) {
|
||||
// cache.put(event.request, networkResponse.clone());
|
||||
// return networkResponse;
|
||||
// });
|
||||
// return response || fetchPromise;
|
||||
// });
|
||||
// })
|
||||
}
|
||||
// async function responder(event: any) {
|
||||
// debugLog ? console.log('Fetching', event.request.url) : null;
|
||||
// let response = await fetch(event.request);
|
||||
// if (!response) {
|
||||
// debugLog ? console.log('Fetch failed, falling back to cache', event.request.url) : null;
|
||||
// let cacheMatch = await caches.match(event.request);
|
||||
// if (!cacheMatch) {
|
||||
// // DUnno what to return here!
|
||||
// }
|
||||
// return cacheMatch;
|
||||
// }
|
||||
// if (response.status === 206) {
|
||||
// debugLog ? console.log('Not caching partial content') : null;
|
||||
// return response;
|
||||
// }
|
||||
// debugLog ? console.log('Fetch successful, updating cache', event.request.url) : null;
|
||||
// const cache = await caches.open(cacheName);
|
||||
// try {
|
||||
// cache.put(event.request, response.clone()).catch((error) => debugLog ? console.log('failed to cache', event.request, error)) : null;
|
||||
// } catch (e) {
|
||||
// console.log('failed to cache', event.request)
|
||||
// }
|
||||
// return response;
|
||||
// }
|
||||
self.addEventListener('fetch', function (event) {
|
||||
event.respondWith(staleWhileRevalidate(event));
|
||||
// event.respondWith(responder(event));
|
||||
const networkFetch = fetchAndUpdateCache(event.request);
|
||||
event.respondWith(async function () {
|
||||
const cache = await caches.open(cacheName);
|
||||
const cached = await cache.match(event.request);
|
||||
if (cached) {
|
||||
debugLog && console.log('Service Worker: Cache hit', event.request.url);
|
||||
return cached;
|
||||
}
|
||||
return networkFetch;
|
||||
}());
|
||||
// Keep the SW alive until the background cache update finishes
|
||||
event.waitUntil(networkFetch);
|
||||
});
|
||||
addEventListener("message", async (e) => {
|
||||
debugLog ? console.log(`Message received:`, e.data) : null;
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"sw.js","sourceRoot":"","sources":["../src/sw.ts"],"names":[],"mappings":";AAAA,MAAM,QAAQ,GAAG,KAAK,CAAC;AACvB,yBAAyB;AACzB,MAAM,SAAS,GAAG,oBAAoB,CAAC;AAEvC,MAAM,cAAc,GAAG;IACrB,oBAAoB;IACpB,kBAAkB;IAClB,kBAAkB;IAClB,2BAA2B;IAC3B,2BAA2B;IAC3B,eAAe;IACf,wBAAwB;IACxB,oBAAoB;IACpB,sBAAsB;IACtB,gBAAgB;IAChB,iBAAiB;IACjB,oBAAoB;IACpB,gBAAgB;IAChB,qB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