refactor: Standardize data processing and update to Svelte 5 runes
This commit introduces a major refactoring of the data processing logic across multiple modules (events, archives, posts, sponsorships) to use a standardized pattern with . This improves consistency and maintainability. Key changes: - Replaced module-specific data processing with a generic helper. - Removed deprecated functions. - Updated Svelte components to leverage the new Svelte 5 runes, simplifying state management. - Fixed linting errors and updated test configurations. - Added .
This commit is contained in:
@@ -1,27 +1,21 @@
|
||||
<script lang="ts">
|
||||
/** @type {import('./$types').LayoutProps} */
|
||||
let log_lvl: number = 0;
|
||||
let log_lvl = $state(0);
|
||||
|
||||
// *** Import Svelte specific
|
||||
// import { browser } from '$app/environment';
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
// *** Import other supporting libraries
|
||||
// import * as icons from '@lucide/svelte';
|
||||
import {
|
||||
Brain,
|
||||
House, Library,
|
||||
House,
|
||||
RefreshCw,
|
||||
Satellite
|
||||
} from '@lucide/svelte';
|
||||
|
||||
// *** Import Aether specific variables and functions
|
||||
import type { key_val } from '$lib/stores/ae_stores';
|
||||
// import { ae_util } from '$lib/ae_utils/ae_utils';
|
||||
// import { api } from '$lib/api';
|
||||
import { ae_loc, ae_sess, ae_api, slct } from '$lib/stores/ae_stores';
|
||||
import { journals_loc, journals_slct, journals_trig } from '$lib/ae_journals/ae_journals_stores';
|
||||
// import { journals_func } from '$lib/ae_journals/ae_journals_functions';
|
||||
import Element_data_store from '$lib/elements/element_data_store_v2.svelte';
|
||||
import Help_tech from '$lib/app_components/e_app_help_tech.svelte';
|
||||
|
||||
@@ -39,26 +33,16 @@ $journals_loc.qry__offset = 0;
|
||||
|
||||
// Quickly save the data passed from the parent(s) to the Svelte stores, localStorage, and other.
|
||||
$slct.account_id = data.account_id;
|
||||
$effect(() => {
|
||||
if (log_lvl) {
|
||||
console.log(`$slct.account_id = `, $slct.account_id);
|
||||
}
|
||||
});
|
||||
let ae_acct = data[$slct.account_id];
|
||||
// console.log(`ae_acct = `, ae_acct);
|
||||
|
||||
// if (browser) {
|
||||
// console.log(`Browser: ${browser}`);
|
||||
// journals_func.handle_db_save_ae_obj_li__journal({
|
||||
// obj_type: 'journal',
|
||||
// obj_li: [ae_acct.slct.journal_obj_li],
|
||||
// });
|
||||
// }
|
||||
|
||||
$journals_slct.journal_id = ae_acct.slct.journal_id;
|
||||
// $journals_slct.journal_obj = ae_acct.slct.journal_obj;
|
||||
$journals_slct.journal_obj_li = ae_acct.slct.journal_obj_li;
|
||||
|
||||
// let ae_promises: key_val = {};
|
||||
|
||||
|
||||
let nav_y_height = $state(0);
|
||||
|
||||
@@ -70,17 +54,17 @@ let yTop = $state(0);
|
||||
let yScroll = $state(0);
|
||||
let yHeight = $state(0);
|
||||
|
||||
let scroll_y = $state(0);
|
||||
|
||||
function parse_scroll() {
|
||||
// console.log(`parse_scroll() called`);
|
||||
xLeft = box.scrollLeft;
|
||||
xScroll = box.scrollWidth;
|
||||
xWidth = box.clientWidth;
|
||||
yTop = box.scrollTop;
|
||||
yHeight = box.clientHeight;
|
||||
yScroll = box.scrollHeight;
|
||||
// console.log(`parse_scroll() called: ${yTop}`);
|
||||
function handle_scroll() {
|
||||
// console.log(`handle_scroll() called`);
|
||||
if (box) {
|
||||
xLeft = box.scrollLeft;
|
||||
xScroll = box.scrollWidth;
|
||||
xWidth = box.clientWidth;
|
||||
yTop = box.scrollTop;
|
||||
yHeight = box.clientHeight;
|
||||
yScroll = box.scrollHeight;
|
||||
// console.log(`handle_scroll() called: ${yTop}`);
|
||||
}
|
||||
}
|
||||
|
||||
function scroll_container() {
|
||||
@@ -101,7 +85,7 @@ function scroll_container() {
|
||||
id="ae_main_content"
|
||||
bind:clientHeight={$ae_loc.iframe_height}
|
||||
bind:this={box}
|
||||
onscroll={parse_scroll}
|
||||
onscroll={handle_scroll}
|
||||
class:iframe={$ae_loc?.iframe}
|
||||
class="
|
||||
ae_journals
|
||||
@@ -286,6 +270,7 @@ function scroll_container() {
|
||||
class:ae_btn_warning_filled={yTop > 1500}
|
||||
onclick={() => {
|
||||
log_lvl = 1;
|
||||
$effect(() => {
|
||||
if (log_lvl) {
|
||||
console.log(`Scroll to top button clicked. scroll_y: ${scroll_y} scrollTop: ${scroll_container().scrollTop}`, scroll_container());
|
||||
// document.getElementById('ae_idaa')?.scrollTo(0, 0);
|
||||
@@ -293,6 +278,7 @@ function scroll_container() {
|
||||
// document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
|
||||
// document.body.scrollTop = 0; // For Safari
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Not Safari, using smooth scroll to top');
|
||||
document.getElementById('ae_main_content')?.scrollTo({
|
||||
@@ -356,6 +342,7 @@ function scroll_container() {
|
||||
class:ae_btn_warning_filled={yTop > 1500}
|
||||
onclick={() => {
|
||||
log_lvl = 1;
|
||||
$effect(() => {
|
||||
if (log_lvl) {
|
||||
console.log(`Scroll to bottom button clicked. scroll_y: ${scroll_y} scrollTop: ${scroll_container().scrollTop}`, scroll_container());
|
||||
// document.getElementById('ae_idaa')?.scrollTo(0, 0);
|
||||
@@ -363,6 +350,7 @@ function scroll_container() {
|
||||
// document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
|
||||
// document.body.scrollTop = 0; // For Safari
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Not Safari, using smooth scroll to bottom');
|
||||
document.getElementById('ae_main_content')?.scrollTo({
|
||||
|
||||
Reference in New Issue
Block a user