Fix for auto saving on creating new story

This commit is contained in:
ebolam
2022-09-07 15:44:25 -04:00
parent 776acb0c7d
commit 2040f506ac
2 changed files with 7 additions and 4 deletions

View File

@@ -7172,7 +7172,7 @@ def UI_2_submit(data):
koboldai_vars.lua_koboldbridge.feedback = None koboldai_vars.lua_koboldbridge.feedback = None
koboldai_vars.recentrng = koboldai_vars.recentrngm = None koboldai_vars.recentrng = koboldai_vars.recentrngm = None
if koboldai_vars.actions.action_count == -1: if koboldai_vars.actions.action_count == -1:
actionsubmit(data['data'], actionmode=0) actionsubmit(data['data'], actionmode=koboldai_vars.actionmode)
else: else:
actionsubmit(data['data'], actionmode=koboldai_vars.actionmode) actionsubmit(data['data'], actionmode=koboldai_vars.actionmode)

View File

@@ -85,12 +85,11 @@ class koboldai_vars(object):
#If we can figure out a way to get flask sessions into/through the lua bridge we could re-enable #If we can figure out a way to get flask sessions into/through the lua bridge we could re-enable
story_name = 'default' story_name = 'default'
if story_name in self._story_settings: if story_name in self._story_settings:
self._story_settings[story_name].reset() self._story_settings[story_name].reset()
else: else:
self._story_settings[story_name] = story_settings(self.socketio) self._story_settings[story_name] = story_settings(self.socketio)
if json_data is not None: if json_data is not None:
self._story_settings[story_name].from_json(json_data) self.load_story(sotry_name, json_data)
self._story_settings['default'].send_to_ui() self._story_settings['default'].send_to_ui()
def story_list(self): def story_list(self):
@@ -517,7 +516,6 @@ class story_settings(settings):
self.gamestarted = False # Whether the game has started (disables UI elements) self.gamestarted = False # Whether the game has started (disables UI elements)
self.gamesaved = True # Whether or not current game is saved self.gamesaved = True # Whether or not current game is saved
self.autosave = False # Whether or not to automatically save after each action self.autosave = False # Whether or not to automatically save after each action
self.no_save = False #Temporary disable save (doesn't save with the file)
self.prompt = "" # Prompt self.prompt = "" # Prompt
self.memory = "" # Text submitted to memory field self.memory = "" # Text submitted to memory field
self.authornote = "" # Text submitted to Author's Note field self.authornote = "" # Text submitted to Author's Note field
@@ -568,6 +566,9 @@ class story_settings(settings):
self.context = [] self.context = []
self.last_story_load = None self.last_story_load = None
#must be at bottom
self.no_save = False #Temporary disable save (doesn't save with the file)
def save_story(self): def save_story(self):
if not self.no_save: if not self.no_save:
if self.prompt != "" or self.memory != "" or self.authornote != "" or len(self.actions) > 0 or len(self.worldinfo_v2) > 0: if self.prompt != "" or self.memory != "" or self.authornote != "" or len(self.actions) > 0 or len(self.worldinfo_v2) > 0:
@@ -592,8 +593,10 @@ class story_settings(settings):
self.gamesaved = True self.gamesaved = True
def reset(self): def reset(self):
self.no_save = True
self.socketio.emit("reset_story", {}, broadcast=True, room="UI_2") self.socketio.emit("reset_story", {}, broadcast=True, room="UI_2")
self.__init__(self.socketio, self.koboldai_vars, tokenizer=self.tokenizer) self.__init__(self.socketio, self.koboldai_vars, tokenizer=self.tokenizer)
self.no_save = False
def __setattr__(self, name, value): def __setattr__(self, name, value):
new_variable = name not in self.__dict__ new_variable = name not in self.__dict__