mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 18:46:00 +00:00
add to favorites basic functionality
This commit is contained in:
@@ -46,6 +46,12 @@ const configLoader = () => ({
|
||||
reloadTrigger: 'config-changed',
|
||||
});
|
||||
|
||||
const favoritesLoader = () => ({
|
||||
url: 'files/favorites',
|
||||
params: {},
|
||||
reloadTrigger: 'files-changed-favorites',
|
||||
});
|
||||
|
||||
const markdownManifestLoader = () => ({
|
||||
url: 'files/markdown-manifest',
|
||||
params: {},
|
||||
@@ -282,3 +288,10 @@ export function getMarkdownManifest(args) {
|
||||
export function useMarkdownManifest(args) {
|
||||
return useCore(markdownManifestLoader, args);
|
||||
}
|
||||
|
||||
export function getFavorites(args) {
|
||||
return getCore(favoritesLoader, args);
|
||||
}
|
||||
export function useFavorites(args) {
|
||||
return useCore(favoritesLoader, args);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { changeTab } from './common';
|
||||
import { useSetOpenedTabs } from './globalState';
|
||||
|
||||
export default function useEditorData({ tabid, reloadToken = 0, loadFromArgs = null }) {
|
||||
const localStorageKey = `tabdata_${tabid}`;
|
||||
const localStorageKey = `tabdata_editor_${tabid}`;
|
||||
const setOpenedTabs = useSetOpenedTabs();
|
||||
const changeCounterRef = React.useRef(0);
|
||||
const savedCounterRef = React.useRef(0);
|
||||
|
||||
@@ -46,7 +46,13 @@ export default function useOpenNewTab() {
|
||||
|
||||
const tabid = uuidv1();
|
||||
if (initialData) {
|
||||
await localforage.setItem(`tabdata_${tabid}`, initialData);
|
||||
for (const key of _.keys(initialData)) {
|
||||
if (key == 'editor') {
|
||||
await localforage.setItem(`tabdata_${key}_${tabid}`, initialData[key]);
|
||||
} else {
|
||||
localStorage.setItem(`tabdata_${key}_${tabid}`, JSON.stringify(initialData[key]));
|
||||
}
|
||||
}
|
||||
}
|
||||
setOpenedTabs((files) => [
|
||||
...(files || []).map((x) => ({ ...x, selected: false })),
|
||||
|
||||
Reference in New Issue
Block a user