mirror of
https://github.com/notherealmarco/WASAPhoto.git
synced 2025-05-05 12:22:35 +02:00
Remove useless try/catch (errors already handled by the interceptor)
This commit is contained in:
parent
f434fcbc72
commit
747a5be567
3 changed files with 98 additions and 83 deletions
|
@ -26,6 +26,7 @@ export default {
|
||||||
|
|
||||||
let response = await this.$axios.get("/stream?start_index=" + this.start_idx + "&limit=" + this.limit);
|
let response = await this.$axios.get("/stream?start_index=" + this.start_idx + "&limit=" + this.limit);
|
||||||
|
|
||||||
|
// Errors are handled by the interceptor, which shows a modal dialog to the user and returns a null response.
|
||||||
if (response == null) {
|
if (response == null) {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.loadingError = true
|
this.loadingError = true
|
||||||
|
|
|
@ -13,11 +13,17 @@ export default {
|
||||||
async login() {
|
async login() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.errormsg = null;
|
this.errormsg = null;
|
||||||
try {
|
|
||||||
let response = await this.$axios.post("/session", {
|
let response = await this.$axios.post("/session", {
|
||||||
name: this.field_username,
|
name: this.field_username,
|
||||||
});
|
});
|
||||||
//this.$router.push({ name: "home" });
|
|
||||||
|
// Errors are handled by the interceptor, which shows a modal dialog to the user and returns a null response.
|
||||||
|
if (response == null) {
|
||||||
|
this.loading = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (response.status == 201 || response.status == 200) {
|
if (response.status == 201 || response.status == 200) {
|
||||||
// Save the token in the local storage if the user wants to be remembered
|
// Save the token in the local storage if the user wants to be remembered
|
||||||
if (this.rememberLogin) {
|
if (this.rememberLogin) {
|
||||||
|
@ -40,10 +46,7 @@ export default {
|
||||||
else {
|
else {
|
||||||
this.errormsg = response.data["error"];
|
this.errormsg = response.data["error"];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
this.errormsg = e.toString();
|
|
||||||
}
|
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -63,13 +66,15 @@ export default {
|
||||||
<form>
|
<form>
|
||||||
<!-- Email input -->
|
<!-- Email input -->
|
||||||
<div class="form-floating mb-4">
|
<div class="form-floating mb-4">
|
||||||
<input v-model="field_username" type="email" id="formUsername" class="form-control" placeholder="name@example.com"/>
|
<input v-model="field_username" type="email" id="formUsername" class="form-control"
|
||||||
|
placeholder="name@example.com" />
|
||||||
<label class="form-label" for="formUsername">Username</label>
|
<label class="form-label" for="formUsername">Username</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Password input -->
|
<!-- Password input -->
|
||||||
<div class="form-floating mb-4">
|
<div class="form-floating mb-4">
|
||||||
<input style="display: none" disabled type="password" id="formPassword" class="form-control" placeholder="gattina12"/>
|
<input style="display: none" disabled type="password" id="formPassword"
|
||||||
|
class="form-control" placeholder="gattina12" />
|
||||||
<label style="display: none" class="form-label" for="formPassword">Password</label>
|
<label style="display: none" class="form-label" for="formPassword">Password</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -78,23 +83,28 @@ export default {
|
||||||
<div class="col d-flex justify-content-center">
|
<div class="col d-flex justify-content-center">
|
||||||
<!-- Checkbox -->
|
<!-- Checkbox -->
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input v-model="rememberLogin" class="form-check-input" type="checkbox" value="" id="form2Example31" />
|
<input v-model="rememberLogin" class="form-check-input" type="checkbox" value=""
|
||||||
|
id="form2Example31" />
|
||||||
<label class="form-check-label" for="form2Example31">Remember me</label>
|
<label class="form-check-label" for="form2Example31">Remember me</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Submit button -->
|
<!-- Submit button -->
|
||||||
<button style="width: 100%" type="button" class="btn btn-primary btn-block mb-4" @click="login">Sign in</button>
|
<button style="width: 100%" type="button" class="btn btn-primary btn-block mb-4"
|
||||||
|
@click="login">Sign in</button>
|
||||||
<ErrorMsg v-if="errormsg" :msg="errormsg"></ErrorMsg>
|
<ErrorMsg v-if="errormsg" :msg="errormsg"></ErrorMsg>
|
||||||
<LoadingSpinner :loading="loading" />
|
<LoadingSpinner :loading="loading" />
|
||||||
<i class="text-center text-secondary d-flex flex-column">repeat after me: "best password is no password"</i>
|
<i class="text-center text-secondary d-flex flex-column">repeat after me: "best password is
|
||||||
|
no password"</i>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div></div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -28,14 +28,19 @@ export default {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
let response = await this.$axios.get("/users?query=" + this.fieldUsername + "&start_index=" + this.startIdx + "&limit=" + this.limit);
|
let response = await this.$axios.get("/users?query=" + this.fieldUsername + "&start_index=" + this.startIdx + "&limit=" + this.limit);
|
||||||
|
|
||||||
|
// Errors are handled by the interceptor, which shows a modal dialog to the user and returns a null response.
|
||||||
|
if (response == null) {
|
||||||
|
this.loading = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (response.data.length == 0) this.dataEnded = true;
|
if (response.data.length == 0) this.dataEnded = true;
|
||||||
else this.streamData = this.streamData.concat(response.data);
|
else this.streamData = this.streamData.concat(response.data);
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
} catch (e) {
|
|
||||||
this.errormsg = e.toString(); // todo: handle better
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
scroll() {
|
scroll() {
|
||||||
window.onscroll = () => {
|
window.onscroll = () => {
|
||||||
|
@ -68,15 +73,13 @@ export default {
|
||||||
<ErrorMsg v-if="errormsg" :msg="errormsg"></ErrorMsg>
|
<ErrorMsg v-if="errormsg" :msg="errormsg"></ErrorMsg>
|
||||||
|
|
||||||
<div class="form-floating mb-4">
|
<div class="form-floating mb-4">
|
||||||
<input v-model="fieldUsername" @input="refresh" id="formUsername" class="form-control" placeholder="name@example.com"/>
|
<input v-model="fieldUsername" @input="refresh" id="formUsername" class="form-control"
|
||||||
|
placeholder="name@example.com" />
|
||||||
<label class="form-label" for="formUsername">Search by username</label>
|
<label class="form-label" for="formUsername">Search by username</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="main-content" v-for="item of streamData">
|
<div id="main-content" v-for="item of streamData">
|
||||||
<UserCard
|
<UserCard :user_id="item.user_id" :name="item.name" :followed="item.followed"
|
||||||
:user_id="item.user_id"
|
|
||||||
:name="item.name"
|
|
||||||
:followed="item.followed"
|
|
||||||
:banned="item.banned" />
|
:banned="item.banned" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -89,4 +92,5 @@ export default {
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue