Skip to content

Commit 28dab75

Browse files
committed
refactor duration
1 parent cdb1781 commit 28dab75

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

web_src/js/modules/toast.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ const levels = {
55
info: {
66
icon: 'octicon-check',
77
background: 'var(--color-green)',
8-
dur: 2000,
8+
duration: 2000,
99
},
1010
error: {
1111
icon: 'gitea-exclamation',
1212
background: 'var(--color-red)',
13-
dur: -1, // needs to be clicked away
13+
duration: -1, // needs to be clicked away
1414
},
1515
};
1616

@@ -19,7 +19,8 @@ async function showToast(message, level, {gravity, position, duration, ...other}
1919
if (!message) return;
2020

2121
const {default: Toastify} = await import(/* webpackChunkName: 'toastify' */'toastify-js');
22-
const {icon, background, dur} = levels[level ?? 'info'];
22+
const {icon, background, duration: levelDuration} = levels[level ?? 'info'];
23+
2324

2425
const toast = Toastify({
2526
text: `
@@ -30,7 +31,7 @@ async function showToast(message, level, {gravity, position, duration, ...other}
3031
escapeMarkup: false,
3132
gravity: gravity ?? 'top',
3233
position: position ?? 'center',
33-
duration: duration ?? dur,
34+
duration: duration ?? levelDuration,
3435
style: {background},
3536
...other,
3637
});

0 commit comments

Comments
 (0)