mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
feat: move session to use seconds
This commit is contained in:
1 parent
068c97ecc6
commit
011b5ead9c
2 files changed
+25
-5
No files matched your search
@@ -24,6 +24,26 @@ export function calculateTime(time: number) {
|
||||
}
|
||||
}
|
||||
|
||||
export function timeToSeconds(time: number, unit: string) {
|
||||
switch (unit) {
|
||||
case 'ms':
|
||||
return time / 1000;
|
||||
case 's':
|
||||
return time;
|
||||
case 'm':
|
||||
return time * 60;
|
||||
case 'h':
|
||||
return time * 60 * 60;
|
||||
case 'd':
|
||||
return time * 60 * 60 * 24;
|
||||
case 'M':
|
||||
return time * 60 * 60 * 24 * 30;
|
||||
case 'y':
|
||||
return time * 60 * 60 * 24 * 30 * 12;
|
||||
default:
|
||||
return time;
|
||||
}
|
||||
}
|
||||
export function timeToMinutes(time: number, unit: string) {
|
||||
switch (unit) {
|
||||
case 'ms':
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { trackEvent } from '$lib/actions/analytics';
|
||||
import { timeToMinutes } from '$lib/helpers/timeConversion';
|
||||
import { timeToSeconds } from '$lib/helpers/timeConversion';
|
||||
|
||||
const projectId = $project.$id;
|
||||
let isLimited = $project.authLimit === 0 ? 'unlimited' : 'limited';
|
||||
let newLimit = $project.authLimit === 0 ? 100 : $project.authLimit;
|
||||
let time: number = $project.authDuration;
|
||||
let period = 'm';
|
||||
let time = $project.authDuration;
|
||||
let period = 's';
|
||||
let btnActive = false;
|
||||
|
||||
let options = [
|
||||
@@ -62,7 +62,7 @@
|
||||
}
|
||||
async function updateSessionLength() {
|
||||
try {
|
||||
await sdkForConsole.projects.updateAuthDuration(projectId, timeToMinutes(time, period));
|
||||
await sdkForConsole.projects.updateAuthDuration(projectId, timeToSeconds(time, period));
|
||||
invalidate(Dependencies.PROJECT);
|
||||
|
||||
addNotification({
|
||||
@@ -166,7 +166,7 @@
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button
|
||||
disabled={options !== 'm' || time !== $project.authDuration}
|
||||
disabled={period !== 's' || time !== $project.authDuration}
|
||||
on:click={() => {
|
||||
updateSessionLength();
|
||||
}}>
|
||||
|
||||
Reference in new issue
Block a user