checkpoint
This commit is contained in:
@@ -385,7 +385,7 @@ class wsConnection {
|
||||
knownUsers = knownUsers
|
||||
.filter(userID => this.shouldSyncUserID(userID))
|
||||
.filter(userID => !this.userBlockList.has(userID))
|
||||
.filter(async (userID) => (await getAllIds(userID)).length > 0); // TODO getting all the IDs is unecessary, replace it with a test to get a single ID.
|
||||
.filter(async (userID) => (await getAllIds(userID)).length > 0); // TODO:EASYOPT getting all the IDs is unecessary, replace it with a test to get a single ID.
|
||||
console.log('Net: Sending known users', knownUsers.map(userID => logID(userID ?? "")));
|
||||
return await this.send({ type: "hello", user_id: this.userID, user_name: app.username, peer_id: this.peerID, peer_name: app.peername, known_users: knownUsers });
|
||||
}
|
||||
@@ -448,7 +448,7 @@ class wsConnection {
|
||||
this.websocket.onopen = async (event) => {
|
||||
log("ws:connected");
|
||||
await this.sendHello();
|
||||
// If we're running as a headless peer, send a hello message every 60 seconds to refresh the posts we have.
|
||||
// If we're running as a headless peer, send a hello message every N seconds to refresh the posts we have.
|
||||
let helloRefreshIntervalPeriod = 120;
|
||||
if (app.isHeadless) {
|
||||
console.log("wsConnection: Setting hello refresh interval to ", helloRefreshIntervalPeriod);
|
||||
@@ -906,29 +906,45 @@ class App {
|
||||
document.querySelector('#qrcode > canvas').classList.add('qrcode_image');
|
||||
this.showLog = true;
|
||||
}
|
||||
button(elementName) {
|
||||
return document.getElementById(elementName);
|
||||
}
|
||||
div(elementName) {
|
||||
return document.getElementById(elementName);
|
||||
}
|
||||
initButtons(userID, posts, registration) {
|
||||
// let font1Button = document.getElementById("button_font1") as HTMLButtonElement;
|
||||
// let font2Button = document.getElementById("button_font2") as HTMLButtonElement;
|
||||
// let importTweetsButton = document.getElementById("import_tweets") as HTMLButtonElement;
|
||||
let exportButton = document.getElementById("export_button");
|
||||
// let toggleDark = document.getElementById('toggle_dark') as HTMLButtonElement;
|
||||
// let clearPostsButton = document.getElementById("clear_posts") as HTMLButtonElement;
|
||||
// let updateApp = document.getElementById("update_app") as HTMLButtonElement;
|
||||
// let ddlnLogoButton = document.getElementById('ddln_logo_button') as HTMLDivElement;
|
||||
let monitorButton = document.getElementById('monitor_button');
|
||||
let composeButton = document.getElementById('compose_button');
|
||||
// let addPic = document.getElementById('button_add_pic') as HTMLDivElement;
|
||||
let filePickerLabel = document.getElementById('file_input_label');
|
||||
let filePicker = document.getElementById('file_input');
|
||||
// let toggleDark = document.getElementById('toggle_dark') as HTMLButtonElement;
|
||||
exportButton.addEventListener('click', async (e) => await this.exportPostsForUser(this.userID));
|
||||
// toggleDark.addEventListener('click', () => {
|
||||
// document.documentElement.style.setProperty('--main-bg-color', 'white');
|
||||
// document.documentElement.style.setProperty('--main-fg-color', 'black');
|
||||
// })
|
||||
let homeButton = this.div('home-button');
|
||||
homeButton.addEventListener('click', e => window.location.href = `${window.location.origin}/`);
|
||||
let profileButton = this.div('profile-button');
|
||||
profileButton.addEventListener('click', e => window.location.href = `${window.location.origin}/user/${this.userID}`);
|
||||
let monitorButton = this.div('monitor_button');
|
||||
monitorButton.addEventListener('click', async () => {
|
||||
navContainer.classList.toggle('active');
|
||||
this.showInfo();
|
||||
});
|
||||
let navContainer = this.div('nav-container');
|
||||
let burgerMenuButton = this.div('burger-menu-button');
|
||||
burgerMenuButton.addEventListener('click', e => navContainer.classList.toggle('active'));
|
||||
let exportButton = this.button("export-button");
|
||||
exportButton.addEventListener('click', async (e) => await this.exportPostsForUser(this.userID));
|
||||
let composeButton = this.div('compose-button');
|
||||
composeButton.addEventListener('click', e => {
|
||||
document.getElementById('compose').style.display = 'block';
|
||||
document.getElementById('textarea_post')?.focus();
|
||||
});
|
||||
let filePicker = document.getElementById('file-input');
|
||||
filePicker?.addEventListener('change', async (event) => {
|
||||
for (let file of filePicker.files) {
|
||||
let buffer = await file.arrayBuffer();
|
||||
@@ -937,6 +953,7 @@ class App {
|
||||
// Reset so that if they pick the same image again, we still get the change event.
|
||||
filePicker.value = '';
|
||||
});
|
||||
let filePickerLabel = document.getElementById('file-input-label');
|
||||
filePickerLabel?.addEventListener('click', () => {
|
||||
console.log("Add pic...");
|
||||
});
|
||||
@@ -983,15 +1000,12 @@ class App {
|
||||
// ddlnLogoButton.addEventListener('click', async () => {
|
||||
// this.showInfo()
|
||||
// });
|
||||
monitorButton.addEventListener('click', async () => {
|
||||
this.showInfo();
|
||||
});
|
||||
}
|
||||
async getPostsForFeed() {
|
||||
// get N posts from each user and sort them by date.
|
||||
// This isn't really going to work very well.
|
||||
// Eventually we'll need a db that only has followed user posts so we can get them chronologically
|
||||
//
|
||||
//
|
||||
let posts = [];
|
||||
for (let followedID of this.following.keys()) {
|
||||
posts = posts.concat(await getData(followedID, new Date(2022, 8), new Date()));
|
||||
@@ -1002,6 +1016,7 @@ class App {
|
||||
return posts;
|
||||
}
|
||||
async loadFollowersFromStorage(userID) {
|
||||
// Rob
|
||||
if (userID === 'b38b623c-c3fa-4351-9cab-50233c99fa4e') {
|
||||
return [
|
||||
'b38b623c-c3fa-4351-9cab-50233c99fa4e',
|
||||
@@ -1012,18 +1027,27 @@ class App {
|
||||
'8f6802be-c3b6-46c1-969c-5f90cbe01479', // Fiona
|
||||
];
|
||||
}
|
||||
// Martin
|
||||
if (userID === '05a495a0-0dd8-4186-94c3-b8309ba6fc4c') {
|
||||
return [
|
||||
'b38b623c-c3fa-4351-9cab-50233c99fa4e',
|
||||
'a0e42390-08b5-4b07-bc2b-787f8e5f1297', // BMO
|
||||
];
|
||||
}
|
||||
// Fiona
|
||||
if (userID === '8f6802be-c3b6-46c1-969c-5f90cbe01479') {
|
||||
return [
|
||||
'b38b623c-c3fa-4351-9cab-50233c99fa4e', // Rob
|
||||
'a0e42390-08b5-4b07-bc2b-787f8e5f1297', // BMO
|
||||
'05a495a0-0dd8-4186-94c3-b8309ba6fc4c', // Martin
|
||||
];
|
||||
}
|
||||
return ['a0e42390-08b5-4b07-bc2b-787f8e5f1297']; // Follow BMO by default :)
|
||||
}
|
||||
async loadPostsFromStorage(userID, postID) {
|
||||
this.timerStart();
|
||||
let posts = [];
|
||||
// if (postID) {
|
||||
// if (postID) {
|
||||
// posts = await gePostForUser(userID, postID);
|
||||
// }
|
||||
posts = await getData(userID, new Date(2022, 8), new Date());
|
||||
@@ -1052,7 +1076,7 @@ class App {
|
||||
// indexedDB.deleteDatabase(`user_${userID}`);
|
||||
// continue;
|
||||
// }
|
||||
console.log(`https://ddln.app/user/${userID}`);
|
||||
console.log(`${document.location.origin}/user/${userID}`);
|
||||
// console.log(`https://ddln.app/${this.username}/${uuidToBase58(userID)}`, userID);
|
||||
}
|
||||
}
|
||||
@@ -1165,7 +1189,7 @@ class App {
|
||||
this.userID = this.getUserID();
|
||||
this.username = this.getUsername();
|
||||
await this.initDB();
|
||||
this.connectURL = `https://${document.location.hostname}/connect/${this.userID}`;
|
||||
this.connectURL = `${document.location.origin}/connect/${this.userID}`;
|
||||
document.getElementById('connectURL').innerHTML = `<a href="${this.connectURL}">connect</a>`;
|
||||
let urlParams = (new URL(window.location.href)).searchParams;
|
||||
if (urlParams.has('log')) {
|
||||
@@ -1358,7 +1382,7 @@ class App {
|
||||
let shareButton = document.createElement('button');
|
||||
shareButton.innerText = 'share';
|
||||
shareButton.onclick = async () => {
|
||||
let shareUrl = `https://${document.location.hostname}/user/${post.author_id}/post/${post.post_id}`;
|
||||
let shareUrl = `${document.location.origin}/user/${post.author_id}/post/${post.post_id}`;
|
||||
await navigator.clipboard.writeText(shareUrl);
|
||||
};
|
||||
let ownPost = post.author_id === this.userID;
|
||||
@@ -1373,7 +1397,7 @@ class App {
|
||||
if (markdown.includes("<iframe") && markdown.includes(`src="https://dotbigbang`)) {
|
||||
markdown = markdown.replace("<iframe", `<iframe style="width:100%;height:50px;display:none" onblur="this.style.display = 'inline';"`);
|
||||
}
|
||||
let userURL = `https://${document.location.hostname}/user/${post.author_id}/`;
|
||||
let userURL = `${document.location.origin}/user/${post.author_id}/`;
|
||||
let postTemplate = `<div>${first ? '' : '<hr>'}
|
||||
<div>
|
||||
<span class='header' title='${timestamp}'><img class="logo" src="/static/favicon.ico"><a class="username" href="${userURL}">@${post.author}</a> -
|
||||
|
||||
Reference in New Issue
Block a user