Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Requester): Error 203 #56

Merged
merged 1 commit into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/MainView/MainView.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
&__empty {
position: absolute;
top: 50%;
width: 100%;
left: 0;
right: 0;
text-align: center;
transform: translateY(-50%);
}
Expand Down
7 changes: 6 additions & 1 deletion src/components/MainView/MainView.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<script>
import { onDestroy } from "svelte";
import { pullRequests, refreshDelay, organizations, isFetchingPullRequests, isFetchingProfile, profile, listIsFiltered, isOffline } from '../../shared/store';
import { pullRequests, refreshDelay, organizations, isFetchingPullRequests, pullRequestsFetchHasError, isFetchingProfile, profile, listIsFiltered, isOffline } from '../../shared/store';
import { getPullRequests } from '../../shared/requester';
import Pullrequest from '../Pullrequest';
import ErrorMessage from '../ErrorMessage';
import Loader from '../Loader';
import ListHeader from '../ListHeader';
import Tag from '../Tag';
Expand Down Expand Up @@ -135,6 +136,9 @@
{#each searchablePullRequests as pullRequest}
<Pullrequest pullRequest={pullRequest}/>
{:else}
{#if $pullRequestsFetchHasError}
<ErrorMessage retry={manualRefresh} label={'Impossible de récupérer vos pull requests.'} />
{:else}
<li>
<p class="skz-pullrequests-list__empty">
Il n'y a aucune pull request dans vos projets pour le moment.
Expand All @@ -143,6 +147,7 @@
{/if}
</p>
</li>
{/if}
{/each}
</ul>
{/if}
Expand Down
6 changes: 5 additions & 1 deletion src/shared/requester.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
organizations,
isFetchingPullRequests,
isFetchingProfile,
pullRequestsFetchHasError,
} from './store';
import { ORGANIZATIONS, IMAGES } from './constant';
import { getDiffDays } from './helpers';
Expand Down Expand Up @@ -406,6 +407,7 @@ export const getPullRequests = async ({
isFiltered,
profileId,
}) => {
pullRequestsFetchHasError.set(false);
numberOfLoadedPullRequests = 0;
if (organizations.length) {
const repositoriesToFetch = organizations
Expand Down Expand Up @@ -441,12 +443,14 @@ export const fetchPullRequests = async ({
`https://dev.azure.com/${organizationName}/${projectId}/_apis/git/repositories/${id}/pullRequests?searchCriteria.status=active&includeLinks=true&api-version=5.0`,
);

if (res.ok) {
if (res.ok && res.status === 200) {
const result = await res.json();

loadedPullRequests.push(
result.value.map(value => ({ ...value, organizationName })),
);
} else {
pullRequestsFetchHasError.set(true);
}

numberOfLoadedPullRequests += 1;
Expand Down
7 changes: 4 additions & 3 deletions src/shared/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export const updateRepository = (e, repository) => {

export const repositories = writable([]);
export const isFetchingPullRequests = writable(false);
export const pullRequestsFetchHasError = writable(false);
export const pullRequests = writable([]);

/**
Expand All @@ -93,9 +94,9 @@ export const pullRequests = writable([]);
const getSettingsByKey = (key, initial, type = undefined) => {
let value = getItem(key);

if (typeof value !== 'boolean' && !value && value !== 0) {
value = initial;
addItem(key, value);
if (typeof value !== 'boolean' && !value && value !== 0) {
value = initial;
addItem(key, value);

if (key === 'startup') {
ipcRenderer.send('launch-startup', value);
Expand Down