Skip to content

Commit

Permalink
Rename currentVersion to version in Telestion options
Browse files Browse the repository at this point in the history
  • Loading branch information
fussel178 committed Dec 13, 2023
1 parent 5c6ebfc commit 542df05
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion frontend-react/src/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const defaultUserData: UserData = {
registerWidgets(simpleWidget);

await initTelestion({
currentVersion: '0.0.1',
version: '0.0.1',
defaultBackendUrl: 'ws://localhost:9222',
defaultUserData
});
2 changes: 1 addition & 1 deletion frontend-react/src/lib/application/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export * from './hooks';
export async function initTelestion(options: TelestionOptions) {
// override default current version
if (options.defaultUserData) {
options.defaultUserData.version = options.currentVersion;
options.defaultUserData.version = options.version;
}

if (options.widgets) {
Expand Down
2 changes: 1 addition & 1 deletion frontend-react/src/lib/application/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface TelestionOptions {
/**
* Represents the current version of the software.
*/
currentVersion: string;
version: string;
/**
* The backend URL that should be inserted by default on first page load.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import {
import { isUserDataUpToDate } from '../../../utils.ts';
import { TelestionOptions } from '../../model.ts';

export function dashboardEditorLoader({ currentVersion }: TelestionOptions) {
export function dashboardEditorLoader({ version }: TelestionOptions) {
return ({ params }: LoaderFunctionArgs) => {
if (!isLoggedIn()) {
return redirect('/login');
}

const userData = getUserData();
if (!isUserDataUpToDate(userData, currentVersion) || !userData) {
if (!isUserDataUpToDate(userData, version) || !userData) {
return redirect('/');
}

Expand All @@ -45,14 +45,14 @@ export function dashboardEditorLoader({ currentVersion }: TelestionOptions) {
};
}

export function dashboardEditorAction({ currentVersion }: TelestionOptions) {
export function dashboardEditorAction({ version }: TelestionOptions) {
return async ({ request, params }: ActionFunctionArgs) => {
if (!isLoggedIn()) {
return redirect('/login');
}

const userData = getUserData();
if (!isUserDataUpToDate(userData, currentVersion) || !userData) {
if (!isUserDataUpToDate(userData, version) || !userData) {
return redirect('/');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { getUserData } from '../../../user-data';
import { isUserDataUpToDate } from '../../../utils.ts';
import { TelestionOptions } from '../../model.ts';

export function dashboardIndexLoader({ currentVersion }: TelestionOptions) {
export function dashboardIndexLoader({ version }: TelestionOptions) {
return () => {
if (!isLoggedIn()) {
return redirect('/login');
}

const userData = getUserData();
if (!isUserDataUpToDate(userData, currentVersion) || !userData) {
if (!isUserDataUpToDate(userData, version) || !userData) {
return redirect('/');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import { isUserDataUpToDate } from '../../../utils.ts';

import { dashboardCreateAction } from '../dashboard.ts';

export function dashboardPageLoader({ currentVersion }: TelestionOptions) {
export function dashboardPageLoader({ version }: TelestionOptions) {
return ({ params }: LoaderFunctionArgs) => {
if (!isLoggedIn()) {
return redirect('/login');
}

const userData = getUserData();
if (!isUserDataUpToDate(userData, currentVersion) || !userData) {
if (!isUserDataUpToDate(userData, version) || !userData) {
return redirect('/');
}

Expand All @@ -42,7 +42,7 @@ export function dashboardPageLoader({ currentVersion }: TelestionOptions) {
}

export function dashboardPageAction(options: TelestionOptions) {
const { currentVersion } = options;
const { version } = options;

const createAction = dashboardCreateAction(options);
const deleteAction = ({ params }: ActionFunctionArgs) => {
Expand All @@ -51,7 +51,7 @@ export function dashboardPageAction(options: TelestionOptions) {
}

const oldUserData = getUserData();
if (!isUserDataUpToDate(oldUserData, currentVersion) || !oldUserData) {
if (!isUserDataUpToDate(oldUserData, version) || !oldUserData) {
return redirect('/');
}

Expand Down
4 changes: 2 additions & 2 deletions frontend-react/src/lib/application/routes/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { generatePath, redirect } from 'react-router-dom';
import { getEmptyDashboard, getUserData, setUserData } from '../../user-data';
import { isUserDataUpToDate } from '../../utils.ts';

export function dashboardCreateAction({ currentVersion }: TelestionOptions) {
export function dashboardCreateAction({ version }: TelestionOptions) {
return () => {
if (!isLoggedIn()) {
return redirect('/login');
}

const oldUserData = getUserData();
if (!isUserDataUpToDate(oldUserData, currentVersion) || !oldUserData) {
if (!isUserDataUpToDate(oldUserData, version) || !oldUserData) {
return redirect('/');
}

Expand Down
12 changes: 6 additions & 6 deletions frontend-react/src/lib/application/routes/migration/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { getWidgetById } from '../../../widget';
import { promptActionSchema } from './model.ts';

export function migrationLoader({
currentVersion,
version,
defaultUserData
}: TelestionOptions) {
return () => {
Expand All @@ -24,15 +24,15 @@ export function migrationLoader({
}

const userData = getUserData();
if (isUserDataUpToDate(userData, currentVersion)) {
if (isUserDataUpToDate(userData, version)) {
return redirect('/');
}

return {
migrationState: userData
? {
previousVersion: userData.version,
currentVersion,
version: version,
oldUserData: userData
}
: undefined,
Expand All @@ -43,7 +43,7 @@ export function migrationLoader({

export function migrationAction({
defaultUserData,
currentVersion
version
}: TelestionOptions) {
return async ({ request }: ActionFunctionArgs) => {
if (!isLoggedIn()) {
Expand Down Expand Up @@ -81,7 +81,7 @@ export function migrationAction({
}

case 'blank':
setUserData(getBlankUserData(currentVersion));
setUserData(getBlankUserData(version));
return redirect('/');
case 'existing': {
const oldUserData = getUserData();
Expand All @@ -97,7 +97,7 @@ export function migrationAction({

setUserData({
...oldUserData,
version: currentVersion,
version: version,
widgetInstances: {
...Object.fromEntries(newInstances)
}
Expand Down
4 changes: 2 additions & 2 deletions frontend-react/src/lib/application/routes/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { getUserData } from '../../user-data';
import { isUserDataUpToDate } from '../../utils.ts';
import { TelestionOptions } from '../model.ts';

export function rootLoader({ currentVersion }: TelestionOptions) {
export function rootLoader({ version }: TelestionOptions) {
return () => {
if (!isLoggedIn()) {
return redirect('/login');
}

const userData = getUserData();
if (!isUserDataUpToDate(userData, currentVersion)) {
if (!isUserDataUpToDate(userData, version)) {
return redirect('/migration');
}

Expand Down
2 changes: 1 addition & 1 deletion frontend-react/src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* ```ts
* initTelestion({
* currentVersion: '1.0.0',
* version: '1.0.0',
* ...
* });
* ```
Expand Down

0 comments on commit 542df05

Please sign in to comment.