fix: Fixed issue where Moments would capture even after disabling (#2122)
This commit is contained in:
@@ -68,6 +68,10 @@ export class MomentsService extends AbstractViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private beginTakingPhotos() {
|
private beginTakingPhotos() {
|
||||||
|
if (this.intervalReference) {
|
||||||
|
clearInterval(this.intervalReference)
|
||||||
|
}
|
||||||
|
|
||||||
void this.takePhoto()
|
void this.takePhoto()
|
||||||
|
|
||||||
this.intervalReference = setInterval(
|
this.intervalReference = setInterval(
|
||||||
@@ -93,16 +97,24 @@ export class MomentsService extends AbstractViewController {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const toastId = addToast({
|
const isAppInForeground = document.visibilityState === 'visible'
|
||||||
type: ToastType.Regular,
|
|
||||||
message: 'Capturing Moment...',
|
let toastId: string | undefined
|
||||||
pauseOnWindowBlur: false,
|
|
||||||
})
|
if (isAppInForeground) {
|
||||||
|
toastId = addToast({
|
||||||
|
type: ToastType.Regular,
|
||||||
|
message: 'Capturing Moment...',
|
||||||
|
pauseOnWindowBlur: false,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if (this.application.desktopDevice) {
|
if (this.application.desktopDevice) {
|
||||||
const granted = await this.application.desktopDevice.askForMediaAccess('camera')
|
const granted = await this.application.desktopDevice.askForMediaAccess('camera')
|
||||||
if (!granted) {
|
if (!granted) {
|
||||||
dismissToast(toastId)
|
if (toastId) {
|
||||||
|
dismissToast(toastId)
|
||||||
|
}
|
||||||
addToast({
|
addToast({
|
||||||
type: ToastType.Error,
|
type: ToastType.Error,
|
||||||
message: 'Please enable Camera permissions for Standard Notes to enable Moments.',
|
message: 'Please enable Camera permissions for Standard Notes to enable Moments.',
|
||||||
@@ -130,12 +142,13 @@ export class MomentsService extends AbstractViewController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dismissToast(toastId)
|
if (toastId) {
|
||||||
|
dismissToast(toastId)
|
||||||
|
}
|
||||||
|
|
||||||
const uploadedFile = await this.filesController.uploadNewFile(file)
|
const uploadedFile = await this.filesController.uploadNewFile(file)
|
||||||
|
|
||||||
if (uploadedFile) {
|
if (uploadedFile) {
|
||||||
const isAppInForeground = document.visibilityState === 'visible'
|
|
||||||
if (isAppInForeground) {
|
if (isAppInForeground) {
|
||||||
void this.application.linkingController.linkItemToSelectedItem(uploadedFile)
|
void this.application.linkingController.linkItemToSelectedItem(uploadedFile)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user