Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
condenser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
condenser
Compare revisions
df1676455eb43e6dc3b8341f31e8d3e521af87c5 to 6965a6c489010e82d034f5a23c2e872e30c9f34b
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
hive/condenser
Select target project
No results found
6965a6c489010e82d034f5a23c2e872e30c9f34b
Select Git revision
Swap
Target
hive/condenser
Select target project
hive/condenser
1 result
df1676455eb43e6dc3b8341f31e8d3e521af87c5
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
Check objects before using them
· 8f4c3891
Quoc Huy Nguyen Dinh
authored
1 month ago
8f4c3891
Merge branch 'fix-postcountdown' into 'master'
· 6965a6c4
Gandalf
authored
1 month ago
Check objects before using them See merge request
!421
6965a6c4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/components/elements/PostCountDown.jsx
+23
-12
23 additions, 12 deletions
src/app/components/elements/PostCountDown.jsx
with
23 additions
and
12 deletions
src/app/components/elements/PostCountDown.jsx
View file @
6965a6c4
...
...
@@ -3,28 +3,39 @@ import { DateTime } from 'luxon';
import
tt
from
"
counterpart
"
;
import
HumanizeDuration
from
"
humanize-duration
"
;
import
classnames
from
'
classnames
'
;
import
{
Map
}
from
"
immutable
"
;
const
PostCountDown
=
(
props
)
=>
{
const
{
post
}
=
props
;
const
jsonMetadata
=
post
.
get
(
'
json_metadata
'
);
const
countDownEndDate
=
jsonMetadata
.
get
(
'
countdown
'
);
let
jsonMetadata
;
let
countDownEndDate
;
if
(
post
)
{
jsonMetadata
=
post
.
get
(
'
json_metadata
'
);
}
if
(
jsonMetadata
instanceof
Map
)
{
countDownEndDate
=
jsonMetadata
.
get
(
'
countdown
'
);
}
const
[
remainingTime
,
setRemainingTime
]
=
useState
();
const
[
intervalHandler
,
setIntervalHandler
]
=
useState
();
useEffect
(()
=>
{
const
endDate
=
DateTime
.
fromISO
(
countDownEndDate
);
let
interval
=
1000
;
if
(
countDownEndDate
)
{
const
endDate
=
DateTime
.
fromISO
(
countDownEndDate
);
let
interval
=
1000
;
if
(
endDate
.
diff
(
DateTime
.
now
()).
as
(
'
days
'
)
>=
1
)
{
interval
=
24
*
3600
;
}
if
(
endDate
.
diff
(
DateTime
.
now
()).
as
(
'
days
'
)
>=
1
)
{
interval
=
24
*
3600
;
}
const
updateRemainingTime
=
()
=>
{
const
remainingSeconds
=
Math
.
round
(
endDate
.
diff
(
DateTime
.
now
()).
as
(
'
seconds
'
));
setRemainingTime
(
remainingSeconds
);
};
const
updateRemainingTime
=
()
=>
{
const
remainingSeconds
=
Math
.
round
(
endDate
.
diff
(
DateTime
.
now
()).
as
(
'
seconds
'
));
setRemainingTime
(
remainingSeconds
);
};
if
(
countDownEndDate
)
{
updateRemainingTime
();
setIntervalHandler
(
setInterval
(
updateRemainingTime
,
interval
));
}
...
...
This diff is collapsed.
Click to expand it.