fix: Disabled Moments photo capture when app is passcode or biometrics locked (#2114)
This commit is contained in:
@@ -178,6 +178,7 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
|
|||||||
private launched = false
|
private launched = false
|
||||||
/** Whether the application has been destroyed via .deinit() */
|
/** Whether the application has been destroyed via .deinit() */
|
||||||
public dealloced = false
|
public dealloced = false
|
||||||
|
private isBiometricsSoftLockEngaged = false
|
||||||
private revokingSession = false
|
private revokingSession = false
|
||||||
private handledFullSyncStage = false
|
private handledFullSyncStage = false
|
||||||
|
|
||||||
@@ -940,11 +941,12 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
|
|||||||
return this.protocolService.hasPasscode()
|
return this.protocolService.hasPasscode()
|
||||||
}
|
}
|
||||||
|
|
||||||
isLocked(): Promise<boolean> {
|
async isLocked(): Promise<boolean> {
|
||||||
if (!this.started) {
|
if (!this.started) {
|
||||||
return Promise.resolve(true)
|
return Promise.resolve(true)
|
||||||
}
|
}
|
||||||
return this.challengeService.isPasscodeLocked()
|
const isPasscodeLocked = await this.challengeService.isPasscodeLocked()
|
||||||
|
return isPasscodeLocked || this.isBiometricsSoftLockEngaged
|
||||||
}
|
}
|
||||||
|
|
||||||
public async lock(): Promise<void> {
|
public async lock(): Promise<void> {
|
||||||
@@ -964,10 +966,12 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
|
|||||||
|
|
||||||
void this.promptForCustomChallenge(challenge)
|
void this.promptForCustomChallenge(challenge)
|
||||||
|
|
||||||
|
this.isBiometricsSoftLockEngaged = true
|
||||||
void this.notifyEvent(ApplicationEvent.BiometricsSoftLockEngaged)
|
void this.notifyEvent(ApplicationEvent.BiometricsSoftLockEngaged)
|
||||||
|
|
||||||
this.addChallengeObserver(challenge, {
|
this.addChallengeObserver(challenge, {
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
|
this.isBiometricsSoftLockEngaged = false
|
||||||
void this.notifyEvent(ApplicationEvent.BiometricsSoftLockDisengaged)
|
void this.notifyEvent(ApplicationEvent.BiometricsSoftLockDisengaged)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -28,7 +28,13 @@ export class MomentsService extends AbstractViewController {
|
|||||||
if (this.isEnabled) {
|
if (this.isEnabled) {
|
||||||
void this.beginTakingPhotos()
|
void this.beginTakingPhotos()
|
||||||
}
|
}
|
||||||
}, ApplicationEvent.Launched),
|
}, ApplicationEvent.LocalDataLoaded),
|
||||||
|
application.addEventObserver(async () => {
|
||||||
|
this.disableMoments()
|
||||||
|
}, ApplicationEvent.BiometricsSoftLockEngaged),
|
||||||
|
application.addEventObserver(async () => {
|
||||||
|
this.enableMoments()
|
||||||
|
}, ApplicationEvent.BiometricsSoftLockDisengaged),
|
||||||
)
|
)
|
||||||
|
|
||||||
makeObservable(this, {
|
makeObservable(this, {
|
||||||
@@ -80,7 +86,13 @@ export class MomentsService extends AbstractViewController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async takePhoto(): Promise<FileItem | undefined> {
|
public takePhoto = async (): Promise<FileItem | undefined> => {
|
||||||
|
const isAppLocked = await this.application.isLocked()
|
||||||
|
|
||||||
|
if (isAppLocked) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const toastId = addToast({
|
const toastId = addToast({
|
||||||
type: ToastType.Loading,
|
type: ToastType.Loading,
|
||||||
message: 'Capturing Moment...',
|
message: 'Capturing Moment...',
|
||||||
@@ -123,7 +135,10 @@ export class MomentsService extends AbstractViewController {
|
|||||||
const uploadedFile = await this.filesController.uploadNewFile(file)
|
const uploadedFile = await this.filesController.uploadNewFile(file)
|
||||||
|
|
||||||
if (uploadedFile) {
|
if (uploadedFile) {
|
||||||
void this.application.linkingController.linkItemToSelectedItem(uploadedFile)
|
const isAppInForeground = document.visibilityState === 'visible'
|
||||||
|
if (isAppInForeground) {
|
||||||
|
void this.application.linkingController.linkItemToSelectedItem(uploadedFile)
|
||||||
|
}
|
||||||
|
|
||||||
const defaultTag = this.getDefaultTag()
|
const defaultTag = this.getDefaultTag()
|
||||||
if (defaultTag) {
|
if (defaultTag) {
|
||||||
|
|||||||
Reference in New Issue
Block a user