File tree Expand file tree Collapse file tree 6 files changed +21
-18
lines changed
components/configure-addon Expand file tree Collapse file tree 6 files changed +21
-18
lines changed Original file line number Diff line number Diff 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 [ ] ;
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change @@ -10,9 +10,9 @@ import { OperationInvocation } from '@osf/shared/models/addons/operation-invocat
1010import { AsyncStateModel } from '@osf/shared/models/store/async-state.model' ;
1111
1212export 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
3131export 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 } ,
Original file line number Diff line number Diff line change @@ -16,13 +16,13 @@ import { AddonsState } from './addons.state';
1616
1717export 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
You can’t perform that action at this time.
0 commit comments