Skip to content

Commit

Permalink
Many small bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
soapdog committed Sep 9, 2022
1 parent 92792f2 commit 4835635
Show file tree
Hide file tree
Showing 10 changed files with 3,531 additions and 936 deletions.
1 change: 0 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ app.on("ready", () => {
// load default identity and start
try {
let defaultIdentity = getDefaultIdentity()
console.log("default identity", defaultIdentity)
if (defaultIdentity.startServer) {
startServer(defaultIdentity)
} else if (defaultIdentity) {
Expand Down
4,392 changes: 3,490 additions & 902 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"ssb-keys": "^8.2.0",
"ssb-lan": "^1.2.3",
"ssb-logging": "^1.0.0",
"ssb-markdown": "^4.0.1",
"ssb-markdown": "^6.0.7",
"ssb-marked": "^0.7.4",
"ssb-master": "^1.0.3",
"ssb-meme": "^1.1.0",
Expand Down
13 changes: 11 additions & 2 deletions ui/core/kernel/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const defaultPreferencesContent = `
#
[Preferences]
theme = "light"
textSize = "prose-lg"
textSize = "prose"
limit = "40"
[MessageTypes]
Expand Down Expand Up @@ -52,10 +52,12 @@ const preferencesFileExists = () => {

if (fileExists) {
const data = TOML.parse(fs.readFileSync(prefsFile))
console.log(data)
if (data?.Preferences?.defaultIdentity &&
data[data?.Preferences?.defaultIdentity]?.id) {
return true
} else if (data?.preferences?.defaultIdentity &&
data[data?.preferences?.defaultIdentity]?.id) {
return true
}
}

Expand All @@ -75,6 +77,11 @@ const loadSavedData = async () => {
const data = TOML.parse(fs.readFileSync(prefsFile))

if (data) {
if (data.hasOwnProperty("preferences")) {
// old prefs file, migrate
data.Preferences = data.preferences
delete data.preferences
}
savedData = data
} else {
throw "Bad patchfox.toml"
Expand All @@ -95,6 +102,8 @@ const getPref = (key, defaultValue, namespace = "Preferences") => {
// by the first-time setup.
if (preferencesFileExists()) {
savedData = TOML.parse(fs.readFileSync(prefsFile))
} else {
initialisePreferencesFileIfNeeded()
}
}

Expand Down
31 changes: 13 additions & 18 deletions ui/core/platforms/nodejs-db1/ssb.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,23 +154,21 @@ class NodeJsDB1 {
}

async public(opts) {
console.time("ssb.public")
opts = opts || {}
opts.reverse = opts.reverse || true

const pipeline = pipelines.thread.get()
const filter = opts.filter
let selectedFilter
console.time("Getting friends graph")
// console.time("Getting friends graph")
let friends = await friendship.friendsAsArray(sbot.id)
console.timeEnd("Getting friends graph")
console.time("Getting following graph")
// console.timeEnd("Getting friends graph")
// console.time("Getting following graph")
let following = await friendship.followingAsArray(sbot.id)
console.timeEnd("Getting following graph")
// console.timeEnd("Getting following graph")

// console.log("friends", friends)
// console.log("following", following)

// console.log("friends", friends)
// console.log("following", following)

// so you don't filter yourself out.
friends.push(sbot.id)
Expand Down Expand Up @@ -204,8 +202,6 @@ class NodeJsDB1 {
// })
// }, 5),
pull.collect((err, msgs) => {
console.timeEnd("ssb.public")

if (err) {
reject(err)
}
Expand Down Expand Up @@ -623,25 +619,24 @@ class NodeJsDB1 {
function replaceFeedID(match, id, offset, string) {
let eid = encodeURIComponent(`@${id}`)
return (
// eslint-disable-next-line quotes
'<a class="link link-accent profile-link" href="?pkg=contacts&view=profile&feed=' + eid + identity
`<a class="link link-accent profile-link" href="?pkg=contacts&view=profile&feed=` + eid + identity
)
}

function replaceImageLinks(match, id, offset, string) {
return `<a class="link link-accent image-link" target="_blank" href="${patchfox.httpUrl("/blobs/get/&")}` + encodeURIComponent(id)
return `<a class="link link-accent image-link" target="_blank" href="${patchfox.httpUrl("/blobs/get/&")}` + id
}

function replaceImages(match, id, offset, string) {
return `<img class="is-image-from-blob" src="${patchfox.httpUrl("/blobs/get/&")}` + encodeURIComponent(id)
return `<img class="is-image-from-blob" src="${patchfox.httpUrl("/blobs/get/&")}` + id
}

function replaceVideos(match, id, offset, string) {
return `<video controls class="is-video-from-blob" src="${patchfox.httpUrl("/blobs/get/&")}` + encodeURIComponent(id)
return `<video controls class="is-video-from-blob" src="${patchfox.httpUrl("/blobs/get/&")}` + id
}

function replaceAudios(match, id, offset, string) {
return `<audio controls class="is-audio-from-blob" src="${patchfox.httpUrl("/blobs/get/&")}` + encodeURIComponent(id)
return `<audio controls class="is-audio-from-blob" src="${patchfox.httpUrl("/blobs/get/&")}` + id
}

let opts = {
Expand All @@ -657,8 +652,8 @@ class NodeJsDB1 {
.replace(/target="_blank"/gi, "")
.replace(/<a href="%([^"]*)/gi, replaceMsgID)
.replace(/<img src="&([^"]*)/gi, replaceImages)
.replace(/<video controls src="&([^"]*)/gi, replaceVideos)
.replace(/<audio controls src="&([^"]*)/gi, replaceAudios)
.replace(/<video src="&([^"]*)/gi, replaceVideos)
.replace(/<audio src="&([^"]*)/gi, replaceAudios)
.replace(/<a href="&([^"]*)/gi, replaceImageLinks)
.replace(/<a href="([^"]*)/gi, replaceLinks)

Expand Down
1 change: 0 additions & 1 deletion ui/packages/firstTimeSetup/FirstTimeSetupView.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const CustomKeys = {
view: vnode => {
let enabled = vnode.state.remote.length > 0 && vnode.state.keys

console.log("disabled", enabled)
const selectedFile = ev => {
const secretFile = ev.target.files[0]
const reader = new FileReader()
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/hub/Public.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const PublicView = {
.public(opts)
.then(ms => {
console.timeEnd("public timeline")
console.log(ms)
// console.log(ms)
vnode.state.msgs = ms
window.scrollTo(0, 0)
vnode.state.loadingPhase = "loaded"
Expand Down
6 changes: 1 addition & 5 deletions ui/packages/hub/Thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ const ThreadView = {
let el = document.querySelector(`[data-key='${thread}']`)

if (el && !vnode.state.scrolledIntoView) {
console.log("scrolling")
el.scrollIntoView({behavior: "smooth", block: "end", inline: "nearest"})
vnode.state.scrolledIntoView = true
} else {
console.log("not", el)
}

},
Expand All @@ -33,17 +30,16 @@ const ThreadView = {

patchfox.title(thread)

vnode.state.shouldLoadMessages = false
ssb
.thread(thread)
.then((ms) => {
vnode.state.msgs = ms
vnode.state.shouldLoadMessages = false
m.redraw()
})
.catch((n) => {
console.dir(n)
vnode.state.error = n.message
vnode.state.shouldLoadMessages = false
if (n.message.indexOf("stream is closed") !== -1) {
location.reload()
}
Expand Down
13 changes: 11 additions & 2 deletions ui/packages/post/PostCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,17 @@ const PostCompose = {
if (vnode.state.showPreview) {
return m("div", [
m("h2.uppercase.font-medium.text-md", "Post Preview"),
m(".prose", [when(vnode.state.channel, m("p.text-md", `Channel: ${vnode.state.channel.startsWith("#") ? vnode.state.channel.slice(1) : vnode.state.channel}`)), when(vnode.state.root, m("p.text-md", `Root: ${vnode.state.root}`)), when(vnode.state.branch, m("p.text-md", `In Reply To: ${vnode.state.branch}`)), when(vnode.state.contentWarning.length > 0, m("p.text-md", `Content Warning: ${vnode.state.contentWarning}`))]),
m.trust(ssb.markdown(vnode.state.content)),
m(".prose", [
when(vnode.state.channel,
m("p.text-md", `Channel: ${vnode.state.channel.startsWith("#") ? vnode.state.channel.slice(1) : vnode.state.channel}`)),
when(vnode.state.root,
m("p.text-md", `Root: ${vnode.state.root}`)),
when(vnode.state.branch,
m("p.text-md", `In Reply To: ${vnode.state.branch}`)),
when(vnode.state.contentWarning.length > 0,
m("p.text-md", `Content Warning: ${vnode.state.contentWarning}`))
]),
m(".prose", m.trust(ssb.markdown(vnode.state.content))),
m(".divider"),
m(".alert.alert-warning", [
m(".flex-1", m("label", "This message will be public and can't be edited or deleted")),
Expand Down
6 changes: 3 additions & 3 deletions ui/packages/statusBar/statusBarView.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const checkVersion = async () => {
let releases = await (await fetch("https://api.github.com/repos/soapdog/patchfox/releases")).json()
let latestRelease = releases[0]

console.log("latestRelease", latestRelease)
console.log("localVersion", localVersion)
// console.log("latestRelease", latestRelease)
// console.log("localVersion", localVersion)

if (latestRelease.name !== localVersion) {
document.getElementById("version").innerHTML = `v${localVersion} (update available: <a class="underline" target="_blank" href="${latestRelease.html_url}">${latestRelease.name}</a>)`
Expand Down Expand Up @@ -74,7 +74,7 @@ const StatusBarView = {
vnode.state.peers = []
setInterval(() => checkIndexing(vnode), 300)
setInterval(() => countPeers(vnode), 300)
checkVersion()
// checkVersion()
},

view: vnode => {
Expand Down

0 comments on commit 4835635

Please sign in to comment.