🚚(frontend) add utils userAgent
In order to stay DRY, we moved the function to know if a user is from a firefox browser from useSaveDoc to utils userAgent.
This commit is contained in:
@@ -4,6 +4,7 @@ import * as Y from 'yjs';
|
|||||||
|
|
||||||
import { useUpdateDoc } from '@/features/docs/doc-management/';
|
import { useUpdateDoc } from '@/features/docs/doc-management/';
|
||||||
import { KEY_LIST_DOC_VERSIONS } from '@/features/docs/doc-versioning';
|
import { KEY_LIST_DOC_VERSIONS } from '@/features/docs/doc-versioning';
|
||||||
|
import { isFirefox } from '@/utils/userAgent';
|
||||||
|
|
||||||
import { toBase64 } from '../utils';
|
import { toBase64 } from '../utils';
|
||||||
|
|
||||||
@@ -87,10 +88,7 @@ const useSaveDoc = (docId: string, doc: Y.Doc, canSave: boolean) => {
|
|||||||
* if he wants to leave the page, by adding the popup, we let the time to the
|
* if he wants to leave the page, by adding the popup, we let the time to the
|
||||||
* request to be sent, and intercepted by the service worker (for the offline part).
|
* request to be sent, and intercepted by the service worker (for the offline part).
|
||||||
*/
|
*/
|
||||||
const isFirefox =
|
if (typeof e !== 'undefined' && e.preventDefault && isFirefox()) {
|
||||||
navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
|
||||||
|
|
||||||
if (typeof e !== 'undefined' && e.preventDefault && isFirefox) {
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
|
export * from './userAgent';
|
||||||
export * from './string';
|
export * from './string';
|
||||||
|
export * from './styleBuilder';
|
||||||
export * from './system';
|
export * from './system';
|
||||||
|
|||||||
2
src/frontend/apps/impress/src/utils/userAgent.ts
Normal file
2
src/frontend/apps/impress/src/utils/userAgent.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export const isFirefox = () =>
|
||||||
|
navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
||||||
Reference in New Issue
Block a user