File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -54,8 +54,9 @@ export class MehComments {
5454
5555 /**
5656 * Comment sort order: 'oldest' (default), 'newest', or 'threaded'
57+ * Can be initialized from localStorage 'meh-sort' key if present
5758 */
58- @Prop ( ) sort : 'oldest' | 'newest' | 'threaded' = 'oldest' ;
59+ @Prop ( { mutable : true } ) sort : 'oldest' | 'newest' | 'threaded' = 'oldest' ;
5960
6061 @State ( ) comments : any [ ] = [ ] ;
6162 @State ( ) loading : boolean = true ;
@@ -93,6 +94,17 @@ export class MehComments {
9394 // Process the backend URL (clean or detect)
9495 this . backend = detectBackendUrl ( this . backend ) ;
9596
97+ // Check localStorage for sort preference
98+ try {
99+ const savedSort = localStorage . getItem ( 'meh-sort' ) ;
100+ if ( savedSort && [ 'oldest' , 'newest' , 'threaded' ] . includes ( savedSort ) ) {
101+ this . sort = savedSort as 'oldest' | 'newest' | 'threaded' ;
102+ }
103+ } catch ( e ) {
104+ // Ignore localStorage errors (e.g., in private browsing mode)
105+ console . warn ( 'Could not access localStorage for sort preference:' , e ) ;
106+ }
107+
96108 // Initialize the TranslationManager with default translations
97109 this . translator = new TranslationManager ( this . defaultTranslations ) ;
98110
You can’t perform that action at this time.
0 commit comments