Skip to content

TagSpaces is an offline, open source, document manager with tagging support

Create context provider for the history and bookmarks (#2097)

Stanimir9ee8b2f28528
diff --git a/src/renderer/components/EntryContainer.tsx b/src/renderer/components/EntryContainer.tsx
index 80b648bd4..00bb6af65 100644
--- a/src/renderer/components/EntryContainer.tsx
+++ b/src/renderer/components/EntryContainer.tsx
@@ -19,6 +19,7 @@
import React, {
MutableRefObject,
useCallback,
+ useContext,
useEffect,
useReducer,
useRef,
@@ -71,7 +72,7 @@ import { SaveIcon, EditIcon } from '-/components/CommonIcons';
import { useIOActionsContext } from '-/hooks/useIOActionsContext';
import { usePerspectiveActionsContext } from '-/hooks/usePerspectiveActionsContext';
-const historyKeys = Pro && Pro.history ? Pro.history.historyKeys : {};
+const historyKeys = Pro ? Pro.keys.historyKeys : {};
function EntryContainer() {
const { t } = useTranslation();
@@ -94,6 +95,9 @@ function EntryContainer() {
const { copyFilePromiseOverwrite, copyFilePromise, saveTextFilePromise } =
usePlatformFacadeContext();
const { showNotification } = useNotificationContext();
+ const historyContext = Pro?.contextProviders?.HistoryContext
+ ? useContext<TS.HistoryContextData>(Pro.contextProviders.HistoryContext)
+ : undefined;
const tabIndex = useSelector(getEntryContainerTab);
const fileEditHistoryKey = useSelector(
(state: any) => state.settings[historyKeys.fileEditKey],
@@ -527,9 +531,10 @@ function EntryContainer() {
currentLocationPath,
fileOpen.path,
);
- Pro.history.saveHistory(
+ historyContext.saveHistory(
historyKeys.fileEditKey,
{
+ creationTimeStamp: new Date().getTime(),
path: relativePath,
url: generateSharingLink(fileOpen.locationID, relativePath),
lid: fileOpen.locationID,
diff --git a/src/renderer/components/EntryContainerTitle.tsx b/src/renderer/components/EntryContainerTitle.tsx
index d1dea0526..a26fab351 100644
--- a/src/renderer/components/EntryContainerTitle.tsx
+++ b/src/renderer/components/EntryContainerTitle.tsx
@@ -16,7 +16,7 @@
*
*/
-import React, { useReducer } from 'react';
+import React, { useContext, useReducer } from 'react';
import { styled, useTheme } from '@mui/material/styles';
import {
extractTitle,
@@ -41,6 +41,7 @@ import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
import { useNotificationContext } from '-/hooks/useNotificationContext';
import { getAllTags } from '-/services/utils-io';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
+import { TS } from '-/tagspaces.namespace';
const FileBadge = styled('span')(({ theme }) => ({
color: 'white',
@@ -79,15 +80,16 @@ function EntryContainerTitle(props: Props) {
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);
- const haveBookmark =
- Pro && Pro.bookmarks && Pro.bookmarks.haveBookmark(openedEntry.path);
+ const bookmarksContext = Pro?.contextProviders?.BookmarksContext
+ ? useContext<TS.BookmarksContextData>(Pro.contextProviders.BookmarksContext)
+ : undefined;
const bookmarkClick = () => {
- if (Pro) {
- if (haveBookmark) {
- Pro.bookmarks.delBookmark(openedEntry.path);
+ if (Pro && bookmarksContext) {
+ if (bookmarksContext.haveBookmark(openedEntry.path)) {
+ bookmarksContext.delBookmark(openedEntry.path);
} else {
- Pro.bookmarks.setBookmark(openedEntry.path, sharingLink);
+ bookmarksContext.setBookmark(openedEntry.path, sharingLink);
}
forceUpdate();
} else {
@@ -242,7 +244,8 @@ function EntryContainerTitle(props: Props) {
WebkitAppRegion: 'no-drag',
}}
>
- {haveBookmark ? (
+ {bookmarksContext &&
+ bookmarksContext.haveBookmark(openedEntry.path) ? (
<BookmarkIcon
style={{
color: theme.palette.primary.main,
diff --git a/src/renderer/components/RenderHistory.tsx b/src/renderer/components/RenderHistory.tsx
index f543866f5..ee3c92713 100644
--- a/src/renderer/components/RenderHistory.tsx
+++ b/src/renderer/components/RenderHistory.tsx
@@ -18,7 +18,7 @@
import { TS } from '-/tagspaces.namespace';
import Grid from '@mui/material/Grid';
-import React from 'react';
+import React, { useContext } from 'react';
import Button from '@mui/material/Button';
import ListItem from '@mui/material/ListItem';
import { Tooltip } from '@mui/material';
@@ -47,6 +47,12 @@ function RenderHistory(props: Props) {
// const dispatch: AppDispatch = useDispatch();
const { openEntry, openLink } = useOpenedEntryContext();
const { openLocationById, currentLocation } = useCurrentLocationContext();
+ const bookmarksContext = Pro?.contextProviders?.BookmarksContext
+ ? useContext<TS.BookmarksContextData>(Pro.contextProviders.BookmarksContext)
+ : undefined;
+ const historyContext = Pro?.contextProviders?.HistoryContext
+ ? useContext<TS.HistoryContextData>(Pro.contextProviders.HistoryContext)
+ : undefined;
const { historyKey, items, update, maxItems, showDelete = true } = props;
const openLinkDispatch = (link) => openLink(link, { fullWidth: false });
@@ -76,13 +82,7 @@ function RenderHistory(props: Props) {
justifyContent: 'start',
}}
onClick={() =>
- Pro.history.openItem(
- item,
- currentLocation && currentLocation.uuid,
- openLinkDispatch,
- openLocationById,
- openEntry,
- )
+ historyContext.openItem(item as TS.HistoryItem)
}
>
<Tooltip
@@ -100,7 +100,7 @@ function RenderHistory(props: Props) {
</span>
}
>
- {historyKey === Pro.bookmarks.bookmarksKey ? (
+ {historyKey === Pro.keys.bookmarksKey ? (
<BookmarkTwoToneIcon fontSize="small" />
) : (
<HistoryIcon fontSize="small" />
@@ -124,7 +124,12 @@ function RenderHistory(props: Props) {
<IconButton
aria-label={t('core:clearHistory')}
onClick={() => {
- Pro.history.delItem(item, historyKey);
+ if (historyKey === Pro.keys.bookmarksKey) {
+ //del bookmarks
+ bookmarksContext.delBookmark(item.path);
+ } else {
+ historyContext.delHistory(item, historyKey);
+ }
update();
}}
data-tid="deleteHistoryItemTID"
diff --git a/src/renderer/components/SearchAutocomplete.tsx b/src/renderer/components/SearchAutocomplete.tsx
index 127e264e5..012dd0ada 100644
--- a/src/renderer/components/SearchAutocomplete.tsx
+++ b/src/renderer/components/SearchAutocomplete.tsx
@@ -16,7 +16,13 @@
*
*/
-import React, { useEffect, useReducer, useRef, useState } from 'react';
+import React, {
+ useContext,
+ useEffect,
+ useReducer,
+ useRef,
+ useState,
+} from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { format, formatDistanceToNow } from 'date-fns';
import HelpOutlineIcon from '@mui/icons-material/HelpOutline';
@@ -97,6 +103,12 @@ function SearchAutocomplete(props: Props) {
} = useDirectoryContentContext();
const { isIndexing, searchAllLocations, searchLocationIndex } =
useLocationIndexContext();
+ const bookmarksContext = Pro?.contextProviders?.BookmarksContext
+ ? useContext<TS.BookmarksContextData>(Pro.contextProviders.BookmarksContext)
+ : undefined;
+ const historyContext = Pro?.contextProviders?.HistoryContext
+ ? useContext<TS.HistoryContextData>(Pro.contextProviders.HistoryContext)
+ : undefined;
const dispatch: AppDispatch = useDispatch();
const maxSearchResults = useSelector(getMaxSearchResults);
const showUnixHiddenEntries = useSelector(getShowUnixHiddenEntries);
@@ -146,7 +158,6 @@ function SearchAutocomplete(props: Props) {
const isOpen = useRef<boolean>(true);
// const firstRender = useFirstRender();
- const historyKeys = Pro && Pro.history ? Pro.history.historyKeys : {};
useEffect(() => {
processSearchQuery();
@@ -564,13 +575,13 @@ function SearchAutocomplete(props: Props) {
currentOptions.current = action;
const fileOpenHistoryItems: Array<TS.HistoryItem> = Pro
- ? Pro.history.getHistory(historyKeys.fileOpenKey)
+ ? historyContext.fileOpenHistory
: [];
const folderOpenHistoryItems: Array<TS.HistoryItem> = Pro
- ? Pro.history.getHistory(historyKeys.folderOpenKey)
+ ? historyContext.folderOpenHistory
: [];
const fileEditHistoryItems: Array<TS.HistoryItem> = Pro
- ? Pro.history.getHistory(historyKeys.fileEditKey)
+ ? historyContext.fileEditHistory
: [];
searchOptions.current = [
@@ -586,7 +597,7 @@ function SearchAutocomplete(props: Props) {
if (currentOptions.current !== action) {
currentOptions.current = action;
const bookmarks: Array<TS.BookmarkItem> =
- Pro && Pro.bookmarks && Pro.bookmarks.getBookmarks();
+ Pro && bookmarksContext && bookmarksContext.bookmarks; //getBookmarks();
function getOptions(
items: TS.BookmarkItem[],
@@ -614,7 +625,7 @@ function SearchAutocomplete(props: Props) {
}
} else if (isAction(action, SearchActions.SEARCH_HISTORY)) {
const searchHistoryItems: Array<TS.HistoryItem> = Pro
- ? Pro.history.getHistory(historyKeys.searchHistoryKey)
+ ? historyContext.searchHistory
: [];
searchOptions.current = getHistoryOptions(
searchHistoryItems,
@@ -873,40 +884,28 @@ function SearchAutocomplete(props: Props) {
setSearchQuery(option.searchQuery);
} else {
}
- } else if (Pro && Pro.history) {
+ } else if (Pro && historyContext) {
const item: TS.HistoryItem = {
path: option.label,
url: option.fullName,
lid: option.id,
creationTimeStamp: 0,
};
- Pro.history.openItem(
- item,
- currentLocation && currentLocation.uuid,
- openLinkDispatch,
- openLocationById,
- openEntry,
- );
+ historyContext.openItem(item);
}
searchOptions.current = getSearchOptions();
currentOptions.current = undefined;
isOpen.current = false;
return [];
} else if (option.action === ExecActions.OPEN_BOOKMARK) {
- if (Pro && Pro.history) {
+ if (Pro && historyContext) {
const item: TS.HistoryItem = {
path: option.label,
url: option.fullName,
lid: undefined,
creationTimeStamp: 0,
};
- Pro.history.openItem(
- item,
- currentLocation && currentLocation.uuid,
- openLinkDispatch,
- openLocationById,
- openEntry,
- );
+ historyContext.openItem(item);
}
searchOptions.current = getSearchOptions();
currentOptions.current = undefined;
diff --git a/src/renderer/components/StoredSearches.tsx b/src/renderer/components/StoredSearches.tsx
index 3f644c031..7baad3232 100644
--- a/src/renderer/components/StoredSearches.tsx
+++ b/src/renderer/components/StoredSearches.tsx
@@ -16,7 +16,7 @@
*
*/
-import React, { useReducer, useRef, useState } from 'react';
+import React, { useContext, useReducer, useRef, useState } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import classNames from 'classnames';
@@ -70,11 +70,18 @@ interface Props {
}
const SaveSearchDialog = Pro && Pro.UI ? Pro.UI.SaveSearchDialog : false;
-const historyKeys = Pro && Pro.history ? Pro.history.historyKeys : {};
function StoredSearches(props: Props) {
const { t } = useTranslation();
const { setSearchQuery, findFromSavedSearch } = useDirectoryContentContext();
+ const bookmarksContext = Pro?.contextProviders?.BookmarksContext
+ ? useContext<TS.BookmarksContextData>(
+ Pro?.contextProviders?.BookmarksContext,
+ )
+ : undefined;
+ const historyContext = Pro?.contextProviders?.HistoryContext
+ ? useContext<TS.HistoryContextData>(Pro.contextProviders.HistoryContext)
+ : undefined;
const [saveSearchDialogOpened, setSaveSearchDialogOpened] =
useState<TS.SearchQuery>(undefined);
const [searchMenuAnchorEl, setSearchMenuAnchorEl] =
@@ -91,6 +98,7 @@ function StoredSearches(props: Props) {
const [importFile, setImportFile] = useState<File>(undefined);
const fileInputRef = useRef<HTMLInputElement>(null);
const menuHistoryKey = useRef<string>(undefined);
+ const historyKeys = Pro ? Pro.keys.historyKeys : {};
const [ignored, forceUpdate] = useReducer((x) => x + 1, 0);
const ExportSearchesDialog =
@@ -128,17 +136,18 @@ function StoredSearches(props: Props) {
const { reduceHeightBy } = props;
- const bookmarkItems: Array<TS.BookmarkItem> = Pro
- ? Pro.bookmarks.getBookmarks()
- : [];
+ const bookmarkItems: Array<TS.BookmarkItem> =
+ Pro && bookmarksContext
+ ? bookmarksContext.bookmarks //getBookmarks()
+ : [];
const fileOpenHistoryItems: Array<TS.HistoryItem> = Pro
- ? Pro.history.getHistory(historyKeys.fileOpenKey)
+ ? historyContext.fileOpenHistory
: [];
const fileEditHistoryItems: Array<TS.HistoryItem> = Pro
- ? Pro.history.getHistory(historyKeys.fileEditKey)
+ ? historyContext.fileEditHistory
: [];
const folderOpenHistoryItems: Array<TS.HistoryItem> = Pro
- ? Pro.history.getHistory(historyKeys.folderOpenKey)
+ ? historyContext.folderOpenHistory
: [];
const bookmarksAvailable = bookmarkItems && bookmarkItems.length > 0;
@@ -324,7 +333,7 @@ function StoredSearches(props: Props) {
</Grid>
{Pro && props.showBookmarks && (
<RenderHistory
- historyKey={Pro.bookmarks.bookmarksKey}
+ historyKey={Pro.keys.bookmarksKey}
items={bookmarkItems}
update={forceUpdate}
/>
@@ -468,7 +477,7 @@ function StoredSearches(props: Props) {
refreshHistory={() => forceUpdate()}
clearAll={() => {
if (Pro) {
- Pro.history.delAllHistory(menuHistoryKey.current);
+ historyContext.delAllHistory(menuHistoryKey.current);
} //historyKeys.fileOpenKey);
forceUpdate();
}}
@@ -479,8 +488,8 @@ function StoredSearches(props: Props) {
onClose={() => setBookmarksMenuAnchorEl(null)}
refresh={() => forceUpdate()}
clearAll={() => {
- if (Pro) {
- Pro.bookmarks.delAllBookmarks();
+ if (Pro && bookmarksContext) {
+ bookmarksContext.delAllBookmarks();
} //historyKeys.fileOpenKey);
forceUpdate();
}}
diff --git a/src/renderer/components/WelcomePanel.tsx b/src/renderer/components/WelcomePanel.tsx
index fb4029dc1..bce5ba6d0 100644
--- a/src/renderer/components/WelcomePanel.tsx
+++ b/src/renderer/components/WelcomePanel.tsx
@@ -16,7 +16,7 @@
*
*/
-import React, { useReducer } from 'react';
+import React, { useContext, useReducer } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import Typography from '@mui/material/Typography';
import List from '@mui/material/List';
@@ -83,6 +83,9 @@ const Root = styled('div')(({ theme }) => ({
function WelcomePanel() {
const { t } = useTranslation();
const theme = useTheme();
+ const historyContext = Pro?.contextProviders?.HistoryContext
+ ? useContext<TS.HistoryContextData>(Pro.contextProviders.HistoryContext)
+ : undefined;
const dispatch: AppDispatch = useDispatch();
const desktopMode = useSelector(getDesktopMode);
@@ -97,15 +100,15 @@ function WelcomePanel() {
const [ignored, forceUpdate] = useReducer((x) => x + 1, 0);
- const historyKeys = Pro && Pro.history ? Pro.history.historyKeys : {};
+ const historyKeys = Pro ? Pro.keys.historyKeys : {};
const fileOpenHistoryItems: Array<TS.HistoryItem> = Pro
- ? Pro.history.getHistory(historyKeys.fileOpenKey)
+ ? historyContext.fileOpenHistory
: [];
const fileEditHistoryItems: Array<TS.HistoryItem> = Pro
- ? Pro.history.getHistory(historyKeys.fileEditKey)
+ ? historyContext.fileEditHistory
: [];
const folderOpenHistoryItems: Array<TS.HistoryItem> = Pro
- ? Pro.history.getHistory(historyKeys.folderOpenKey)
+ ? historyContext.folderOpenHistory
: [];
const showDelete = false;
diff --git a/src/renderer/components/dialogs/settings/SettingsAdvanced.tsx b/src/renderer/components/dialogs/settings/SettingsAdvanced.tsx
index bd1369a2d..6e794593c 100644
--- a/src/renderer/components/dialogs/settings/SettingsAdvanced.tsx
+++ b/src/renderer/components/dialogs/settings/SettingsAdvanced.tsx
@@ -16,7 +16,7 @@
*
*/
-import React, { useState } from 'react';
+import React, { useContext, useState } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import List from '@mui/material/List';
import ListItem from '@mui/material/ListItem';
@@ -80,11 +80,14 @@ interface Props {
showResetSettings: (showDialog: boolean) => void;
}
-const historyKeys = Pro && Pro.history ? Pro.history.historyKeys : {};
+const historyKeys = Pro ? Pro.keys.historyKeys : {};
function SettingsAdvanced(props: Props) {
const { showResetSettings } = props;
const { t } = useTranslation();
+ const historyContext = Pro?.contextProviders?.HistoryContext
+ ? useContext<TS.HistoryContextData>(Pro.contextProviders.HistoryContext)
+ : undefined;
const dispatch: AppDispatch = useDispatch();
const settings = useSelector(getSettings);
const tileServers: Array<TS.MapTileServer> = useSelector(getMapTileServers);
@@ -332,7 +335,7 @@ function SettingsAdvanced(props: Props) {
content={t('core:confirm' + confirmDialogKey + 'Deletion')}
confirmCallback={(result) => {
if (result) {
- Pro.history.delAllHistory(confirmDialogKey);
+ historyContext.delAllHistory(confirmDialogKey);
}
}}
cancelDialogTID={'cancelDelete' + confirmDialogKey + 'Dialog'}
diff --git a/src/renderer/containers/Root.tsx b/src/renderer/containers/Root.tsx
index ed6b47d59..6984f953d 100644
--- a/src/renderer/containers/Root.tsx
+++ b/src/renderer/containers/Root.tsx
@@ -44,6 +44,7 @@ import { TagGroupsLocationContextProvider } from '-/hooks/TagGroupsLocationConte
import { EditedTagLibraryContextProvider } from '-/hooks/EditedTagLibraryContextProvider';
import { EditedKanBanMetaContextProvider } from '-/hooks/EditedKanBanMetaContextProvider';
import { PerspectiveActionsContextProvider } from '-/hooks/PerspectiveActionsContextProvider';
+import { Pro } from '-/pro';
type RootType = {
store: Store<{}>;
@@ -82,7 +83,15 @@ export default function Root({ store, persistor }: RootType) {
<TagGroupsLocationContextProvider>
<TaggingActionsContextProvider>
<DndProvider backend={HTML5Backend}>
- <MainPage />
+ {Pro ? (
+ <Pro.contextProviders.BookmarksContextProvider>
+ <Pro.contextProviders.HistoryContextProvider>
+ <MainPage />
+ </Pro.contextProviders.HistoryContextProvider>
+ </Pro.contextProviders.BookmarksContextProvider>
+ ) : (
+ <MainPage />
+ )}
</DndProvider>
</TaggingActionsContextProvider>
</TagGroupsLocationContextProvider>
diff --git a/src/renderer/hooks/DirectoryContentContextProvider.tsx b/src/renderer/hooks/DirectoryContentContextProvider.tsx
index 89d41ee00..3c60e214d 100644
--- a/src/renderer/hooks/DirectoryContentContextProvider.tsx
+++ b/src/renderer/hooks/DirectoryContentContextProvider.tsx
@@ -18,6 +18,7 @@
import React, {
createContext,
+ useContext,
useEffect,
useMemo,
useReducer,
@@ -200,6 +201,9 @@ export const DirectoryContentContextProvider = ({
const { kanbanActions } = useEditedKanBanMetaContext();
const { showNotification, hideNotifications } = useNotificationContext();
const { selectedEntries, setSelectedEntries } = useSelectedEntriesContext();
+ const historyContext = Pro?.contextProviders?.HistoryContext
+ ? useContext<TS.HistoryContextData>(Pro.contextProviders.HistoryContext)
+ : undefined;
const currentLocationPath = useRef<string>('');
//const useGenerateThumbnails = useSelector(getUseGenerateThumbnails);
@@ -210,7 +214,7 @@ export const DirectoryContentContextProvider = ({
const defaultBackgroundColor = useSelector(getTagColor);
const defaultTextColor = useSelector(getTagTextColor);
const searchHistoryKey = useSelector((state: any) =>
- Pro ? state.settings[Pro.history.historyKeys.searchHistoryKey] : undefined,
+ Pro ? state.settings[Pro.keys.historyKeys.searchHistoryKey] : undefined,
);
//const enableWS = useSelector(getEnableWS);
@@ -978,12 +982,13 @@ export const DirectoryContentContextProvider = ({
isSearchMode.current = true;
searchQuery.current = sQuery;
const searchTitle = defaultTitle(sQuery);
- if (searchTitle.length > 0 && Pro && Pro.history) {
- const historyKeys = Pro.history.historyKeys;
+ if (searchTitle.length > 0 && Pro) {
+ const historyKeys = Pro.keys.historyKeys;
if (currentLocation) {
- Pro.history.saveHistory(
+ historyContext.saveHistory(
historyKeys.searchHistoryKey,
{
+ creationTimeStamp: new Date().getTime(),
path:
searchTitle +
' ' +
diff --git a/src/renderer/hooks/OpenedEntryContextProvider.tsx b/src/renderer/hooks/OpenedEntryContextProvider.tsx
index e738ba169..074551215 100644
--- a/src/renderer/hooks/OpenedEntryContextProvider.tsx
+++ b/src/renderer/hooks/OpenedEntryContextProvider.tsx
@@ -25,7 +25,6 @@ import React, {
} from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { AppDispatch } from '-/reducers/app';
-import { Pro } from '-/pro';
import { TS } from '-/tagspaces.namespace';
import {
findExtensionPathForId,
@@ -149,19 +148,12 @@ export const OpenedEntryContextProvider = ({
const { selectedEntries, setSelectedEntries } = useSelectedEntriesContext();
const { showNotification } = useNotificationContext();
- const { actions } = useEditedEntryContext();
+ const { actions, setReflectActions } = useEditedEntryContext();
const { metaActions } = useEditedEntryMetaContext();
const { saveFilePromise } = usePlatformFacadeContext();
const supportedFileTypes = useSelector(getSupportedFileTypes);
//const locations: CommonLocation[] = useSelector(getLocations);
- const historyKeys = Pro && Pro.history ? Pro.history.historyKeys : {};
- const fileOpenHistory = useSelector(
- (state: any) => state.settings[historyKeys.fileOpenKey],
- );
- const folderOpenHistory = useSelector(
- (state: any) => state.settings[historyKeys.folderOpenKey],
- );
const newHTMLFileContent = useSelector(getNewHTMLFileContent);
const currentEntry = useRef<TS.OpenedEntry>(undefined);
/* const dirProps = useRef<TS.DirProp>({
@@ -601,41 +593,12 @@ export const OpenedEntryContextProvider = ({
addToEntryContainer(entryForOpening);
- // save in history
- if (currentLocation) {
- if (Pro) {
- const relEntryPath = getRelativeEntryPath(
- currentLocationPath,
- fsEntry.path,
- );
- const historyKeys = Pro.history.historyKeys;
- if (fsEntry.isFile) {
- Pro.history.saveHistory(
- historyKeys.fileOpenKey,
- {
- path: fsEntry.path,
- url: generateSharingLink(currentLocation.uuid, relEntryPath),
- lid: currentLocation.uuid,
- },
- fileOpenHistory,
- );
- } else {
- Pro.history.saveHistory(
- historyKeys.folderOpenKey,
- {
- path: fsEntry.path,
- url: generateSharingLink(
- currentLocation.uuid,
- relEntryPath,
- relEntryPath,
- ),
- lid: currentLocation.uuid,
- },
- folderOpenHistory,
- );
- }
- }
- }
+ // send action to save in history
+ const action: TS.EditAction = {
+ action: 'open',
+ entry: fsEntry,
+ };
+ setReflectActions(action);
return Promise.resolve(true);
}
@@ -1004,8 +967,6 @@ export const OpenedEntryContextProvider = ({
isEntryInFullWidth.current,
currentLocation,
currentDirectoryPath,
- fileOpenHistory,
- folderOpenHistory,
]);
return (
diff --git a/src/renderer/tagspaces.namespace.d.ts b/src/renderer/tagspaces.namespace.d.ts
index dd6359d98..2ebf43e21 100644
--- a/src/renderer/tagspaces.namespace.d.ts
+++ b/src/renderer/tagspaces.namespace.d.ts
@@ -115,7 +115,7 @@ export namespace TS {
export type ActionSource = 'local' | 'upload' | 'thumbgen' | 'fsWatcher';
interface EditAction {
- action: 'add' | 'delete' | 'update' | 'move';
+ action: 'add' | 'delete' | 'update' | 'move' | 'open' | 'edit';
entry: TS.FileSystemEntry;
oldEntryPath?: string;
open?: boolean;
@@ -239,6 +239,25 @@ export namespace TS {
type ThumbnailMode = 'contain' | 'cover' | 'fill' | 'none' | 'scale-down';
+ type BookmarksContextData = {
+ bookmarks: TS.BookmarkItem[];
+ setBookmark: (filePath: string, url: string) => void;
+ haveBookmark: (filePath: string) => boolean;
+ delAllBookmarks: () => void;
+ delBookmark: (filePath: string) => void;
+ };
+
+ type HistoryContextData = {
+ fileOpenHistory: TS.HistoryItem[];
+ folderOpenHistory: TS.HistoryItem[];
+ fileEditHistory: TS.HistoryItem[];
+ searchHistory: TS.HistoryItem[];
+ saveHistory: (key, historyItem: TS.HistoryItem, limit) => void;
+ delAllHistory: (key) => void;
+ delHistory: (key, creationTimeStamp) => void;
+ openItem: (item: TS.HistoryItem) => void;
+ };
+
interface EditedEntryPath {
action: EditedEntryAction;
path: string;