move the judgement to `handlePermissionPrompt`