Skip to content

Commit 1dbfba8

Browse files
committed
fix(addons): fixed endless loading
1 parent 3fdcc68 commit 1dbfba8

File tree

6 files changed

+21
-18
lines changed

6 files changed

+21
-18
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/features/project/project-addons/components/configure-addon/configure-addon.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ export class ConfigureAddonComponent implements OnInit {
116116
});
117117

118118
readonly supportedResourceTypes = computed(() => {
119-
if (this.linkAddons().length && this.addonTypeString() === AddonType.LINK) {
120-
const addon = this.linkAddons().find((a) => this.addon()?.externalServiceName === a.externalServiceName);
119+
const linkAddons = this.linkAddons();
120+
if (linkAddons?.length && this.addonTypeString() === AddonType.LINK) {
121+
const addon = linkAddons.find((a) => this.addon()?.externalServiceName === a.externalServiceName);
121122
return addon?.supportedResourceTypes || [];
122123
}
123124
return [];

src/app/features/project/project-addons/project-addons.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,9 @@ export class ProjectAddonsComponent implements OnInit {
242242
filteredAddonCards = computed((): AddonCardModel[] => {
243243
const searchValue = this.searchValue().toLowerCase();
244244
const configuredAddons = this.allConfiguredAddonsForCheck();
245+
const addons = this.currentAddonsState() ?? [];
245246

246-
const addonCards = this.currentAddonsState()
247+
const addonCards = addons
247248
.filter(
248249
(card) =>
249250
card.externalServiceName.toLowerCase().includes(searchValue) ||
@@ -300,7 +301,7 @@ export class ProjectAddonsComponent implements OnInit {
300301
const addons = this.currentAddonsState();
301302
const isLoading = this.currentAddonsLoading();
302303

303-
if (!addons?.length && !isLoading) {
304+
if (!addons && !isLoading) {
304305
action();
305306
}
306307
}

src/app/features/settings/settings-addons/settings-addons.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ export class SettingsAddonsComponent implements OnInit {
213213

214214
readonly filteredAddonCards = computed(() => {
215215
const searchValue = this.searchValue().toLowerCase();
216-
const filteredAddons = this.currentAddonsState().filter(
216+
const addons = this.currentAddonsState() ?? [];
217+
const filteredAddons = addons.filter(
217218
(card) =>
218219
card.externalServiceName.toLowerCase().includes(searchValue) ||
219220
card.displayName.toLowerCase().includes(searchValue)
@@ -259,7 +260,7 @@ export class SettingsAddonsComponent implements OnInit {
259260
const action = this.currentAction();
260261
const addons = this.currentAddonsState();
261262

262-
if (!addons?.length) {
263+
if (!addons) {
263264
action();
264265
}
265266
}

src/app/shared/stores/addons/addons.models.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import { OperationInvocation } from '@osf/shared/models/addons/operation-invocat
1010
import { AsyncStateModel } from '@osf/shared/models/store/async-state.model';
1111

1212
export interface AddonsStateModel {
13-
storageAddons: AsyncStateModel<AddonModel[]>;
14-
citationAddons: AsyncStateModel<AddonModel[]>;
15-
linkAddons: AsyncStateModel<AddonModel[]>;
13+
storageAddons: AsyncStateModel<AddonModel[] | null>;
14+
citationAddons: AsyncStateModel<AddonModel[] | null>;
15+
linkAddons: AsyncStateModel<AddonModel[] | null>;
1616
authorizedStorageAddons: AsyncStateModel<AuthorizedAccountModel[]>;
1717
authorizedCitationAddons: AsyncStateModel<AuthorizedAccountModel[]>;
1818
authorizedLinkAddons: AsyncStateModel<AuthorizedAccountModel[]>;
@@ -30,17 +30,17 @@ export interface AddonsStateModel {
3030

3131
export const ADDONS_DEFAULTS: AddonsStateModel = {
3232
storageAddons: {
33-
data: [],
33+
data: null,
3434
isLoading: false,
3535
error: null,
3636
},
3737
citationAddons: {
38-
data: [],
38+
data: null,
3939
isLoading: false,
4040
error: null,
4141
},
4242
linkAddons: {
43-
data: [],
43+
data: null,
4444
isLoading: false,
4545
error: null,
4646
},

src/app/shared/stores/addons/addons.selectors.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ import { AddonsState } from './addons.state';
1616

1717
export class AddonsSelectors {
1818
@Selector([AddonsState])
19-
static getStorageAddons(state: AddonsStateModel): AddonModel[] {
19+
static getStorageAddons(state: AddonsStateModel): AddonModel[] | null {
2020
return state.storageAddons.data;
2121
}
2222

2323
static getStorageAddon(id: string): (state: AddonsStateModel) => AddonModel | null {
2424
return createSelector([AddonsState], (state: AddonsStateModel): AddonModel | null => {
25-
return state.storageAddons.data.find((addon: AddonModel) => addon.id === id) || null;
25+
return state.storageAddons.data?.find((addon: AddonModel) => addon.id === id) || null;
2626
});
2727
}
2828

@@ -32,7 +32,7 @@ export class AddonsSelectors {
3232
}
3333

3434
@Selector([AddonsState])
35-
static getCitationAddons(state: AddonsStateModel): AddonModel[] {
35+
static getCitationAddons(state: AddonsStateModel): AddonModel[] | null {
3636
return state.citationAddons.data;
3737
}
3838

@@ -42,7 +42,7 @@ export class AddonsSelectors {
4242
}
4343

4444
@Selector([AddonsState])
45-
static getLinkAddons(state: AddonsStateModel): AddonModel[] {
45+
static getLinkAddons(state: AddonsStateModel): AddonModel[] | null {
4646
return state.linkAddons.data;
4747
}
4848

0 commit comments

Comments
 (0)