Skip to content

Commit

Permalink
fix: challege not refresh when it show
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Jul 15, 2020
1 parent 85a915f commit aee50f0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/renderer/hooks/useUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ export function useUserSecurity() {
});
async function check() {
try {
if (data.loading) return;
if (data.challenges.length > 0) return;
data.loading = true;
let sec = await checkLocation();
if (sec) return;
Expand All @@ -335,9 +337,6 @@ export function useUserSecurity() {
data.loading = false;
}
}
onMounted(() => {
check();
});
return {
...toRefs(data),
refreshing,
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/windows/main/pages/UserPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
v-model="isChallengesDialogShown"
width="500"
>
<challenges-form />
<challenges-form :show="isChallengesDialogShown" />
</v-dialog>
<v-dialog
v-model="isUserServicesDialogShown"
Expand Down
18 changes: 14 additions & 4 deletions src/renderer/windows/main/pages/UserPageChallengesForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,26 @@
</template>

<script lang=ts>
import { defineComponent } from '@vue/composition-api';
import { defineComponent, watch, computed } from '@vue/composition-api';
import { useUserSecurity } from '@/hooks';
export default defineComponent({
setup() {
const { submit, challenges, error, security, refreshing, loading } = useUserSecurity();
interface Props {
show: boolean;
}
export default defineComponent<Props>({
props: { show: Boolean },
setup(props) {
const { submit, challenges, error, security, refreshing, loading, check } = useUserSecurity();
function updateAnswer(index: number, content: string) {
challenges.value[index].answer.answer = content;
error.value = undefined;
}
watch(computed(() => props.show), (newValue) => {
if (newValue) {
check();
}
});
return {
loading,
updateAnswer,
Expand Down

0 comments on commit aee50f0

Please sign in to comment.