38 lines
683 B
JavaScript
38 lines
683 B
JavaScript
|
import { div, pfp, p, parse, button, body, a, textarea, span, crawl } from './main.js'
|
||
|
import { loadself, loadpostspage, createpost, loadusers } from './api.js'
|
||
|
import { parsePost, header } from './components.js'
|
||
|
|
||
|
function render() {
|
||
|
|
||
|
let new_body =
|
||
|
body({},
|
||
|
...header(false, false, true, data.self.user_id),
|
||
|
)
|
||
|
|
||
|
document.body.replaceWith(new_body)
|
||
|
|
||
|
}
|
||
|
|
||
|
const data = {
|
||
|
self: {},
|
||
|
users: []
|
||
|
}
|
||
|
|
||
|
async function init() {
|
||
|
|
||
|
let request = (await loadself());
|
||
|
data.self = request.json
|
||
|
|
||
|
if (request.json == undefined) {
|
||
|
location.href = '/login'
|
||
|
return
|
||
|
}
|
||
|
|
||
|
data.users[data.self.user_id] = data.self
|
||
|
|
||
|
render()
|
||
|
}
|
||
|
|
||
|
|
||
|
init()
|