mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-20 22:07:15 +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 { useEffect, useState } from "react";
|
||||||
import { toast } from "react-hot-toast";
|
import { toast } from "react-hot-toast";
|
||||||
import { useStorageContext } from "@/context";
|
import { useStorageContext } from "@/context";
|
||||||
import useShortcutStore from "@/store/shortcut";
|
import { useShortcutStore } from "@/stores";
|
||||||
import type { Visibility } from "@/types/proto/api/v1/common";
|
import type { Visibility } from "@/types/proto/api/v1/common";
|
||||||
import { Shortcut } from "@/types/proto/api/v1/shortcut_service";
|
import { Shortcut } from "@/types/proto/api/v1/shortcut_service";
|
||||||
import Icon from "./Icon";
|
import Icon from "./Icon";
|
||||||
|
@ -2,7 +2,7 @@ import { IconButton } from "@mui/joy";
|
|||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { toast } from "react-hot-toast";
|
import { toast } from "react-hot-toast";
|
||||||
import { useStorageContext } from "@/context";
|
import { useStorageContext } from "@/context";
|
||||||
import useShortcutStore from "@/store/shortcut";
|
import { useShortcutStore } from "@/stores";
|
||||||
import Icon from "./Icon";
|
import Icon from "./Icon";
|
||||||
|
|
||||||
const PullShortcutsButton = () => {
|
const PullShortcutsButton = () => {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import useShortcutStore from "@/store/shortcut";
|
import { useShortcutStore } from "@/stores";
|
||||||
import Icon from "./Icon";
|
import Icon from "./Icon";
|
||||||
import ShortcutView from "./ShortcutView";
|
import ShortcutView from "./ShortcutView";
|
||||||
|
|
||||||
|
@ -16,18 +16,26 @@ const StorageContextProvider = ({ children }: Props) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
const domain = await storage.get("domain");
|
let instanceUrl = await storage.get("instance_url");
|
||||||
const accessToken = await storage.get("access_token");
|
const accessToken = await storage.get("access_token");
|
||||||
const defaultVisibility = (await storage.get("default_visibility")) as Visibility;
|
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);
|
setAccessToken(accessToken);
|
||||||
setDefaultVisibility(defaultVisibility);
|
setDefaultVisibility(defaultVisibility);
|
||||||
setIsInitialized(true);
|
setIsInitialized(true);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
storage.watch({
|
storage.watch({
|
||||||
domain: (c) => {
|
instance_url: (c) => {
|
||||||
setInstanceUrl(c.newValue);
|
setInstanceUrl(c.newValue);
|
||||||
},
|
},
|
||||||
access_token: (c) => {
|
access_token: (c) => {
|
||||||
@ -45,7 +53,7 @@ const StorageContextProvider = ({ children }: Props) => {
|
|||||||
instanceUrl,
|
instanceUrl,
|
||||||
accessToken,
|
accessToken,
|
||||||
defaultVisibility,
|
defaultVisibility,
|
||||||
setInstanceUrl: (instanceUrl: string) => storage.set("domain", instanceUrl),
|
setInstanceUrl: (instanceUrl: string) => storage.set("instance_url", instanceUrl),
|
||||||
setAccessToken: (accessToken: string) => storage.set("access_token", accessToken),
|
setAccessToken: (accessToken: string) => storage.set("access_token", accessToken),
|
||||||
setDefaultVisibility: (visibility: Visibility) => storage.set("default_visibility", visibility),
|
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) => {
|
export const getFaviconWithGoogleS2 = (url: string) => {
|
||||||
try {
|
try {
|
||||||
const urlObject = new URL(url);
|
const urlObject = new URL(url);
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { Button, CssVarsProvider, Divider, Input, Select, Option } from "@mui/joy";
|
import { Button, CssVarsProvider, Divider, Input, Select, Option } from "@mui/joy";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Toaster, toast } from "react-hot-toast";
|
import { Toaster, toast } from "react-hot-toast";
|
||||||
|
import { useShortcutStore } from "@/stores";
|
||||||
import Icon from "./components/Icon";
|
import Icon from "./components/Icon";
|
||||||
import Logo from "./components/Logo";
|
import Logo from "./components/Logo";
|
||||||
import PullShortcutsButton from "./components/PullShortcutsButton";
|
import PullShortcutsButton from "./components/PullShortcutsButton";
|
||||||
import ShortcutsContainer from "./components/ShortcutsContainer";
|
import ShortcutsContainer from "./components/ShortcutsContainer";
|
||||||
import { StorageContextProvider, useStorageContext } from "./context";
|
import { StorageContextProvider, useStorageContext } from "./context";
|
||||||
import useColorTheme from "./hooks/useColorTheme";
|
import useColorTheme from "./hooks/useColorTheme";
|
||||||
import useShortcutStore from "./store/shortcut";
|
|
||||||
import "./style.css";
|
import "./style.css";
|
||||||
import { Visibility } from "./types/proto/api/v1/common";
|
import { Visibility } from "./types/proto/api/v1/common";
|
||||||
|
|
||||||
|
@ -6,9 +6,9 @@ import Icon from "@/components/Icon";
|
|||||||
import Logo from "@/components/Logo";
|
import Logo from "@/components/Logo";
|
||||||
import PullShortcutsButton from "@/components/PullShortcutsButton";
|
import PullShortcutsButton from "@/components/PullShortcutsButton";
|
||||||
import ShortcutsContainer from "@/components/ShortcutsContainer";
|
import ShortcutsContainer from "@/components/ShortcutsContainer";
|
||||||
|
import { useShortcutStore } from "@/stores";
|
||||||
import { StorageContextProvider, useStorageContext } from "./context";
|
import { StorageContextProvider, useStorageContext } from "./context";
|
||||||
import useColorTheme from "./hooks/useColorTheme";
|
import useColorTheme from "./hooks/useColorTheme";
|
||||||
import useShortcutStore from "./store/shortcut";
|
|
||||||
import "./style.css";
|
import "./style.css";
|
||||||
|
|
||||||
const IndexPopup = () => {
|
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