From 8ff9a84af416f9b9e791b74567d91635be5b1e82 Mon Sep 17 00:00:00 2001
From: ivarlovlie <git@ivarlovlie.no>
Date: Sun, 12 Jun 2022 14:26:40 +0200
Subject: refactor: Use store for setting current locale instead of directly
 setting a cookie

This was not doable before because locale.ts was inside of projects and not web-shared
---
 apps/web-shared/src/components/locale-switcher.svelte | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

(limited to 'apps/web-shared/src/components/locale-switcher.svelte')

diff --git a/apps/web-shared/src/components/locale-switcher.svelte b/apps/web-shared/src/components/locale-switcher.svelte
index 2dae026..9cffc7a 100644
--- a/apps/web-shared/src/components/locale-switcher.svelte
+++ b/apps/web-shared/src/components/locale-switcher.svelte
@@ -1,9 +1,8 @@
 <script>
-	import {base_domain, CookieNames} from "$shared/lib/configuration";
-	import {get_cookie, set_cookie} from "$shared/lib/helpers";
-	import {createEventDispatcher, onMount} from "svelte";
-
-	const dispatch = createEventDispatcher();
+	import { CookieNames } from "$shared/lib/configuration";
+	import { get_cookie } from "$shared/lib/helpers";
+	import { currentLocale } from "$shared/lib/locale";
+	import { onMount } from "svelte";
 
 	export let glow = false;
 	export let show = false;
@@ -12,8 +11,7 @@
 
 	function change(to) {
 		selection = to;
-		set_cookie(CookieNames.locale, selection, base_domain());
-		dispatch("change", selection);
+		currentLocale.set(to);
 	}
 
 	onMount(() => {
-- 
cgit v1.3

