From e9a9da4d32b7db0b9be5bfc507611311f83bda85 Mon Sep 17 00:00:00 2001 From: kshitij katiyar <90389917+Kshitij-Katiyar@users.noreply.github.com> Date: Thu, 24 Oct 2024 15:12:04 +0530 Subject: [PATCH] [MM-769]: Convert some JS files to TS and removed unused codes (#1124) --- webapp/src/action_types/{index.js => index.ts} | 0 webapp/src/client/{index.js => index.ts} | 15 ++++++++++++--- webapp/src/reducers/index.js | 13 ------------- webapp/src/selectors/index.ts | 2 -- 4 files changed, 12 insertions(+), 18 deletions(-) rename webapp/src/action_types/{index.js => index.ts} (100%) rename webapp/src/client/{index.js => index.ts} (74%) diff --git a/webapp/src/action_types/index.js b/webapp/src/action_types/index.ts similarity index 100% rename from webapp/src/action_types/index.js rename to webapp/src/action_types/index.ts diff --git a/webapp/src/client/index.js b/webapp/src/client/index.ts similarity index 74% rename from webapp/src/client/index.js rename to webapp/src/client/index.ts index 16b4811f1..e17ce73b4 100644 --- a/webapp/src/client/index.js +++ b/webapp/src/client/index.ts @@ -4,13 +4,22 @@ import {Client4} from 'mattermost-redux/client'; import {ClientError} from 'mattermost-redux/client/client4'; -export const doFetch = async (url, options) => { +interface QueryParameters { + [key: string]: string | number | boolean; +} + +interface FetchOptions { + method: string; + body?: BodyInit | null; +} + +export const doFetch = async (url: string, options: FetchOptions) => { const {data} = await doFetchWithResponse(url, options); return data; }; -export const doFetchWithResponse = async (url, options = {}) => { +export const doFetchWithResponse = async (url: string, options = {}) => { const response = await fetch(url, Client4.getOptions(options)); let data; @@ -32,7 +41,7 @@ export const doFetchWithResponse = async (url, options = {}) => { }); }; -export function buildQueryString(parameters) { +export function buildQueryString(parameters: QueryParameters) { const keys = Object.keys(parameters); if (keys.length === 0) { return ''; diff --git a/webapp/src/reducers/index.js b/webapp/src/reducers/index.js index d68df9726..efed52332 100644 --- a/webapp/src/reducers/index.js +++ b/webapp/src/reducers/index.js @@ -193,18 +193,6 @@ const channelSubscriptions = (state = {}, action) => { } }; -const storedLinkTooltipIssue = (state = {}, action) => { - switch (action.type) { - case ActionTypes.RECEIVED_JIRA_TICKET : { - return { - ticket: action.data, - }; - } - default: - return state; - } -}; - export default combineReducers({ userConnected, userCanConnect, @@ -220,5 +208,4 @@ export default combineReducers({ attachCommentToIssueModalForPostId, channelIdWithSettingsOpen, channelSubscriptions, - storedLinkTooltipIssue, }); diff --git a/webapp/src/selectors/index.ts b/webapp/src/selectors/index.ts index 0694f25cd..0488f67a4 100644 --- a/webapp/src/selectors/index.ts +++ b/webapp/src/selectors/index.ts @@ -73,5 +73,3 @@ export const instanceIsInstalled = (state): boolean => getInstalledInstances(sta export const getDefaultUserInstanceID = (state) => getPluginState(state).defaultUserInstanceID; export const getPluginSettings = (state) => getPluginState(state).pluginSettings; - -export const getStoredLinkTooltipIssue = (state) => getPluginState(state).storedLinkTooltipIssue;