mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: update function name
This commit is contained in:
@ -46,7 +46,7 @@ func (s *APIV2Service) UpdateInbox(ctx context.Context, request *apiv2pb.UpdateI
|
|||||||
return nil, status.Errorf(codes.InvalidArgument, "update mask is required")
|
return nil, status.Errorf(codes.InvalidArgument, "update mask is required")
|
||||||
}
|
}
|
||||||
|
|
||||||
inboxID, err := GetInboxID(request.Inbox.Name)
|
inboxID, err := ExtractInboxIDFromName(request.Inbox.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(codes.InvalidArgument, "invalid inbox name: %v", err)
|
return nil, status.Errorf(codes.InvalidArgument, "invalid inbox name: %v", err)
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ func (s *APIV2Service) UpdateInbox(ctx context.Context, request *apiv2pb.UpdateI
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *APIV2Service) DeleteInbox(ctx context.Context, request *apiv2pb.DeleteInboxRequest) (*apiv2pb.DeleteInboxResponse, error) {
|
func (s *APIV2Service) DeleteInbox(ctx context.Context, request *apiv2pb.DeleteInboxRequest) (*apiv2pb.DeleteInboxResponse, error) {
|
||||||
inboxID, err := GetInboxID(request.Name)
|
inboxID, err := ExtractInboxIDFromName(request.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(codes.InvalidArgument, "invalid inbox name: %v", err)
|
return nil, status.Errorf(codes.InvalidArgument, "invalid inbox name: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,8 @@ func GetNameParentTokens(name string, tokenPrefixes ...string) ([]string, error)
|
|||||||
return tokens, nil
|
return tokens, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUsername returns the username from a resource name.
|
// ExtractUsernameFromName returns the username from a resource name.
|
||||||
func GetUsername(name string) (string, error) {
|
func ExtractUsernameFromName(name string) (string, error) {
|
||||||
tokens, err := GetNameParentTokens(name, UserNamePrefix)
|
tokens, err := GetNameParentTokens(name, UserNamePrefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@ -43,8 +43,8 @@ func GetUsername(name string) (string, error) {
|
|||||||
return tokens[0], nil
|
return tokens[0], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetInboxID returns the inbox ID from a resource name.
|
// ExtractInboxIDFromName returns the inbox ID from a resource name.
|
||||||
func GetInboxID(name string) (int32, error) {
|
func ExtractInboxIDFromName(name string) (int32, error) {
|
||||||
tokens, err := GetNameParentTokens(name, InboxNamePrefix)
|
tokens, err := GetNameParentTokens(name, InboxNamePrefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
|
@ -28,7 +28,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (s *APIV2Service) GetUser(ctx context.Context, request *apiv2pb.GetUserRequest) (*apiv2pb.GetUserResponse, error) {
|
func (s *APIV2Service) GetUser(ctx context.Context, request *apiv2pb.GetUserRequest) (*apiv2pb.GetUserResponse, error) {
|
||||||
username, err := GetUsername(request.Name)
|
username, err := ExtractUsernameFromName(request.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(codes.InvalidArgument, "name is required")
|
return nil, status.Errorf(codes.InvalidArgument, "name is required")
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ func (s *APIV2Service) CreateUser(ctx context.Context, request *apiv2pb.CreateUs
|
|||||||
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
|
||||||
}
|
}
|
||||||
|
|
||||||
username, err := GetUsername(request.User.Name)
|
username, err := ExtractUsernameFromName(request.User.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(codes.InvalidArgument, "name is required")
|
return nil, status.Errorf(codes.InvalidArgument, "name is required")
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ func (s *APIV2Service) CreateUser(ctx context.Context, request *apiv2pb.CreateUs
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *APIV2Service) UpdateUser(ctx context.Context, request *apiv2pb.UpdateUserRequest) (*apiv2pb.UpdateUserResponse, error) {
|
func (s *APIV2Service) UpdateUser(ctx context.Context, request *apiv2pb.UpdateUserRequest) (*apiv2pb.UpdateUserResponse, error) {
|
||||||
username, err := GetUsername(request.User.Name)
|
username, err := ExtractUsernameFromName(request.User.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(codes.InvalidArgument, "name is required")
|
return nil, status.Errorf(codes.InvalidArgument, "name is required")
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ func (s *APIV2Service) ListUserAccessTokens(ctx context.Context, request *apiv2p
|
|||||||
}
|
}
|
||||||
|
|
||||||
userID := user.ID
|
userID := user.ID
|
||||||
username, err := GetUsername(request.Name)
|
username, err := ExtractUsernameFromName(request.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(codes.InvalidArgument, "name is required")
|
return nil, status.Errorf(codes.InvalidArgument, "name is required")
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { toast } from "react-hot-toast";
|
import { toast } from "react-hot-toast";
|
||||||
import { useUserStore } from "@/store/module";
|
import { useUserV1Store, UserNamePrefix } from "@/store/v1";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
import { generateDialog } from "./Dialog";
|
import { generateDialog } from "./Dialog";
|
||||||
import Icon from "./Icon";
|
import Icon from "./Icon";
|
||||||
@ -10,9 +10,9 @@ interface Props extends DialogProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ChangeMemberPasswordDialog: React.FC<Props> = (props: Props) => {
|
const ChangeMemberPasswordDialog: React.FC<Props> = (props: Props) => {
|
||||||
const { user: propsUser, destroy } = props;
|
const { user, destroy } = props;
|
||||||
const t = useTranslate();
|
const t = useTranslate();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserV1Store();
|
||||||
const [newPassword, setNewPassword] = useState("");
|
const [newPassword, setNewPassword] = useState("");
|
||||||
const [newPasswordAgain, setNewPasswordAgain] = useState("");
|
const [newPasswordAgain, setNewPasswordAgain] = useState("");
|
||||||
|
|
||||||
@ -47,10 +47,13 @@ const ChangeMemberPasswordDialog: React.FC<Props> = (props: Props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await userStore.patchUser({
|
await userStore.updateUser(
|
||||||
id: propsUser.id,
|
{
|
||||||
password: newPassword,
|
name: `${UserNamePrefix}${user.username}`,
|
||||||
});
|
password: newPassword,
|
||||||
|
},
|
||||||
|
["password"]
|
||||||
|
);
|
||||||
toast(t("message.password-changed"));
|
toast(t("message.password-changed"));
|
||||||
handleCloseBtnClick();
|
handleCloseBtnClick();
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
@ -63,7 +66,7 @@ const ChangeMemberPasswordDialog: React.FC<Props> = (props: Props) => {
|
|||||||
<>
|
<>
|
||||||
<div className="dialog-header-container !w-64">
|
<div className="dialog-header-container !w-64">
|
||||||
<p className="title-text">
|
<p className="title-text">
|
||||||
{t("setting.account-section.change-password")} ({propsUser.username})
|
{t("setting.account-section.change-password")} ({user.username})
|
||||||
</p>
|
</p>
|
||||||
<button className="btn close-btn" onClick={handleCloseBtnClick}>
|
<button className="btn close-btn" onClick={handleCloseBtnClick}>
|
||||||
<Icon.X />
|
<Icon.X />
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { toast } from "react-hot-toast";
|
import { toast } from "react-hot-toast";
|
||||||
import { useGlobalStore, useUserStore } from "@/store/module";
|
import { useGlobalStore, useUserStore } from "@/store/module";
|
||||||
import { useUserV1Store } from "@/store/v1";
|
import { useUserV1Store, UserNamePrefix } from "@/store/v1";
|
||||||
import { UserNamePrefix } from "@/store/v1/resourceName";
|
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
import { generateDialog } from "./Dialog";
|
import { generateDialog } from "./Dialog";
|
||||||
import Icon from "./Icon";
|
import Icon from "./Icon";
|
||||||
|
@ -3,7 +3,7 @@ import { useEffect } from "react";
|
|||||||
import { NavLink, useLocation } from "react-router-dom";
|
import { NavLink, useLocation } from "react-router-dom";
|
||||||
import useCurrentUser from "@/hooks/useCurrentUser";
|
import useCurrentUser from "@/hooks/useCurrentUser";
|
||||||
import { useLayoutStore } from "@/store/module";
|
import { useLayoutStore } from "@/store/module";
|
||||||
import useInboxStore from "@/store/v1/inbox";
|
import { useInboxStore } from "@/store/v1";
|
||||||
import { Inbox_Status } from "@/types/proto/api/v2/inbox_service";
|
import { Inbox_Status } from "@/types/proto/api/v2/inbox_service";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
import { resolution } from "@/utils/layout";
|
import { resolution } from "@/utils/layout";
|
||||||
|
@ -4,8 +4,7 @@ import { useEffect, useState } from "react";
|
|||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import { activityServiceClient } from "@/grpcweb";
|
import { activityServiceClient } from "@/grpcweb";
|
||||||
import useNavigateTo from "@/hooks/useNavigateTo";
|
import useNavigateTo from "@/hooks/useNavigateTo";
|
||||||
import useInboxStore from "@/store/v1/inbox";
|
import { useInboxStore, extractUsernameFromName } from "@/store/v1";
|
||||||
import { extractUsernameFromName } from "@/store/v1/resourceName";
|
|
||||||
import { Activity } from "@/types/proto/api/v2/activity_service";
|
import { Activity } from "@/types/proto/api/v2/activity_service";
|
||||||
import { Inbox, Inbox_Status } from "@/types/proto/api/v2/inbox_service";
|
import { Inbox, Inbox_Status } from "@/types/proto/api/v2/inbox_service";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
|
@ -8,8 +8,7 @@ import { getRelativeTimeString } from "@/helpers/datetime";
|
|||||||
import useCurrentUser from "@/hooks/useCurrentUser";
|
import useCurrentUser from "@/hooks/useCurrentUser";
|
||||||
import useNavigateTo from "@/hooks/useNavigateTo";
|
import useNavigateTo from "@/hooks/useNavigateTo";
|
||||||
import { useFilterStore, useMemoStore, useUserStore } from "@/store/module";
|
import { useFilterStore, useMemoStore, useUserStore } from "@/store/module";
|
||||||
import { useUserV1Store } from "@/store/v1";
|
import { useUserV1Store, extractUsernameFromName } from "@/store/v1";
|
||||||
import { extractUsernameFromName } from "@/store/v1/resourceName";
|
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
import showChangeMemoCreatedTsDialog from "./ChangeMemoCreatedTsDialog";
|
import showChangeMemoCreatedTsDialog from "./ChangeMemoCreatedTsDialog";
|
||||||
import { showCommonDialog } from "./Dialog/CommonDialog";
|
import { showCommonDialog } from "./Dialog/CommonDialog";
|
||||||
|
@ -7,7 +7,7 @@ import { getTimeStampByDate } from "@/helpers/datetime";
|
|||||||
import useCurrentUser from "@/hooks/useCurrentUser";
|
import useCurrentUser from "@/hooks/useCurrentUser";
|
||||||
import { TAG_REG } from "@/labs/marked/parser";
|
import { TAG_REG } from "@/labs/marked/parser";
|
||||||
import { useFilterStore, useMemoStore } from "@/store/module";
|
import { useFilterStore, useMemoStore } from "@/store/module";
|
||||||
import { extractUsernameFromName } from "@/store/v1/resourceName";
|
import { extractUsernameFromName } from "@/store/v1";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
import Empty from "./Empty";
|
import Empty from "./Empty";
|
||||||
import Memo from "./Memo";
|
import Memo from "./Memo";
|
||||||
|
@ -4,7 +4,7 @@ import { useEffect, useState } from "react";
|
|||||||
import { toast } from "react-hot-toast";
|
import { toast } from "react-hot-toast";
|
||||||
import { userServiceClient } from "@/grpcweb";
|
import { userServiceClient } from "@/grpcweb";
|
||||||
import useCurrentUser from "@/hooks/useCurrentUser";
|
import useCurrentUser from "@/hooks/useCurrentUser";
|
||||||
import { extractUsernameFromName } from "@/store/v1/resourceName";
|
import { extractUsernameFromName } from "@/store/v1";
|
||||||
import { UserAccessToken } from "@/types/proto/api/v2/user_service";
|
import { UserAccessToken } from "@/types/proto/api/v2/user_service";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
import showCreateAccessTokenDialog from "../CreateAccessTokenDialog";
|
import showCreateAccessTokenDialog from "../CreateAccessTokenDialog";
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Button } from "@mui/joy";
|
import { Button } from "@mui/joy";
|
||||||
import useCurrentUser from "@/hooks/useCurrentUser";
|
import useCurrentUser from "@/hooks/useCurrentUser";
|
||||||
import { extractUsernameFromName } from "@/store/v1/resourceName";
|
import { extractUsernameFromName } from "@/store/v1";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
import showChangePasswordDialog from "../ChangePasswordDialog";
|
import showChangePasswordDialog from "../ChangePasswordDialog";
|
||||||
import showUpdateAccountDialog from "../UpdateAccountDialog";
|
import showUpdateAccountDialog from "../UpdateAccountDialog";
|
||||||
|
@ -5,8 +5,7 @@ import { toast } from "react-hot-toast";
|
|||||||
import { getDateTimeString } from "@/helpers/datetime";
|
import { getDateTimeString } from "@/helpers/datetime";
|
||||||
import useLoading from "@/hooks/useLoading";
|
import useLoading from "@/hooks/useLoading";
|
||||||
import toImage from "@/labs/html2image";
|
import toImage from "@/labs/html2image";
|
||||||
import { useUserV1Store } from "@/store/v1";
|
import { useUserV1Store, extractUsernameFromName } from "@/store/v1";
|
||||||
import { extractUsernameFromName } from "@/store/v1/resourceName";
|
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
import { generateDialog } from "./Dialog";
|
import { generateDialog } from "./Dialog";
|
||||||
import showEmbedMemoDialog from "./EmbedMemoDialog";
|
import showEmbedMemoDialog from "./EmbedMemoDialog";
|
||||||
|
@ -5,8 +5,7 @@ import { getDateStampByDate, getDateString, getTimeStampByDate } from "@/helpers
|
|||||||
import * as utils from "@/helpers/utils";
|
import * as utils from "@/helpers/utils";
|
||||||
import useCurrentUser from "@/hooks/useCurrentUser";
|
import useCurrentUser from "@/hooks/useCurrentUser";
|
||||||
import { useGlobalStore } from "@/store/module";
|
import { useGlobalStore } from "@/store/module";
|
||||||
import { useUserV1Store } from "@/store/v1";
|
import { useUserV1Store, extractUsernameFromName } from "@/store/v1";
|
||||||
import { extractUsernameFromName } from "@/store/v1/resourceName";
|
|
||||||
import { useTranslate, Translations } from "@/utils/i18n";
|
import { useTranslate, Translations } from "@/utils/i18n";
|
||||||
import { useFilterStore, useMemoStore } from "../store/module";
|
import { useFilterStore, useMemoStore } from "../store/module";
|
||||||
import "@/less/usage-heat-map.less";
|
import "@/less/usage-heat-map.less";
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import useCurrentUser from "@/hooks/useCurrentUser";
|
import useCurrentUser from "@/hooks/useCurrentUser";
|
||||||
import useNavigateTo from "@/hooks/useNavigateTo";
|
import useNavigateTo from "@/hooks/useNavigateTo";
|
||||||
import { useGlobalStore, useUserStore } from "@/store/module";
|
import { useGlobalStore, useUserStore } from "@/store/module";
|
||||||
import { extractUsernameFromName } from "@/store/v1/resourceName";
|
import { extractUsernameFromName } from "@/store/v1";
|
||||||
import { User_Role } from "@/types/proto/api/v2/user_service";
|
import { User_Role } from "@/types/proto/api/v2/user_service";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
import showAboutSiteDialog from "./AboutSiteDialog";
|
import showAboutSiteDialog from "./AboutSiteDialog";
|
||||||
|
@ -5,7 +5,7 @@ import { getMemoStats } from "@/helpers/api";
|
|||||||
import { DAILY_TIMESTAMP } from "@/helpers/consts";
|
import { DAILY_TIMESTAMP } from "@/helpers/consts";
|
||||||
import { getDateStampByDate, isFutureDate } from "@/helpers/datetime";
|
import { getDateStampByDate, isFutureDate } from "@/helpers/datetime";
|
||||||
import useCurrentUser from "@/hooks/useCurrentUser";
|
import useCurrentUser from "@/hooks/useCurrentUser";
|
||||||
import { extractUsernameFromName } from "@/store/v1/resourceName";
|
import { extractUsernameFromName } from "@/store/v1";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
import Icon from "../Icon";
|
import Icon from "../Icon";
|
||||||
import "@/less/common/date-picker.less";
|
import "@/less/common/date-picker.less";
|
||||||
|
@ -15,7 +15,7 @@ import { DAILY_TIMESTAMP, DEFAULT_MEMO_LIMIT } from "@/helpers/consts";
|
|||||||
import { getDateStampByDate, getNormalizedDateString, getTimeStampByDate, getTimeString } from "@/helpers/datetime";
|
import { getDateStampByDate, getNormalizedDateString, getTimeStampByDate, getTimeString } from "@/helpers/datetime";
|
||||||
import useCurrentUser from "@/hooks/useCurrentUser";
|
import useCurrentUser from "@/hooks/useCurrentUser";
|
||||||
import { useMemoStore, useUserStore } from "@/store/module";
|
import { useMemoStore, useUserStore } from "@/store/module";
|
||||||
import { extractUsernameFromName } from "@/store/v1/resourceName";
|
import { extractUsernameFromName } from "@/store/v1";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
|
|
||||||
const DailyReview = () => {
|
const DailyReview = () => {
|
||||||
|
@ -3,7 +3,7 @@ import Empty from "@/components/Empty";
|
|||||||
import Icon from "@/components/Icon";
|
import Icon from "@/components/Icon";
|
||||||
import MemoCommentMessage from "@/components/Inbox/MemoCommentMessage";
|
import MemoCommentMessage from "@/components/Inbox/MemoCommentMessage";
|
||||||
import MobileHeader from "@/components/MobileHeader";
|
import MobileHeader from "@/components/MobileHeader";
|
||||||
import useInboxStore from "@/store/v1/inbox";
|
import { useInboxStore } from "@/store/v1";
|
||||||
import { Inbox_Type } from "@/types/proto/api/v2/inbox_service";
|
import { Inbox_Type } from "@/types/proto/api/v2/inbox_service";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
|
|
||||||
|
@ -19,8 +19,7 @@ import { getDateTimeString } from "@/helpers/datetime";
|
|||||||
import useCurrentUser from "@/hooks/useCurrentUser";
|
import useCurrentUser from "@/hooks/useCurrentUser";
|
||||||
import useNavigateTo from "@/hooks/useNavigateTo";
|
import useNavigateTo from "@/hooks/useNavigateTo";
|
||||||
import { useGlobalStore, useMemoStore } from "@/store/module";
|
import { useGlobalStore, useMemoStore } from "@/store/module";
|
||||||
import { useUserV1Store } from "@/store/v1";
|
import { useUserV1Store, extractUsernameFromName } from "@/store/v1";
|
||||||
import { extractUsernameFromName } from "@/store/v1/resourceName";
|
|
||||||
import { User, User_Role } from "@/types/proto/api/v2/user_service";
|
import { User, User_Role } from "@/types/proto/api/v2/user_service";
|
||||||
import { useTranslate } from "@/utils/i18n";
|
import { useTranslate } from "@/utils/i18n";
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ interface InboxStore {
|
|||||||
updateInbox: (inbox: Partial<Inbox>, updateMask: string[]) => Promise<Inbox>;
|
updateInbox: (inbox: Partial<Inbox>, updateMask: string[]) => Promise<Inbox>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const useInboxStore = create<InboxStore>()((set, get) => ({
|
export const useInboxStore = create<InboxStore>()((set, get) => ({
|
||||||
inboxes: [],
|
inboxes: [],
|
||||||
fetchInboxes: async () => {
|
fetchInboxes: async () => {
|
||||||
const { inboxes } = await inboxServiceClient.listInboxes({});
|
const { inboxes } = await inboxServiceClient.listInboxes({});
|
||||||
@ -28,5 +28,3 @@ const useInboxStore = create<InboxStore>()((set, get) => ({
|
|||||||
return updatedInbox;
|
return updatedInbox;
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export default useInboxStore;
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import useMemoCacheStore from "./memo";
|
export * from "./user";
|
||||||
import useUserV1Store from "./user";
|
export * from "./memo";
|
||||||
|
export * from "./inbox";
|
||||||
export { useUserV1Store, useMemoCacheStore };
|
export * from "./resourceName";
|
||||||
|
@ -3,7 +3,7 @@ import { combine } from "zustand/middleware";
|
|||||||
import * as api from "@/helpers/api";
|
import * as api from "@/helpers/api";
|
||||||
import { convertResponseModelMemo } from "../module";
|
import { convertResponseModelMemo } from "../module";
|
||||||
|
|
||||||
const useMemoCacheStore = create(
|
export const useMemoCacheStore = create(
|
||||||
combine({ memoById: new Map<MemoId, Memo>() }, (set, get) => ({
|
combine({ memoById: new Map<MemoId, Memo>() }, (set, get) => ({
|
||||||
getState: () => get(),
|
getState: () => get(),
|
||||||
getOrFetchMemoById: async (memoId: MemoId) => {
|
getOrFetchMemoById: async (memoId: MemoId) => {
|
||||||
@ -39,5 +39,3 @@ const useMemoCacheStore = create(
|
|||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
|
|
||||||
export default useMemoCacheStore;
|
|
||||||
|
@ -13,7 +13,7 @@ interface UserV1Store {
|
|||||||
// Request cache is used to prevent multiple requests.
|
// Request cache is used to prevent multiple requests.
|
||||||
const requestCache = new Map<string, Promise<any>>();
|
const requestCache = new Map<string, Promise<any>>();
|
||||||
|
|
||||||
const useUserV1Store = create<UserV1Store>()((set, get) => ({
|
export const useUserV1Store = create<UserV1Store>()((set, get) => ({
|
||||||
userMapByUsername: {},
|
userMapByUsername: {},
|
||||||
getOrFetchUserByUsername: async (username: string) => {
|
getOrFetchUserByUsername: async (username: string) => {
|
||||||
const userMap = get().userMapByUsername;
|
const userMap = get().userMapByUsername;
|
||||||
@ -58,5 +58,3 @@ const useUserV1Store = create<UserV1Store>()((set, get) => ({
|
|||||||
return updatedUser;
|
return updatedUser;
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export default useUserV1Store;
|
|
||||||
|
Reference in New Issue
Block a user