@@ -31,19 +31,13 @@ export const addArchivedOrDeletedBoardListener = (startAppListening: AppStartLis
31
31
return ;
32
32
}
33
33
34
- let didReset = false ;
35
-
36
- if ( ! queryResult . data . find ( ( board ) => board . board_id === autoAddBoardId ) ) {
37
- dispatch ( autoAddBoardIdChanged ( 'none' ) ) ;
38
- didReset = true ;
39
- }
40
34
if ( ! queryResult . data . find ( ( board ) => board . board_id === selectedBoardId ) ) {
41
35
dispatch ( boardIdSelected ( { boardId : 'none' } ) ) ;
42
- didReset = true ;
43
- }
44
- if ( didReset ) {
45
36
dispatch ( galleryViewChanged ( 'images' ) ) ;
46
37
}
38
+ if ( ! queryResult . data . find ( ( board ) => board . board_id === autoAddBoardId ) ) {
39
+ dispatch ( autoAddBoardIdChanged ( 'none' ) ) ;
40
+ }
47
41
} ,
48
42
} ) ;
49
43
@@ -90,25 +84,17 @@ export const addArchivedOrDeletedBoardListener = (startAppListening: AppStartLis
90
84
return ;
91
85
}
92
86
93
- let didReset = false ;
94
-
95
87
// Handle the case where selected board is archived
96
88
const selectedBoard = queryResult . data . find ( ( b ) => b . board_id === selectedBoardId ) ;
97
89
if ( selectedBoard && selectedBoard . archived ) {
98
90
dispatch ( boardIdSelected ( { boardId : 'none' } ) ) ;
99
- didReset = true ;
91
+ dispatch ( galleryViewChanged ( 'images' ) ) ;
100
92
}
101
93
102
94
// Handle the case where auto-add board is archived
103
95
const autoAddBoard = queryResult . data . find ( ( b ) => b . board_id === autoAddBoardId ) ;
104
96
if ( autoAddBoard && autoAddBoard . archived ) {
105
97
dispatch ( autoAddBoardIdChanged ( 'none' ) ) ;
106
- didReset = true ;
107
- }
108
-
109
- // When resetting the auto-add board or selected board, we should also reset the view to images
110
- if ( didReset ) {
111
- dispatch ( galleryViewChanged ( 'images' ) ) ;
112
98
}
113
99
} ,
114
100
} ) ;
@@ -123,25 +109,15 @@ export const addArchivedOrDeletedBoardListener = (startAppListening: AppStartLis
123
109
const state = getState ( ) ;
124
110
const { selectedBoardId, autoAddBoardId } = state . gallery ;
125
111
126
- let didReset = false ;
127
-
128
112
// Handle the case where selected board isn't in the list of boards
129
- const selectedBoard = boards . find ( ( b ) => b . board_id === selectedBoardId ) ;
130
- if ( selectedBoard && selectedBoard . archived ) {
113
+ if ( ! boards . find ( ( b ) => b . board_id === selectedBoardId ) ) {
131
114
dispatch ( boardIdSelected ( { boardId : 'none' } ) ) ;
132
- didReset = true ;
115
+ dispatch ( galleryViewChanged ( 'images' ) ) ;
133
116
}
134
117
135
118
// Handle the case where auto-add board isn't in the list of boards
136
- const autoAddBoard = boards . find ( ( b ) => b . board_id === autoAddBoardId ) ;
137
- if ( autoAddBoard && autoAddBoard . archived ) {
119
+ if ( ! boards . find ( ( b ) => b . board_id === autoAddBoardId ) ) {
138
120
dispatch ( autoAddBoardIdChanged ( 'none' ) ) ;
139
- didReset = true ;
140
- }
141
-
142
- // When resetting the auto-add board or selected board, we should also reset the view to images
143
- if ( didReset ) {
144
- dispatch ( galleryViewChanged ( 'images' ) ) ;
145
121
}
146
122
} ,
147
123
} ) ;
0 commit comments