Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/common/localStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export const StorageKeys = {
TIME_FORMAT: "timeFormat",
DASHBOARD_POST_SORT: "dashboardPostSort",
rightDrawerMode: "rightDrawerMode",
FAVORITE_GIFS: "favoriteGifs"
FAVORITE_GIFS: "favoriteGifs",
USE_LATEST_URL: "useLatestURL" // check for mobile and desktop app on wether to use the latest.nerimity.com url or not
} as const;

export type StorageKeys = (typeof StorageKeys)[keyof typeof StorageKeys];
Expand Down
31 changes: 30 additions & 1 deletion src/components/settings/developer/DeveloperSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createEffect } from "solid-js";
import { createEffect, createSignal } from "solid-js";
import { styled } from "solid-styled-components";

import useStore from "@/chat-api/store/useStore";
Expand All @@ -18,6 +18,21 @@ const Container = styled("div")`
export default function DeveloperSettings() {
const { header } = useStore();

const getInitialCookieValue = () => {
const match = document.cookie.split('; ').find(row => row.startsWith('useLatestURL='));
return match ? match.split('=')[1] === 'true' : false;
};

const [useLatest, setUseLatest] = createSignal(getInitialCookieValue());

const handleToggleCookie = (e: Event) => {
const checked = (e.target as HTMLInputElement).checked;
setUseLatest(checked);

const domain = window.location.hostname.includes("nerimity.com") ? "domain=.nerimity.com;" : "";
document.cookie = `useLatestURL=${checked}; path=/; max-age=315360000; ${domain}`;
};

createEffect(() => {
header.updateHeader({
title: t("settings.drawer.title") + " - " + t("settings.drawer.developer"),
Expand All @@ -32,6 +47,20 @@ export default function DeveloperSettings() {
<BreadcrumbItem title={t("settings.drawer.developer")} />
</Breadcrumb>

<SettingsBlock
icon="update"
label={t("settings.developer.useLatestUrl")}
description={t("settings.developer.useLatestUrlDescription")}
children={
<input
type="checkbox"
checked={useLatest()}
onChange={handleToggleCookie}
style={{ cursor: "pointer", width: "20px", height: "20px", margin: "0 8px" }}
/>
}
/>

<SettingsBlock
href="./applications"
icon="extension"
Expand Down
2 changes: 2 additions & 0 deletions src/locales/list/en-gb.json
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,8 @@
"lastfmApiKeyPlaceholder": "Last.fm API Key"
},
"developer": {
"useLatestUrl": "Use Latest URL",
"useLatestUrlDescription": "Load latest.nerimity.com on next app restart. Will relaunch app",
"applicationsDescription": "Create Nerimity Bots.",
"apiDocumentation": "API Documentation (incomplete)",
"addButton": "Add App",
Expand Down