Skip to content

Commit 2ae62c6

Browse files
committed
client: Typed functions
1 parent 3b23358 commit 2ae62c6

File tree

2 files changed

+69
-35
lines changed

2 files changed

+69
-35
lines changed

client/js/templates/Source.tsx

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ import { LocalizationContext } from '../helpers/i18n';
1717
const FAST_DURATION_MS = 200;
1818

1919
// cancel source editing
20-
function handleCancel({ source, sourceElem, setSources, setEditedSource }) {
20+
function handleCancel(args: {
21+
event?: any;
22+
source: any;
23+
sourceElem: any;
24+
setSources: any;
25+
setEditedSource: any;
26+
}) {
27+
const { source, sourceElem, setSources, setEditedSource } = args;
2128
const id = source.id;
2229

2330
if (id.toString().startsWith('new-')) {
@@ -37,15 +44,24 @@ function handleCancel({ source, sourceElem, setSources, setEditedSource }) {
3744
}
3845

3946
// save source
40-
function handleSave({
41-
event,
42-
setSources,
43-
source,
44-
setEditedSource,
45-
setSourceActionLoading,
46-
setJustSavedTimeout,
47-
setSourceErrors,
47+
function handleSave(args: {
48+
event: any;
49+
setSources: any;
50+
source: any;
51+
setEditedSource: any;
52+
setSourceActionLoading: any;
53+
setJustSavedTimeout: any;
54+
setSourceErrors: any;
4855
}) {
56+
const {
57+
event,
58+
setSources,
59+
source,
60+
setEditedSource,
61+
setSourceActionLoading,
62+
setJustSavedTimeout,
63+
setSourceErrors,
64+
} = args;
4965
event.preventDefault();
5066

5167
// remove old errors
@@ -128,13 +144,15 @@ function handleSave({
128144
}
129145

130146
// delete source
131-
function handleDelete({
132-
source,
133-
sourceElem,
134-
setSources,
135-
setSourceBeingDeleted,
136-
setDirty,
147+
function handleDelete(args: {
148+
source: any;
149+
sourceElem: any;
150+
setSources: any;
151+
setSourceBeingDeleted: any;
152+
setDirty: any;
137153
}) {
154+
const { source, sourceElem, setSources, setSourceBeingDeleted, setDirty } =
155+
args;
138156
const answer = confirm(selfoss.app._('source_warn'));
139157
if (answer == false) {
140158
return;
@@ -177,7 +195,8 @@ function handleDelete({
177195
}
178196

179197
// start editing
180-
function handleEdit({ event, source, setEditedSource }) {
198+
function handleEdit(args: { event: any; source: any; setEditedSource: any }) {
199+
const { event, source, setEditedSource } = args;
181200
event.preventDefault();
182201

183202
const { id, title, tags, filter, spout, params } = source;
@@ -193,13 +212,20 @@ function handleEdit({ event, source, setEditedSource }) {
193212
}
194213

195214
// select new source spout type
196-
function handleSpoutChange({
197-
event,
198-
setSpouts,
199-
updateEditedSource,
200-
setSourceParamsLoading,
201-
setSourceParamsError,
215+
function handleSpoutChange(args: {
216+
event: any;
217+
setSpouts: any;
218+
updateEditedSource: any;
219+
setSourceParamsLoading: any;
220+
setSourceParamsError: any;
202221
}) {
222+
const {
223+
event,
224+
setSpouts,
225+
updateEditedSource,
226+
setSourceParamsLoading,
227+
setSourceParamsError,
228+
} = args;
203229
const spoutClass = event.target.value;
204230
updateEditedSource({ spout: spoutClass });
205231

client/js/templates/SourcesPage.tsx

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ function rand() {
1717
return Math.floor(Math.random() * 2147483647);
1818
}
1919

20-
function handleAddSource({
21-
event = null,
22-
setSources,
23-
setSpouts,
24-
extraInitialData = {},
25-
}) {
20+
function handleAddSource(args: {
21+
setSources: any;
22+
setSpouts: any;
23+
extraInitialData?: any;
24+
event?: any;
25+
}): void {
26+
const { event = null, setSources, setSpouts, extraInitialData = {} } = args;
2627
if (event) {
2728
event.preventDefault();
2829
}
@@ -48,13 +49,20 @@ function handleAddSource({
4849
}
4950

5051
// load sources
51-
function loadSources({
52-
abortController,
53-
location,
54-
setSpouts,
55-
setSources,
56-
setLoadingState,
57-
}) {
52+
function loadSources(args: {
53+
abortController: any;
54+
location: any;
55+
setSpouts: any;
56+
setSources: any;
57+
setLoadingState: any;
58+
}): Promise<void> {
59+
const {
60+
abortController,
61+
location,
62+
setSpouts,
63+
setSources,
64+
setLoadingState,
65+
} = args;
5866
if (abortController.signal.aborted) {
5967
return Promise.resolve();
6068
}

0 commit comments

Comments
 (0)