From bfe8847d72cd0893230f2e654242658214943e61 Mon Sep 17 00:00:00 2001 From: Markus Hatvan Date: Sat, 2 Oct 2021 09:24:32 +0200 Subject: chore: convert various files from JS to TS (#2010) --- src/features/todos/actions.js | 28 ---------------------------- src/features/todos/actions.ts | 31 +++++++++++++++++++++++++++++++ src/features/todos/constants.js | 8 -------- src/features/todos/constants.ts | 8 ++++++++ src/features/todos/index.js | 28 ---------------------------- src/features/todos/index.ts | 29 +++++++++++++++++++++++++++++ 6 files changed, 68 insertions(+), 64 deletions(-) delete mode 100644 src/features/todos/actions.js create mode 100644 src/features/todos/actions.ts delete mode 100644 src/features/todos/constants.js create mode 100644 src/features/todos/constants.ts delete mode 100644 src/features/todos/index.js create mode 100644 src/features/todos/index.ts (limited to 'src/features/todos') diff --git a/src/features/todos/actions.js b/src/features/todos/actions.js deleted file mode 100644 index cc17e919b..000000000 --- a/src/features/todos/actions.js +++ /dev/null @@ -1,28 +0,0 @@ -import PropTypes from 'prop-types'; -import { createActionsFromDefinitions } from '../../actions/lib/actions'; - -export const todoActions = createActionsFromDefinitions({ - resize: { - width: PropTypes.number.isRequired, - }, - toggleTodosPanel: {}, - toggleTodosFeatureVisibility: {}, - setTodosWebview: { - webview: PropTypes.instanceOf(Element).isRequired, - }, - handleHostMessage: { - action: PropTypes.string.isRequired, - data: PropTypes.object, - }, - handleClientMessage: { - channel: PropTypes.string.isRequired, - message: PropTypes.shape({ - action: PropTypes.string.isRequired, - data: PropTypes.object, - }), - }, - openDevTools: {}, - reload: {}, -}, PropTypes.checkPropTypes); - -export default todoActions; diff --git a/src/features/todos/actions.ts b/src/features/todos/actions.ts new file mode 100644 index 000000000..04e299e71 --- /dev/null +++ b/src/features/todos/actions.ts @@ -0,0 +1,31 @@ +import PropTypes from 'prop-types'; +import { createActionsFromDefinitions } from '../../actions/lib/actions'; + +export const todoActions = createActionsFromDefinitions( + { + resize: { + width: PropTypes.number.isRequired, + }, + toggleTodosPanel: {}, + toggleTodosFeatureVisibility: {}, + setTodosWebview: { + webview: PropTypes.instanceOf(Element).isRequired, + }, + handleHostMessage: { + action: PropTypes.string.isRequired, + data: PropTypes.object, + }, + handleClientMessage: { + channel: PropTypes.string.isRequired, + message: PropTypes.shape({ + action: PropTypes.string.isRequired, + data: PropTypes.object, + }), + }, + openDevTools: {}, + reload: {}, + }, + PropTypes.checkPropTypes, +); + +export default todoActions; diff --git a/src/features/todos/constants.js b/src/features/todos/constants.js deleted file mode 100644 index 303a7a16e..000000000 --- a/src/features/todos/constants.js +++ /dev/null @@ -1,8 +0,0 @@ -export const IPC = { - TODOS_HOST_CHANNEL: 'TODOS_HOST_CHANNEL', - TODOS_CLIENT_CHANNEL: 'TODOS_CLIENT_CHANNEL', -}; - -export const TODOS_ROUTES = { - TARGET: '/todos', -}; diff --git a/src/features/todos/constants.ts b/src/features/todos/constants.ts new file mode 100644 index 000000000..303a7a16e --- /dev/null +++ b/src/features/todos/constants.ts @@ -0,0 +1,8 @@ +export const IPC = { + TODOS_HOST_CHANNEL: 'TODOS_HOST_CHANNEL', + TODOS_CLIENT_CHANNEL: 'TODOS_CLIENT_CHANNEL', +}; + +export const TODOS_ROUTES = { + TARGET: '/todos', +}; diff --git a/src/features/todos/index.js b/src/features/todos/index.js deleted file mode 100644 index 573190881..000000000 --- a/src/features/todos/index.js +++ /dev/null @@ -1,28 +0,0 @@ -import { reaction } from 'mobx'; -import TodoStore from './store'; - -const debug = require('debug')('Ferdi:feature:todos'); - -export const todosStore = new TodoStore(); - -export default function initTodos(stores, actions) { - stores.todos = todosStore; - const { features } = stores; - - // Toggle todos feature - reaction( - () => ( - features.features.isTodosEnabled - ), - (isEnabled) => { - if (isEnabled) { - debug('Initializing `todos` feature'); - todosStore.start(stores, actions); - } else if (todosStore.isFeatureActive) { - debug('Disabling `todos` feature'); - todosStore.stop(); - } - }, - { fireImmediately: true }, - ); -} diff --git a/src/features/todos/index.ts b/src/features/todos/index.ts new file mode 100644 index 000000000..3665812e6 --- /dev/null +++ b/src/features/todos/index.ts @@ -0,0 +1,29 @@ +import { reaction } from 'mobx'; +import TodoStore from './store'; + +const debug = require('debug')('Ferdi:feature:todos'); + +export const todosStore = new TodoStore(); + +export default function initTodos( + stores: { todos?: any; features?: any }, + actions: any, +) { + stores.todos = todosStore; + const { features } = stores; + + // Toggle todos feature + reaction( + () => features.features.isTodosEnabled, + isEnabled => { + if (isEnabled) { + debug('Initializing `todos` feature'); + todosStore.start(stores, actions); + } else if (todosStore.isFeatureActive) { + debug('Disabling `todos` feature'); + todosStore.stop(); + } + }, + { fireImmediately: true }, + ); +} -- cgit v1.2.3-54-g00ecf