New mobile nav. Removed old cruft.
This commit is contained in:
parent
20907bede6
commit
6c9f5f12fe
9 changed files with 106 additions and 253 deletions
18
js/main.js
18
js/main.js
|
@ -81,10 +81,6 @@ async function webapp_init() {
|
|||
|
||||
// Load data from storage
|
||||
await model_load_settings(model);
|
||||
/*err = await contacts_load(model);
|
||||
if (err) {
|
||||
window.alert("Unable to load contacts.");
|
||||
}*/
|
||||
init_settings(model);
|
||||
|
||||
// Create our pool so that event processing functions can work
|
||||
|
@ -96,14 +92,6 @@ async function webapp_init() {
|
|||
pool.on("eose", on_pool_eose);
|
||||
pool.on("ok", on_pool_ok);
|
||||
|
||||
// Load all events from storage and re-process them so that apply correct
|
||||
// effects.
|
||||
/*await model_load_events(model, (ev)=> {
|
||||
model_process_event(model, undefined, ev);
|
||||
});
|
||||
log_debug("loaded events", Object.keys(model.all_events).length);
|
||||
*/
|
||||
|
||||
var { mode, opts, valid } = parse_url_mode();
|
||||
view_timeline_apply_mode(model, mode, opts, !valid);
|
||||
on_timer_timestamps();
|
||||
|
@ -171,7 +159,7 @@ function on_timer_save() {
|
|||
setTimeout(() => {
|
||||
const model = DAMUS;
|
||||
//model_save_events(model);
|
||||
model_save_settings(model);
|
||||
//model_save_settings(model);
|
||||
on_timer_save();
|
||||
}, 1 * 1000);
|
||||
}
|
||||
|
@ -300,6 +288,7 @@ function fetch_profile(pubkey, pool, relay) {
|
|||
}
|
||||
|
||||
function fetch_thread_history(evid, pool) {
|
||||
// TODO look up referenced relays for thread history
|
||||
const sid = `${SID_THREAD}:${evid}`
|
||||
pool.subscribe(sid, [{
|
||||
kinds: PUBLIC_KINDS,
|
||||
|
@ -309,8 +298,7 @@ function fetch_thread_history(evid, pool) {
|
|||
}
|
||||
|
||||
function fetch_friends_history(friends, pool, relay) {
|
||||
// TODO only fetch friends history from their desired relay instead of
|
||||
// pinging all of the relays
|
||||
// TODO fetch history of each friend by their desired relay
|
||||
pool.subscribe(SID_FRIENDS, [{
|
||||
kinds: PUBLIC_KINDS,
|
||||
authors: friends,
|
||||
|
|
|
@ -1,21 +1,12 @@
|
|||
function init_settings(model) {
|
||||
const el = find_node("#settings");
|
||||
find_node("#add-relay", el).addEventListener("click", on_click_add_relay);
|
||||
find_node("[role='sign-out']", el).addEventListener("click", on_click_sign_out);
|
||||
const rlist = find_node("#relay-list tbody", el);
|
||||
model.relays.forEach((str) => {
|
||||
rlist.appendChild(new_relay_item(str));
|
||||
});
|
||||
}
|
||||
|
||||
async function on_click_sign_out(ev) {
|
||||
if (confirm("Are you sure you want to sign out?")) {
|
||||
localStorage.clear();
|
||||
await dbclear();
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
function new_relay_item(str) {
|
||||
const tr = document.createElement('tr');
|
||||
tr.innerHTML = `<td>${str}</td>
|
||||
|
|
|
@ -115,17 +115,14 @@ function view_timeline_apply_mode(model, mode, opts={}, push_state=true) {
|
|||
|
||||
// Do some visual updates
|
||||
find_node("#show-more").classList.add("hide");
|
||||
find_node("#view header > label").innerText = name;
|
||||
find_node("#nav > div[data-active]").dataset.active = names[mode].toLowerCase();
|
||||
find_node("#view header > label").innerText = name;
|
||||
view_update_navs(mode);
|
||||
find_node("#view [role='profile-info']").classList.toggle("hide", mode != VM_USER);
|
||||
const timeline_el = find_node("#timeline");
|
||||
timeline_el.classList.toggle("reverse", mode == VM_THREAD);
|
||||
timeline_el.classList.toggle("hide", mode == VM_SETTINGS || mode == VM_DM);
|
||||
find_node("#settings").classList.toggle("hide", mode != VM_SETTINGS);
|
||||
find_node("#dms").classList.toggle("hide", mode != VM_DM);
|
||||
find_node("#dms-not-available")
|
||||
.classList.toggle("hide", mode == VM_DM_THREAD || mode == VM_DM ?
|
||||
dms_available() : true);
|
||||
find_node("#header-tools button[action='mark-all-read']")
|
||||
.classList.toggle("hide", mode != VM_DM);
|
||||
|
||||
|
@ -220,6 +217,12 @@ function view_timeline_refresh(model, mode, opts={}) {
|
|||
}
|
||||
}
|
||||
|
||||
function view_update_navs(mode) {
|
||||
find_nodes("nav.nav button[data-view]").forEach((el)=> {
|
||||
el.classList.toggle("active", el.dataset.view == mode)
|
||||
});
|
||||
}
|
||||
|
||||
function view_show_spinner(show=true) {
|
||||
find_node("#view .loading-events").classList.toggle("hide", !show);
|
||||
}
|
||||
|
@ -546,7 +549,6 @@ function get_thread_root_id(damus, id) {
|
|||
|
||||
function switch_view(mode, opts) {
|
||||
view_timeline_apply_mode(DAMUS, mode, opts);
|
||||
close_gnav();
|
||||
}
|
||||
|
||||
function toggle_hide_replys(el) {
|
||||
|
@ -668,9 +670,6 @@ function onclick_any(ev) {
|
|||
const el = ev.target;
|
||||
const action = el.getAttribute("action");
|
||||
switch (action) {
|
||||
case "toggle-gnav":
|
||||
toggle_gnav(el);
|
||||
break;
|
||||
case "sign-in":
|
||||
signin();
|
||||
break;
|
||||
|
|
|
@ -3,17 +3,6 @@
|
|||
* this file grows specific UI area code should be migrated to its own file.
|
||||
*/
|
||||
|
||||
/* toggle_gnav hides or shows the global navigation's additional buttons based
|
||||
* on its opened state.
|
||||
*/
|
||||
function toggle_gnav(el) {
|
||||
el.parentElement.classList.toggle("open");
|
||||
}
|
||||
|
||||
function close_gnav() {
|
||||
find_node("#gnav").classList.remove("open");
|
||||
}
|
||||
|
||||
/* init_message_textareas finds all message textareas and updates their initial
|
||||
* height based on their content (0). This is so there is no jaring affect when
|
||||
* the page loads.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue