Apply exclusion list to profile exports
This commit is contained in:
		
							parent
							
								
									238cc4647c
								
							
						
					
					
						commit
						a69b8c59d4
					
				| 
						 | 
					@ -2,6 +2,7 @@
 | 
				
			||||||
  import { get } from 'svelte/store'
 | 
					  import { get } from 'svelte/store'
 | 
				
			||||||
  import type { Chat } from './Types.svelte'
 | 
					  import type { Chat } from './Types.svelte'
 | 
				
			||||||
  import { chatsStorage } from './Storage.svelte'
 | 
					  import { chatsStorage } from './Storage.svelte'
 | 
				
			||||||
 | 
					    import { getExcludeFromProfile } from './Settings.svelte';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  export const exportAsMarkdown = (chatId: number) => {
 | 
					  export const exportAsMarkdown = (chatId: number) => {
 | 
				
			||||||
    const chats = get(chatsStorage)
 | 
					    const chats = get(chatsStorage)
 | 
				
			||||||
| 
						 | 
					@ -43,12 +44,15 @@
 | 
				
			||||||
  export const exportProfileAsJSON = (chatId: number) => {
 | 
					  export const exportProfileAsJSON = (chatId: number) => {
 | 
				
			||||||
    const chats = get(chatsStorage)
 | 
					    const chats = get(chatsStorage)
 | 
				
			||||||
    const chat = chats.find((chat) => chat.id === chatId) as Chat
 | 
					    const chat = chats.find((chat) => chat.id === chatId) as Chat
 | 
				
			||||||
    const profile = chat.settings
 | 
					    const clone = JSON.parse(JSON.stringify(chat.settings)) // Clone it
 | 
				
			||||||
    const exportContent = JSON.stringify(profile)
 | 
					    Object.keys(getExcludeFromProfile()).forEach(k => {
 | 
				
			||||||
 | 
					      delete clone[k]
 | 
				
			||||||
 | 
					    })
 | 
				
			||||||
 | 
					    const exportContent = JSON.stringify(clone)
 | 
				
			||||||
    const blob = new Blob([exportContent], { type: 'text/json' })
 | 
					    const blob = new Blob([exportContent], { type: 'text/json' })
 | 
				
			||||||
    const url = URL.createObjectURL(blob)
 | 
					    const url = URL.createObjectURL(blob)
 | 
				
			||||||
    const a = document.createElement('a')
 | 
					    const a = document.createElement('a')
 | 
				
			||||||
    a.download = `${profile.profileName}.json`
 | 
					    a.download = `${clone.profileName}.json`
 | 
				
			||||||
    a.href = url
 | 
					    a.href = url
 | 
				
			||||||
    document.body.appendChild(a)
 | 
					    document.body.appendChild(a)
 | 
				
			||||||
    a.click()
 | 
					    a.click()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue