M avatar.js => avatar.js +3 -3
@@ 8,9 8,9 @@ import { make, find } from './blob.js'
import { blast } from './replicate.js'
import { cachekv } from './cachekv.js'
-let imagecache = new Map()
+const imagecache = new Map()
-let namecache = new Map()
+const namecache = new Map()
setInterval(function () {
imagecache.clear()
@@ 27,7 27,7 @@ export function plainTextName (id) {
}
export function getImage (id) {
- let img = vb(decode(id), 256)
+ const img = vb(decode(id), 256)
img.classList = 'avatar'
if (imagecache.has(id)) {
M cachekv.js => cachekv.js +2 -2
@@ 25,11 25,11 @@ if ('caches' in window) {
}
cachekv.rm = async function (key) {
- cache.delete(url + key)
+ await cache.delete(url + key)
}
cachekv.clear = async function () {
- caches.delete(db)
+ await caches.delete(db)
}
} else {
console.log('No Cache API available')
M composer.js => composer.js +8 -8
@@ 1,19 1,19 @@
import { h } from './lib/misc.js'
import { markdown } from './markdown.js'
import { publish, open } from './sbog.js'
-import { make, find } from './blob.js'
+import { make } from './blob.js'
import { save, logs } from './log.js'
import { render } from './render.js'
-import { getName, getImage, getBoth } from './avatar.js'
+import { getName, getImage } from './avatar.js'
import { blast } from './replicate.js'
import { cachekv } from './cachekv.js'
function getContacts (textarea, preview, msg) {
- var span = h('span')
+ const span = h('span')
- var button = h('button', {classList: 'btn right', onclick: function () {
+ const button = h('button', {classList: 'btn right', onclick: function () {
if (!span.childNodes[1]) {
- var addrs = h('span')
+ const addrs = h('span')
span.appendChild(addrs)
logs.getFeeds().then(feeds => {
@@ 130,7 130,7 @@ function photoAdder (textarea, preview, msg) {
}
export function composer (msg) {
- let preview = h('div', [h('p', [' '])])
+ const preview = h('div', [h('p', [' '])])
const textarea = h('textarea', {placeholder: 'Write a message...'})
@@ 140,7 140,7 @@ export function composer (msg) {
if (msg.hash.length === 44) {
cachekv.get('name:' + msg.author).then(name => {
- var select = window.getSelection().toString()
+ const select = window.getSelection().toString()
if (!name) {
name = msg.author.substring(0, 10) + '...'
}
@@ 154,7 154,7 @@ export function composer (msg) {
})
}
- textarea.addEventListener('input', function (e) {
+ textarea.addEventListener('input', () => {
if (textarea.value) {
cachekv.put('draft:' + msg.hash, textarea.value)
} else {
M console.js => console.js +4 -7
@@ 1,5 1,4 @@
import { keys } from './keys.js'
-import { encode, decode } from './lib/base64.js'
import { open } from './sbog.js'
import { addSocket, rmSocket, gossipMsg } from './gossip.js'
import { logs } from './log.js'
@@ 7,9 6,9 @@ import { find, make } from './blob.js'
const server = 'ws://localhost:8080/ws'
-let blastcache = []
+const blastcache = []
-function processReq (req, ws) {
+function processReq (req) {
if (req.length === 44) {
let gotit = false
if (req === keys.pubkey()) {
@@ 97,8 96,6 @@ function processReq (req, ws) {
}
}
-const sockets = new Set()
-
export function connect (server) {
console.log('Connecting to ' + server)
@@ 124,7 121,7 @@ export function connect (server) {
Deno.exit()
})
- ws.onclose = (e) => {
+ ws.onclose = () => {
rmSocket(ws)
setTimeout(function () {
connect(server)
@@ 133,7 130,7 @@ export function connect (server) {
let retryCount = 1
- ws.onerror = (err) => {
+ ws.onerror = () => {
setTimeout(function () {
ws.close()
rmSocket(ws)