mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-16 12:23:12 +00:00
chore: tweak store imports
This commit is contained in:
parent
5264dc9d8a
commit
b7484363dc
@ -2,7 +2,7 @@ import { Button, IconButton, Input, Modal, ModalDialog } from "@mui/joy";
|
||||
import { useEffect, useState } from "react";
|
||||
import { toast } from "react-hot-toast";
|
||||
import { useStorageContext } from "@/context";
|
||||
import useShortcutStore from "@/store/shortcut";
|
||||
import { useShortcutStore } from "@/stores";
|
||||
import type { Visibility } from "@/types/proto/api/v1/common";
|
||||
import { Shortcut } from "@/types/proto/api/v1/shortcut_service";
|
||||
import Icon from "./Icon";
|
||||
|
@ -2,7 +2,7 @@ import { IconButton } from "@mui/joy";
|
||||
import { useEffect } from "react";
|
||||
import { toast } from "react-hot-toast";
|
||||
import { useStorageContext } from "@/context";
|
||||
import useShortcutStore from "@/store/shortcut";
|
||||
import { useShortcutStore } from "@/stores";
|
||||
import Icon from "./Icon";
|
||||
|
||||
const PullShortcutsButton = () => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import classNames from "classnames";
|
||||
import useShortcutStore from "@/store/shortcut";
|
||||
import { useShortcutStore } from "@/stores";
|
||||
import Icon from "./Icon";
|
||||
import ShortcutView from "./ShortcutView";
|
||||
|
||||
|
@ -16,18 +16,26 @@ const StorageContextProvider = ({ children }: Props) => {
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const domain = await storage.get("domain");
|
||||
let instanceUrl = await storage.get("instance_url");
|
||||
const accessToken = await storage.get("access_token");
|
||||
const defaultVisibility = (await storage.get("default_visibility")) as Visibility;
|
||||
|
||||
setInstanceUrl(domain);
|
||||
// Migrate domain to instance_url.
|
||||
const domain = await storage.get("domain");
|
||||
if (domain) {
|
||||
instanceUrl = domain;
|
||||
await storage.remove("domain");
|
||||
await storage.set("instance_url", instanceUrl);
|
||||
}
|
||||
|
||||
setInstanceUrl(instanceUrl);
|
||||
setAccessToken(accessToken);
|
||||
setDefaultVisibility(defaultVisibility);
|
||||
setIsInitialized(true);
|
||||
})();
|
||||
|
||||
storage.watch({
|
||||
domain: (c) => {
|
||||
instance_url: (c) => {
|
||||
setInstanceUrl(c.newValue);
|
||||
},
|
||||
access_token: (c) => {
|
||||
@ -45,7 +53,7 @@ const StorageContextProvider = ({ children }: Props) => {
|
||||
instanceUrl,
|
||||
accessToken,
|
||||
defaultVisibility,
|
||||
setInstanceUrl: (instanceUrl: string) => storage.set("domain", instanceUrl),
|
||||
setInstanceUrl: (instanceUrl: string) => storage.set("instance_url", instanceUrl),
|
||||
setAccessToken: (accessToken: string) => storage.set("access_token", accessToken),
|
||||
setDefaultVisibility: (visibility: Visibility) => storage.set("default_visibility", visibility),
|
||||
}}
|
||||
|
@ -1,9 +1,3 @@
|
||||
import { isNull, isUndefined } from "lodash-es";
|
||||
|
||||
export const isNullorUndefined = (value: any) => {
|
||||
return isNull(value) || isUndefined(value);
|
||||
};
|
||||
|
||||
export const getFaviconWithGoogleS2 = (url: string) => {
|
||||
try {
|
||||
const urlObject = new URL(url);
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { Button, CssVarsProvider, Divider, Input, Select, Option } from "@mui/joy";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Toaster, toast } from "react-hot-toast";
|
||||
import { useShortcutStore } from "@/stores";
|
||||
import Icon from "./components/Icon";
|
||||
import Logo from "./components/Logo";
|
||||
import PullShortcutsButton from "./components/PullShortcutsButton";
|
||||
import ShortcutsContainer from "./components/ShortcutsContainer";
|
||||
import { StorageContextProvider, useStorageContext } from "./context";
|
||||
import useColorTheme from "./hooks/useColorTheme";
|
||||
import useShortcutStore from "./store/shortcut";
|
||||
import "./style.css";
|
||||
import { Visibility } from "./types/proto/api/v1/common";
|
||||
|
||||
|
@ -6,9 +6,9 @@ import Icon from "@/components/Icon";
|
||||
import Logo from "@/components/Logo";
|
||||
import PullShortcutsButton from "@/components/PullShortcutsButton";
|
||||
import ShortcutsContainer from "@/components/ShortcutsContainer";
|
||||
import { useShortcutStore } from "@/stores";
|
||||
import { StorageContextProvider, useStorageContext } from "./context";
|
||||
import useColorTheme from "./hooks/useColorTheme";
|
||||
import useShortcutStore from "./store/shortcut";
|
||||
import "./style.css";
|
||||
|
||||
const IndexPopup = () => {
|
||||
|
3
frontend/extension/src/stores/index.ts
Normal file
3
frontend/extension/src/stores/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import useShortcutStore from "./shortcut";
|
||||
|
||||
export { useShortcutStore };
|
Loading…
x
Reference in New Issue
Block a user