added settings
This commit is contained in:
		
							parent
							
								
									5ec00d4999
								
							
						
					
					
						commit
						5833e5a76b
					
				
					 15 changed files with 359 additions and 91 deletions
				
			
		| 
						 | 
				
			
			@ -1,10 +1,35 @@
 | 
			
		|||
import { Accessor, createResource } from "solid-js";
 | 
			
		||||
import type { mastodon } from "masto";
 | 
			
		||||
import { useSessions } from "./clients";
 | 
			
		||||
import { updateAcctInf } from "../accounts/stores";
 | 
			
		||||
 | 
			
		||||
export function useAcctProfile(client: Accessor<mastodon.rest.Client>) {
 | 
			
		||||
  return createResource(client, (client) => {
 | 
			
		||||
    return client.v1.accounts.verifyCredentials()
 | 
			
		||||
  }, {
 | 
			
		||||
    name: "MastodonAccountProfile"
 | 
			
		||||
  })
 | 
			
		||||
  return createResource(
 | 
			
		||||
    client,
 | 
			
		||||
    (client) => {
 | 
			
		||||
      return client.v1.accounts.verifyCredentials();
 | 
			
		||||
    },
 | 
			
		||||
    {
 | 
			
		||||
      name: "MastodonAccountProfile",
 | 
			
		||||
    },
 | 
			
		||||
  );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function useSignedInProfiles() {
 | 
			
		||||
  const sessions = useSessions();
 | 
			
		||||
  const [accessor, tools] = createResource(sessions, async (all) => {
 | 
			
		||||
    return Promise.all(
 | 
			
		||||
      all.map(async (x, i) => ({ ...x, inf: await updateAcctInf(i) })),
 | 
			
		||||
    );
 | 
			
		||||
  });
 | 
			
		||||
  return [
 | 
			
		||||
    () => {
 | 
			
		||||
      if (accessor.loading) {
 | 
			
		||||
        accessor();
 | 
			
		||||
        return sessions().map((x) => ({ ...x, inf: x.account.inf }));
 | 
			
		||||
      }
 | 
			
		||||
      return accessor();
 | 
			
		||||
    },
 | 
			
		||||
    tools,
 | 
			
		||||
  ] as const;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -69,7 +69,7 @@ export function useSessions() {
 | 
			
		|||
  return sessions;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function useSessionsRw() {
 | 
			
		||||
function useSessionsRw() {
 | 
			
		||||
  const store = useContext(Context);
 | 
			
		||||
  if (!store) {
 | 
			
		||||
    throw new TypeError("sessions are not provided");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue