Skip to content

Commit

Permalink
better typing based on MomentInput
Browse files Browse the repository at this point in the history
  • Loading branch information
nytai committed Dec 17, 2020
1 parent 37acf78 commit c139908
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 3 additions & 3 deletions superset-frontend/src/components/LastUpdated/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
* under the License.
*/
import React, { useEffect, useState, FunctionComponent } from 'react';
import moment from 'moment';
import moment, { Moment, MomentInput } from 'moment';
import { t, styled } from '@superset-ui/core';
import Icon from 'src/components/Icon';

const REFRESH_INTERVAL = 60000; // every minute

interface LastUpdatedProps {
updatedAt: string | Date | number;
updatedAt: MomentInput;
update?: React.MouseEventHandler<SVGSVGElement>;
}
moment.updateLocale('en', {
Expand Down Expand Up @@ -56,7 +56,7 @@ export const LastUpdated: FunctionComponent<LastUpdatedProps> = ({
updatedAt,
update,
}) => {
const [timeSince, setTimeSince] = useState<moment.Moment>(moment(updatedAt));
const [timeSince, setTimeSince] = useState<Moment>(moment(updatedAt));

useEffect(() => {
setTimeSince(() => moment(updatedAt));
Expand Down
5 changes: 1 addition & 4 deletions superset-frontend/src/views/CRUD/alert/AlertList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,7 @@ function AlertList({
buttons={subMenuButtons}
>
<RefreshContainer>
<LastUpdated
updatedAt={lastFetched || ''}
update={() => refreshData()}
/>
<LastUpdated updatedAt={lastFetched} update={() => refreshData()} />
</RefreshContainer>
</SubMenu>
<AlertReportModal
Expand Down

0 comments on commit c139908

Please sign in to comment.