Settings: prefetching toots
This commit is contained in:
		
							parent
							
								
									cbed46ae77
								
							
						
					
					
						commit
						6ad794eae5
					
				
					 3 changed files with 19 additions and 4 deletions
				
			
		|  | @ -23,9 +23,12 @@ import { css } from "solid-styled"; | ||||||
| import { useSignedInProfiles } from "../masto/acct.js"; | import { useSignedInProfiles } from "../masto/acct.js"; | ||||||
| import { signOut, type Account } from "../accounts/stores.js"; | import { signOut, type Account } from "../accounts/stores.js"; | ||||||
| import { intlFormat } from "date-fns"; | import { intlFormat } from "date-fns"; | ||||||
|  | import { useStore } from "@nanostores/solid"; | ||||||
|  | import { $settings } from "./stores.js"; | ||||||
| 
 | 
 | ||||||
| const Settings: ParentComponent = () => { | const Settings: ParentComponent = () => { | ||||||
|   const navigate = useNavigate(); |   const navigate = useNavigate(); | ||||||
|  |   const settings$ = useStore($settings); | ||||||
| 
 | 
 | ||||||
|   const [profiles] = useSignedInProfiles(); |   const [profiles] = useSignedInProfiles(); | ||||||
| 
 | 
 | ||||||
|  | @ -96,7 +99,12 @@ const Settings: ParentComponent = () => { | ||||||
|               Prefetch Toots |               Prefetch Toots | ||||||
|             </ListItemText> |             </ListItemText> | ||||||
|             <ListItemSecondaryAction> |             <ListItemSecondaryAction> | ||||||
|               <Switch /> |               <Switch | ||||||
|  |                 checked={!settings$().prefetchTootsDisabled} | ||||||
|  |                 onChange={(e) => | ||||||
|  |                   $settings.setKey("prefetchTootsDisabled", !e.target.checked) | ||||||
|  |                 } | ||||||
|  |               /> | ||||||
|             </ListItemSecondaryAction> |             </ListItemSecondaryAction> | ||||||
|           </ListItem> |           </ListItem> | ||||||
|         </li> |         </li> | ||||||
|  |  | ||||||
|  | @ -2,6 +2,10 @@ import { persistentMap } from "@nanostores/persistent"; | ||||||
| 
 | 
 | ||||||
| type Settings = { | type Settings = { | ||||||
|   onGoingOAuth2Process?: string |   onGoingOAuth2Process?: string | ||||||
|  |   prefetchTootsDisabled?: boolean | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export const $settings = persistentMap<Settings>("settings::", {}) | export const $settings = persistentMap<Settings>("settings::", {}, { | ||||||
|  |   encode: JSON.stringify, | ||||||
|  |   decode: JSON.parse | ||||||
|  | }) | ||||||
|  |  | ||||||
|  | @ -35,6 +35,8 @@ import { Create as CreateTootIcon } from "@suid/icons-material"; | ||||||
| import { useTimeline } from "../masto/timelines"; | import { useTimeline } from "../masto/timelines"; | ||||||
| import { makeEventListener } from "@solid-primitives/event-listener"; | import { makeEventListener } from "@solid-primitives/event-listener"; | ||||||
| import BottomSheet from "../material/BottomSheet"; | import BottomSheet from "../material/BottomSheet"; | ||||||
|  | import { $settings } from "../settings/stores"; | ||||||
|  | import { useStore } from "@nanostores/solid"; | ||||||
| 
 | 
 | ||||||
| const TimelinePanel: Component<{ | const TimelinePanel: Component<{ | ||||||
|   client: mastodon.rest.Client; |   client: mastodon.rest.Client; | ||||||
|  | @ -153,12 +155,13 @@ const Home: ParentComponent = (props) => { | ||||||
|   useDocumentTitle("Timelines"); |   useDocumentTitle("Timelines"); | ||||||
|   const now = createTimeSource(); |   const now = createTimeSource(); | ||||||
| 
 | 
 | ||||||
|  |   const settings$ = useStore($settings) | ||||||
|   const sessions = useSessions(); |   const sessions = useSessions(); | ||||||
|   const client = () => sessions()[0].client; |   const client = () => sessions()[0].client; | ||||||
|   const [profile] = useAcctProfile(client); |   const [profile] = useAcctProfile(client); | ||||||
| 
 | 
 | ||||||
|   const [panelOffset, setPanelOffset] = createSignal(0); |   const [panelOffset, setPanelOffset] = createSignal(0); | ||||||
|   const [prefetching, setPrefetching] = createSignal(true); |   const prefetching = () => !settings$().prefetchTootsDisabled | ||||||
|   const [currentFocusOn, setCurrentFocusOn] = createSignal<HTMLElement[]>([]); |   const [currentFocusOn, setCurrentFocusOn] = createSignal<HTMLElement[]>([]); | ||||||
|   const [focusRange, setFocusRange] = createSignal([0, 0] as readonly [ |   const [focusRange, setFocusRange] = createSignal([0, 0] as readonly [ | ||||||
|     number, |     number, | ||||||
|  | @ -279,7 +282,7 @@ const Home: ParentComponent = (props) => { | ||||||
|                 </Tab> |                 </Tab> | ||||||
|               </Tabs> |               </Tabs> | ||||||
|               <ProfileMenuButton profile={profile()}> |               <ProfileMenuButton profile={profile()}> | ||||||
|                 <MenuItem onClick={(e) => setPrefetching((x) => !x)}> |                 <MenuItem onClick={(e) => $settings.setKey("prefetchTootsDisabled", !$settings.get().prefetchTootsDisabled)}> | ||||||
|                   <ListItemText>Prefetch Toots</ListItemText> |                   <ListItemText>Prefetch Toots</ListItemText> | ||||||
|                   <ListItemSecondaryAction> |                   <ListItemSecondaryAction> | ||||||
|                     <Switch checked={prefetching()}></Switch> |                     <Switch checked={prefetching()}></Switch> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue