mirror of
https://github.com/aykhans/slash-e.git
synced 2025-07-04 04:23:16 +00:00
chore: fix view shortcut activity
This commit is contained in:
@ -32,7 +32,6 @@ const CollectionSpace = () => {
|
||||
(async () => {
|
||||
try {
|
||||
const collection = await collectionStore.fetchCollectionByName(collectionName);
|
||||
await userStore.getOrFetchUserById(collection.creatorId);
|
||||
setCollection(collection);
|
||||
setShortcuts([]);
|
||||
for (const shortcutId of collection.shortcutIds) {
|
||||
|
@ -13,7 +13,7 @@ const ShortcutSpace = () => {
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
try {
|
||||
await shortcutStore.getOrFetchShortcutByName(shortcutName);
|
||||
await shortcutStore.getOrFetchShortcutByName(shortcutName, true);
|
||||
} catch (error: any) {
|
||||
console.error(error);
|
||||
toast.error(error.details);
|
||||
@ -26,6 +26,7 @@ const ShortcutSpace = () => {
|
||||
}
|
||||
|
||||
if (isURL(shortcut.link)) {
|
||||
window.document.title = "Redirecting...";
|
||||
window.location.href = shortcut.link;
|
||||
return null;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ interface ShortcutState {
|
||||
shortcutMapByName: Record<string, Shortcut>;
|
||||
fetchShortcutList: () => Promise<Shortcut[]>;
|
||||
fetchShortcutById: (id: number) => Promise<Shortcut>;
|
||||
getOrFetchShortcutByName: (name: string) => Promise<Shortcut>;
|
||||
getOrFetchShortcutByName: (name: string, recordView?: boolean) => Promise<Shortcut>;
|
||||
getShortcutByName: (name: string) => Shortcut;
|
||||
getShortcutList: () => Shortcut[];
|
||||
createShortcut: (shortcut: Shortcut) => Promise<Shortcut>;
|
||||
@ -36,7 +36,7 @@ const useShortcutStore = create<ShortcutState>()((set, get) => ({
|
||||
}
|
||||
return shortcut;
|
||||
},
|
||||
getOrFetchShortcutByName: async (name: string) => {
|
||||
getOrFetchShortcutByName: async (name: string, recordView = false) => {
|
||||
const shortcutMap = get().shortcutMapByName;
|
||||
if (shortcutMap[name]) {
|
||||
return shortcutMap[name] as Shortcut;
|
||||
@ -44,6 +44,7 @@ const useShortcutStore = create<ShortcutState>()((set, get) => ({
|
||||
|
||||
const { shortcut } = await shortcutServiceClient.getShortcut({
|
||||
name,
|
||||
recordView,
|
||||
});
|
||||
if (!shortcut) {
|
||||
throw new Error(`Shortcut with name ${name} not found`);
|
||||
|
Reference in New Issue
Block a user