Chat export parameter customisation (#7647)
* use export settings and hide fields Signed-off-by: Kerry Archibald <kerrya@element.io> * fix exporter tests Signed-off-by: Kerry Archibald <kerrya@element.io> * test ExportDialog with settings Signed-off-by: Kerry Archibald <kerrya@element.io> * tidy debugs, rename setting to Parameters Signed-off-by: Kerry Archibald <kerrya@element.io> * use reasonable 100gb limit Signed-off-by: Kerry Archibald <kerrya@element.io> * use normal setting instead of UIFeature Signed-off-by: Kerry Archibald <kerrya@element.io> * use a customisation Signed-off-by: Kerry Archibald <kerrya@element.io> * move validateNumberInRange to utils Signed-off-by: Kerry Archibald <kerrya@element.io> * use nullish coalesce Signed-off-by: Kerry Archibald <kerrya@element.io> * use 8gb size limit for customisation Signed-off-by: Kerry Archibald <kerrya@element.io> * update comments Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
@@ -48,7 +48,7 @@ export default abstract class Exporter {
|
||||
protected setProgressText: React.Dispatch<React.SetStateAction<string>>,
|
||||
) {
|
||||
if (exportOptions.maxSize < 1 * 1024 * 1024|| // Less than 1 MB
|
||||
exportOptions.maxSize > 2000 * 1024 * 1024|| // More than ~ 2 GB
|
||||
exportOptions.maxSize > 8000 * 1024 * 1024 || // More than 8 GB
|
||||
exportOptions.numberOfMessages > 10**8
|
||||
) {
|
||||
throw new Error("Invalid export options");
|
||||
|
||||
1
src/utils/validate/index.ts
Normal file
1
src/utils/validate/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./numberInRange";
|
||||
9
src/utils/validate/numberInRange.ts
Normal file
9
src/utils/validate/numberInRange.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
/**
|
||||
* Validates that a value is
|
||||
* - a number
|
||||
* - in a provided range (inclusive)
|
||||
*/
|
||||
export const validateNumberInRange = (min: number, max: number) => (value?: number) => {
|
||||
return typeof value === 'number' && !(isNaN(value) || min > value || value > max);
|
||||
};
|
||||
Reference in New Issue
Block a user