@@ -8,6 +8,15 @@ customElements.define('upvote-rss', class extends HTMLElement {
88 'average-posts-per-day' , 'comments' , 'threshold-percentage' , 'post-cutoff-days' , 'score' , 'score-default-hacker-news' , 'score-default-lemmy' , 'score-default-lobsters' , 'score-default-mbin' , 'score-default-piefed' , 'score-default-reddit'
99 ] ) ;
1010
11+ // Constructor
12+ constructor ( ) {
13+ super ( ) ;
14+
15+ // Set initial attributes
16+ this . setAttribute ( 'dark-mode' , localStorage . getItem ( 'dark-mode' ) || this . attr ( 'dark-mode' ) || 'auto' ) ;
17+ this . setAttribute ( 'show-rss-url' , navigator . clipboard ? false : true ) ;
18+ }
19+
1120
1221 /**
1322 * Called when the element is added to the DOM
@@ -36,16 +45,9 @@ customElements.define('upvote-rss', class extends HTMLElement {
3645 this . allowSkeletons = false ;
3746 this . skeletonDelay = 150 ;
3847
39- // Get dark mode preference
40- this . getDarkMode ( ) ;
41-
4248 // Initial data fetching
4349 this . debouncedSearch ( ) ;
4450
45- // Set initial attributes
46- this . setAttribute ( 'dark-mode' , localStorage . getItem ( 'dark-mode' ) || 'auto' ) ;
47- this . setAttribute ( 'show-rss-url' , navigator . clipboard ? false : true ) ;
48-
4951 // Set up event listeners
5052 this . setupEventListeners ( ) ;
5153 }
@@ -698,19 +700,6 @@ customElements.define('upvote-rss', class extends HTMLElement {
698700 }
699701
700702
701- /**
702- * Get the dark mode setting from local storage and apply it
703- * @returns {void }
704- * */
705- getDarkMode ( ) {
706- const darkMode = localStorage . getItem ( 'dark-mode' ) ;
707- if ( darkMode ) {
708- this . setAttribute ( 'dark-mode' , darkMode ) ;
709- }
710- document . documentElement . dataset . colorScheme = this . attr ( 'dark-mode' ) ;
711- }
712-
713-
714703 /**
715704 * Perform a debounced search to get posts
716705 * @param {number } delay - The delay in milliseconds
0 commit comments