fix: link_randomuuid_cache (#718)
* fix: [SPDV-828] use react router link instead of href * fix: auto import issue * fix: replace randomuuid with getRandomValues= * fix: reset FM states if state is invalid * fix: use no-cache for stamp fetch * fix: clear cache and reload message * fix: shallReset flag * fix: identify browser platform and set help url accordingly * fix: edge browser detection * fix: use fallback chrome and verify for safari --------- Co-authored-by: Nandor Komlodi <nandor.komlodi@gmail.com> Co-authored-by: Balint Ujvari <balint.ujvari@solarpunk.buzz>
This commit is contained in:
@@ -5,8 +5,8 @@ import { FileManagerBase, FileManagerEvents } from '@solarpunkltd/file-manager-l
|
||||
import { Context as SettingsContext } from './Settings'
|
||||
import { DriveInfo } from '@solarpunkltd/file-manager-lib'
|
||||
import { getSignerPk } from '../modules/filemanager/utils/common'
|
||||
import { getUsableStamps } from '../../src/modules/filemanager/utils/bee'
|
||||
import { FILE_MANAGER_EVENTS } from '../modules/filemanager/constants/common'
|
||||
import { getUsableStamps } from '../modules/filemanager/utils/bee'
|
||||
|
||||
interface ContextInterface {
|
||||
fm: FileManagerBase | null
|
||||
@@ -256,6 +256,12 @@ export function Provider({ children }: Props) {
|
||||
|
||||
const handleResetState = (isInvalid: boolean) => {
|
||||
setShallReset(isInvalid)
|
||||
setFiles([])
|
||||
setDrives([])
|
||||
setExpiredDrives([])
|
||||
setAdminDrive(null)
|
||||
setCurrentDrive(undefined)
|
||||
setCurrentStamp(undefined)
|
||||
}
|
||||
|
||||
manager.emitter.on(FileManagerEvents.STATE_INVALID, handleResetState)
|
||||
|
||||
@@ -55,6 +55,42 @@ function getOS(): Platforms | null {
|
||||
return null
|
||||
}
|
||||
|
||||
export enum BrowserPlatform {
|
||||
Chrome = 'chrome',
|
||||
Firefox = 'firefox',
|
||||
Safari = 'safari',
|
||||
Brave = 'brave',
|
||||
Edge = 'edge',
|
||||
}
|
||||
|
||||
export async function isBraveBrowser(): Promise<boolean> {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
return (window.navigator.brave && (await window.navigator.brave.isBrave())) === true
|
||||
}
|
||||
|
||||
export async function detectBrowser(): Promise<BrowserPlatform> {
|
||||
const ua = window.navigator.userAgent.toLowerCase()
|
||||
|
||||
if (ua.includes('edge') || ua.includes('edg/')) return BrowserPlatform.Edge
|
||||
|
||||
if (ua.includes('chrome') && (await isBraveBrowser())) return BrowserPlatform.Brave
|
||||
|
||||
if (ua.includes('firefox')) return BrowserPlatform.Firefox
|
||||
|
||||
if (ua.includes('safari') && !ua.includes('chrome')) return BrowserPlatform.Safari
|
||||
|
||||
return BrowserPlatform.Chrome
|
||||
}
|
||||
|
||||
export const cacheClearUrls = {
|
||||
chrome: 'https://support.google.com/accounts/answer/32050?hl=en&co=GENIE.Platform%3DDesktop',
|
||||
brave: 'https://support.brave.app/hc/en-us/articles/360048833872-How-Do-I-Clear-Cookies-And-Site-Data-In-Brave',
|
||||
firefox: 'https://support.mozilla.org/en-US/kb/how-clear-firefox-cache',
|
||||
safari: 'https://support.apple.com/en-il/guide/safari/sfri47acf5d6/mac',
|
||||
edge: 'https://support.microsoft.com/en-us/microsoft-edge/view-and-delete-browser-history-in-microsoft-edge-00cf7943-a9e1-975a-a33d-ac10ce454ca4',
|
||||
}
|
||||
|
||||
export function Provider({ children }: Props): ReactElement {
|
||||
const [platform, setPlatform] = useState<SupportedPlatforms>(SupportedPlatforms.Linux)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user