throttling saveConfigs
This commit is contained in:
parent
3cef51144f
commit
0ab248c478
@ -2,6 +2,7 @@ import {
|
|||||||
AddToDownloadList,
|
AddToDownloadList,
|
||||||
DeleteFile,
|
DeleteFile,
|
||||||
DepCheck,
|
DepCheck,
|
||||||
|
GetProxyPort,
|
||||||
InstallPyDep,
|
InstallPyDep,
|
||||||
ListDirFiles,
|
ListDirFiles,
|
||||||
OpenOpenFileDialog,
|
OpenOpenFileDialog,
|
||||||
@ -28,7 +29,7 @@ import logo from '../assets/images/logo.png';
|
|||||||
import { Preset } from '../types/presets';
|
import { Preset } from '../types/presets';
|
||||||
import { botName, Conversation, MessageType, Role, systemName, userName } from '../types/chat';
|
import { botName, Conversation, MessageType, Role, systemName, userName } from '../types/chat';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
import { findLastIndex } from 'lodash-es';
|
import { findLastIndex, throttle } from 'lodash-es';
|
||||||
|
|
||||||
export type Cache = {
|
export type Cache = {
|
||||||
version: string
|
version: string
|
||||||
@ -223,7 +224,7 @@ export const getStrategy = (modelConfig: ModelConfig | undefined = undefined) =>
|
|||||||
return strategy;
|
return strategy;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const saveConfigs = async () => {
|
export const saveConfigs = throttle(async () => {
|
||||||
const data: LocalConfig = {
|
const data: LocalConfig = {
|
||||||
modelSourceManifestList: commonStore.modelSourceManifestList,
|
modelSourceManifestList: commonStore.modelSourceManifestList,
|
||||||
currentModelConfigIndex: commonStore.currentModelConfigIndex,
|
currentModelConfigIndex: commonStore.currentModelConfigIndex,
|
||||||
@ -233,7 +234,11 @@ export const saveConfigs = async () => {
|
|||||||
loraFinetuneParams: commonStore.loraFinetuneParams
|
loraFinetuneParams: commonStore.loraFinetuneParams
|
||||||
};
|
};
|
||||||
return SaveJson('config.json', data);
|
return SaveJson('config.json', data);
|
||||||
};
|
}, 500,
|
||||||
|
{
|
||||||
|
leading: true,
|
||||||
|
trailing: true
|
||||||
|
});
|
||||||
|
|
||||||
export const saveCache = async () => {
|
export const saveCache = async () => {
|
||||||
const data: Cache = {
|
const data: Cache = {
|
||||||
|
Loading…
Reference in New Issue
Block a user