App: fix the clients change is not notified

This commit is contained in:
thislight 2024-10-11 16:39:42 +08:00
parent fd47639bef
commit bd3ad078a2
4 changed files with 122 additions and 79 deletions

View file

@ -49,12 +49,12 @@ export type Session = {
client: mastodon.rest.Client;
};
const Context = /* @__PURE__ */ createContext<Signal<Session[]>>();
const Context = /* @__PURE__ */ createContext<Accessor<readonly Readonly<Session>[]>>();
export const Provider = Context.Provider;
export function useSessions() {
const [sessions] = useSessionsRw();
const sessions = useSessionsRaw();
const navigate = useNavigate();
const location = useLocation();
@ -69,7 +69,7 @@ export function useSessions() {
return sessions;
}
function useSessionsRw() {
function useSessionsRaw() {
const store = useContext(Context);
if (!store) {
throw new TypeError("sessions are not provided");