mirror of https://github.com/Fabio286/antares.git
refactor: migrate old scratchpad into notes
This commit is contained in:
parent
9a732ea197
commit
532002ca01
|
@ -21,7 +21,7 @@
|
||||||
class="titlebar-element"
|
class="titlebar-element"
|
||||||
@click="openDevTools"
|
@click="openDevTools"
|
||||||
>
|
>
|
||||||
<BaseIcon icon-name="mdiCodeTags" :size="24" />
|
<BaseIcon icon-name="mdiBugPlayOutline" :size="24" />
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="isDevelopment"
|
v-if="isDevelopment"
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import * as Store from 'electron-store';
|
import * as Store from 'electron-store';
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
const persistentStore = new Store({ name: 'notes' });
|
|
||||||
|
|
||||||
export type TagCode = 'all' | 'note' | 'todo' | 'query'
|
export type TagCode = 'all' | 'note' | 'todo' | 'query'
|
||||||
|
|
||||||
|
@ -14,11 +13,29 @@ export interface ConnectionNote {
|
||||||
date: Date;
|
date: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const persistentStore = new Store({ name: 'notes' });
|
||||||
|
|
||||||
|
// Migrate old scratchpad on new notes TODO: remove in future releases
|
||||||
|
const oldNotes = persistentStore.get('notes') as string;
|
||||||
|
if (oldNotes) {
|
||||||
|
const newNotes = persistentStore.get('connectionNotes', []) as ConnectionNote[];
|
||||||
|
newNotes.unshift({
|
||||||
|
uid: 'N:LEGACY',
|
||||||
|
cUid: null,
|
||||||
|
isArchived: false,
|
||||||
|
type: 'note',
|
||||||
|
note: oldNotes,
|
||||||
|
date: new Date()
|
||||||
|
});
|
||||||
|
|
||||||
|
persistentStore.delete('notes');
|
||||||
|
|
||||||
|
persistentStore.set('connectionNotes', newNotes);
|
||||||
|
}
|
||||||
|
|
||||||
export const useScratchpadStore = defineStore('scratchpad', {
|
export const useScratchpadStore = defineStore('scratchpad', {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
selectedTag: 'all',
|
selectedTag: 'all',
|
||||||
/** Global notes */
|
|
||||||
notes: persistentStore.get('notes', '# HOW TO SUPPORT ANTARES\n\n- [ ] Leave a star to Antares [GitHub repo](https://github.com/antares-sql/antares)\n- [ ] Send feedbacks and advices\n- [ ] Report for bugs\n- [ ] If you enjoy, share Antares with friends\n\n# ABOUT SCRATCHPAD\n\nThis is a scratchpad where you can save your **personal notes**. It supports `markdown` format, but you are free to use plain text.\nThis content is just a placeholder, feel free to clear it to make space for your notes.\n') as string,
|
|
||||||
/** Connection specific notes */
|
/** Connection specific notes */
|
||||||
connectionNotes: persistentStore.get('connectionNotes', []) as ConnectionNote[]
|
connectionNotes: persistentStore.get('connectionNotes', []) as ConnectionNote[]
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Reference in New Issue