From 006ce356220c1a089fc468bbfdc0dea819cd9288 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Tue, 22 Feb 2022 18:48:59 +0100 Subject: persist bot code in localstorage --- web/pw-server/src/lib/bot_code.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 web/pw-server/src/lib/bot_code.ts (limited to 'web/pw-server/src/lib/bot_code.ts') diff --git a/web/pw-server/src/lib/bot_code.ts b/web/pw-server/src/lib/bot_code.ts new file mode 100644 index 0000000..088db72 --- /dev/null +++ b/web/pw-server/src/lib/bot_code.ts @@ -0,0 +1,15 @@ +import defaultBotCode from "../assets/bot_template.txt?raw"; + +const BOT_CODE_KEY = "bot_code"; + +export function getBotCode() { + let botCode = localStorage.getItem(BOT_CODE_KEY); + if (!botCode) { + botCode = defaultBotCode; + } + return botCode; +} + +export function saveBotCode(botCode: string) { + localStorage.setItem(BOT_CODE_KEY, botCode); +} -- cgit v1.2.3