Skip to content

Commit 71e7f45

Browse files
committed
refactor collect instead of do, instance var access, overwriting methods
1 parent 61452b1 commit 71e7f45

18 files changed

+57
-138
lines changed

Diff for: src/SpotifyConnect/SPOCApiAlbum.class.st

+4-6
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,12 @@ SPOCApiAlbum >> getAlbumWithID: aString [
5656

5757
{
5858
#category : #response,
59-
#'squeak_changestamp' : 'TL 7/8/2024 20:07'
59+
#'squeak_changestamp' : 'TL 7/11/2024 16:35'
6060
}
6161
SPOCApiAlbum >> tinkerReponseContent: aContentStream [
6262

63-
| content tracks |
63+
| content |
6464
content := Json readFrom: aContentStream readStream.
65-
tracks := OrderedCollection new.
66-
(content at: #items)
67-
do: [:anItem | tracks add: (self tinkerTrack: anItem)].
68-
^ tracks
65+
^ (content at: #items)
66+
collect: [:anItem | self tinkerTrack: anItem]
6967
]

Diff for: src/SpotifyConnect/SPOCApiDevices.class.st

+6-8
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,12 @@ SPOCApiDevices >> getCurrentDevices [
5757

5858
{
5959
#category : #response,
60-
#'squeak_changestamp' : 'TL 7/7/2024 03:06'
60+
#'squeak_changestamp' : 'TL 7/11/2024 15:11'
6161
}
62-
SPOCApiDevices >> tinkerReponseContent: aContentStream [
63-
64-
| content devices |
62+
SPOCApiDevices >> tinkerReponseContent: aContentStream [
63+
64+
| content |
6565
content := Json readFrom: aContentStream readStream.
66-
devices := OrderedCollection new.
67-
(content at: #devices)
68-
do: [:aDevice | devices add: (self tinkerDevice: aDevice)].
69-
^ devices
66+
^ (content at: #devices)
67+
collect: [:aDevice | self tinkerDevice: aDevice]
7068
]

Diff for: src/SpotifyConnect/SPOCApiEndpoint.class.st

+6-8
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,13 @@ SPOCApiEndpoint >> returnsTestContent: aBoolean [
203203

204204
{
205205
#category : #response,
206-
#'squeak_changestamp' : 'RK 7/7/2024 13:10'
206+
#'squeak_changestamp' : 'TL 7/11/2024 15:11'
207207
}
208208
SPOCApiEndpoint >> tinkerAlbum: aJson [
209209

210210
| artists |
211-
artists := OrderedCollection new.
212-
(aJson at: #artists)
213-
do: [:anArtist | artists add: (self tinkerArtist: anArtist)].
211+
artists := (aJson at: #artists)
212+
collect: [:anArtist | self tinkerArtist: anArtist].
214213
^ SPOCAlbum new id: (aJson at: #id);
215214
name: (aJson at: #name);
216215
image: (SPOCImage newWithUrl: (((aJson at: #images) first) at: #url));
@@ -301,14 +300,13 @@ SPOCApiEndpoint >> tinkerRequest [
301300

302301
{
303302
#category : #response,
304-
#'squeak_changestamp' : 'RK 7/7/2024 13:11'
303+
#'squeak_changestamp' : 'TL 7/11/2024 15:12'
305304
}
306305
SPOCApiEndpoint >> tinkerTrack: aJson [
307306

308307
| album artists track |
309-
artists := OrderedCollection new.
310-
(aJson at: #artists)
311-
do: [:anArtist | artists add: (self tinkerArtist: anArtist)].
308+
artists := (aJson at: #artists)
309+
collect: [:anArtist | self tinkerArtist: anArtist].
312310
track := SPOCTrack new id: (aJson at: #id);
313311
name: (aJson at: #name);
314312
artists: artists;

Diff for: src/SpotifyConnect/SPOCApiPlay.class.st

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ SPOCApiPlay >> endpointMethod [
7373

7474
{
7575
#category : #'api-call',
76-
#'squeak_changestamp' : 'TL 7/8/2024 20:18'
76+
#'squeak_changestamp' : 'TL 7/11/2024 16:51'
7777
}
7878
SPOCApiPlay >> executeRequest: request withParams: aParamDictionary [
7979

@@ -85,7 +85,7 @@ SPOCApiPlay >> executeRequest: request withParams: aParamDictionary [
8585
ifFalse: [(aParamDictionary includesKey: #context_uri)
8686
ifTrue: [data := self buildDataWithContext: (aParamDictionary at: #context_uri) andTrack: (aParamDictionary at: #uris)]].
8787
request headerAt: 'Content-Length' put: data size.
88-
(data size = 0)
88+
(data isEmpty)
8989
ifTrue: [^ self client sendRequest: request]
9090
ifFalse: [^ self client sendRequest: request content: data readStream size: data size]
9191

Diff for: src/SpotifyConnect/SPOCApiPlaylist.class.st

+4-6
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,12 @@ SPOCApiPlaylist >> getPlaylistWithID: aString [
5656

5757
{
5858
#category : #response,
59-
#'squeak_changestamp' : 'VE 7/8/2024 18:39'
59+
#'squeak_changestamp' : 'TL 7/11/2024 15:13'
6060
}
6161
SPOCApiPlaylist >> tinkerReponseContent: aContentStream [
6262

63-
| content tracks |
63+
| content |
6464
content := Json readFrom: aContentStream readStream.
65-
tracks := OrderedCollection new.
66-
(content at: #items)
67-
do: [:anItem | tracks add: (self tinkerTrack: (anItem at: #track))].
68-
^ tracks
65+
^ (content at: #items)
66+
collect: [:anItem | self tinkerTrack: (anItem at: #track)]
6967
]

Diff for: src/SpotifyConnect/SPOCApiRecentlyPlayed.class.st

+4-6
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,12 @@ SPOCApiRecentlyPlayed >> getRecentlyPlayed [
5858

5959
{
6060
#category : #response,
61-
#'squeak_changestamp' : 'TL 7/7/2024 03:19'
61+
#'squeak_changestamp' : 'TL 7/11/2024 15:13'
6262
}
6363
SPOCApiRecentlyPlayed >> tinkerReponseContent: aContentStream [
6464

65-
| content tracks |
65+
| content |
6666
content := Json readFrom: aContentStream readStream.
67-
tracks := OrderedCollection new.
68-
(content at: #items)
69-
do: [:anItem | tracks add: (self tinkerTrack: (anItem at: #track))].
70-
^ tracks
67+
^ (content at: #items)
68+
collect: [:anItem | self tinkerTrack: (anItem at: #track)]
7169
]

Diff for: src/SpotifyConnect/SPOCCurrentlyPlaying.class.st

-9
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,6 @@ SPOCCurrentlyPlaying >> needsActiveDevice [
6666
^ true
6767
]
6868

69-
{
70-
#category : #updating,
71-
#'squeak_changestamp' : 'VE 7/2/2024 18:40'
72-
}
73-
SPOCCurrentlyPlaying >> needsLogin [
74-
75-
^ true
76-
]
77-
7869
{
7970
#category : #accessing,
8071
#'squeak_changestamp' : 'RK 6/9/2024 11:47'

Diff for: src/SpotifyConnect/SPOCDataPiece.class.st

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ SPOCDataPiece >> artistsAsString [
3030

3131
{
3232
#category : #testing,
33-
#'squeak_changestamp' : 'TL 7/7/2024 02:27'
33+
#'squeak_changestamp' : 'TL 7/11/2024 16:49'
3434
}
3535
SPOCDataPiece >> artistsEqual: anArtistCollection [
3636

3737
self artists
38-
collect: [:anArtist | ((anArtistCollection at: (self artists indexOf: anArtist)) equals: anArtist)
38+
do: [:anArtist | ((anArtistCollection at: (self artists indexOf: anArtist)) equals: anArtist)
3939
ifFalse: [^ false]].
4040
^ true
4141
]

Diff for: src/SpotifyConnect/SPOCPlayer.class.st

-9
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,6 @@ SPOCPlayer >> needsActiveDevice [
200200
^ true
201201
]
202202

203-
{
204-
#category : #accessing,
205-
#'squeak_changestamp' : 'VE 7/2/2024 18:41'
206-
}
207-
SPOCPlayer >> needsLogin [
208-
209-
^ true
210-
]
211-
212203
{
213204
#category : #accessing,
214205
#'squeak_changestamp' : 'TL 6/3/2024 23:37'

Diff for: src/SpotifyConnect/SPOCRefresh.class.st

-18
Original file line numberDiff line numberDiff line change
@@ -81,24 +81,6 @@ SPOCRefresh >> initialize [
8181
extendFully
8282
]
8383

84-
{
85-
#category : #initialization,
86-
#'squeak_changestamp' : 'VE 7/2/2024 18:44'
87-
}
88-
SPOCRefresh >> needsActiveDevice [
89-
90-
^ false
91-
]
92-
93-
{
94-
#category : #initialization,
95-
#'squeak_changestamp' : 'VE 7/2/2024 18:44'
96-
}
97-
SPOCRefresh >> needsLogin [
98-
99-
^ true
100-
]
101-
10284
{
10385
#category : #initialization,
10486
#'squeak_changestamp' : 'VE 7/9/2024 11:02'

Diff for: src/SpotifyConnect/SPOCResultList.class.st

+12-10
Original file line numberDiff line numberDiff line change
@@ -218,19 +218,21 @@ SPOCResultList >> titleMorph: aSPOCBoldText [
218218

219219
{
220220
#category : #updating,
221-
#'squeak_changestamp' : 'TL 7/8/2024 19:24'
221+
#'squeak_changestamp' : 'TL 7/11/2024 16:46'
222222
}
223223
SPOCResultList >> updateItems [
224224

225-
self items isEmpty ifFalse: [self items removeAll].
226-
self results do: [:aResult |
227-
| item clickable |
228-
item := SPOCResultListItem newWith: aResult.
229-
clickable := SPOCClickable newUsing: item onClick: [:anEvent | self onItemClicked: item].
230-
clickable layoutPolicy: TableLayout new;
231-
hResizing: #spaceFill;
232-
vResizing: #shrinkWrap.
233-
self items add: clickable].
225+
self items isEmpty
226+
ifFalse: [self items removeAll].
227+
self results
228+
do: [:aResult |
229+
| item clickable |
230+
item := SPOCResultListItem newWith: aResult.
231+
clickable := (SPOCClickable newUsing: item onClick: [:anEvent | self onItemClicked: item])
232+
layoutPolicy: TableLayout new;
233+
hResizing: #spaceFill;
234+
vResizing: #shrinkWrap.
235+
self items add: clickable].
234236
self app updatePlaybackState
235237
]
236238

Diff for: src/SpotifyConnect/SPOCScrollablePanel.class.st

+3-3
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ SPOCScrollablePanel >> spec: anObject [
134134

135135
{
136136
#category : #'as yet unclassified',
137-
#'squeak_changestamp' : 'RK 6/9/2024 18:05'
137+
#'squeak_changestamp' : 'TL 7/11/2024 14:28'
138138
}
139139
SPOCScrollablePanel >> updatePanel: anOrderedCollection [
140140

141141
self items: anOrderedCollection.
142-
panel scroller removeAllMorphs.
143-
panel scroller addAllMorphs: items
142+
self panel scroller removeAllMorphs;
143+
addAllMorphs: self items
144144
]

Diff for: src/SpotifyConnect/SPOCSearchbar.class.st

-10
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,6 @@ SPOCSearchbar >> items: anOrderedCollection [
240240
items := anOrderedCollection
241241
]
242242

243-
{
244-
#category : #building,
245-
#'squeak_changestamp' : 'VE 7/2/2024 18:46'
246-
}
247-
SPOCSearchbar >> needsLogin [
248-
249-
^ true
250-
251-
]
252-
253243
{
254244
#category : #actions,
255245
#'squeak_changestamp' : 'VE 7/8/2024 17:41'

Diff for: src/SpotifyConnect/SPOCSwitchDevice.class.st

+5-6
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,12 @@ SPOCSwitchDevice >> switchDeviceClicked: aDevice [
304304

305305
{
306306
#category : #updating,
307-
#'squeak_changestamp' : 'VK 6/10/2024 19:50'
307+
#'squeak_changestamp' : 'TL 7/11/2024 16:47'
308308
}
309309
SPOCSwitchDevice >> updateResultDisplay: anOrderedCollection [
310310

311-
self deviceItems removeAll.
312-
anOrderedCollection do: [:device |
313-
self deviceItems add: (self buildResultMorphFrom: device)].
314-
self resultDisplay updatePanel: self deviceItems.
315-
self resultDisplay show
311+
self deviceItems: (anOrderedCollection
312+
collect: [:aDevice | self buildResultMorphFrom: aDevice]).
313+
self resultDisplay updatePanel: self deviceItems;
314+
show
316315
]

Diff for: src/SpotifyConnect/SPOCTestAuthorizerProcess.class.st

+2-10
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@ Class {
88
#'squeak_changestamp' : 'OW 7/9/2024 10:44'
99
}
1010

11-
{
12-
#category : #testing,
13-
#'squeak_changestamp' : 'VE 7/9/2024 11:34'
14-
}
15-
SPOCTestAuthorizerProcess >> setUp [
16-
17-
]
18-
1911
{
2012
#category : #testing,
2113
#'squeak_changestamp' : 'VE 6/20/2024 19:56'
@@ -61,11 +53,11 @@ SPOCTestAuthorizerProcess >> testCallbackErrors [
6153

6254
{
6355
#category : #testing,
64-
#'squeak_changestamp' : 'VE 7/9/2024 11:35'
56+
#'squeak_changestamp' : 'TL 7/11/2024 16:52'
6557
}
6658
SPOCTestAuthorizerProcess >> testStartAuthorization [
6759

6860
| entryPoints |
6961
entryPoints := WebServer default entryPoints.
70-
self assert: ((entryPoints at: (SPOCAuthorizer redirectRoute)) ~= nil)
62+
self assert: ((entryPoints at: (SPOCAuthorizer redirectRoute)) isNil not)
7163
]

Diff for: src/SpotifyConnect/SPOCTestText.class.st

+6-6
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ SPOCTestText >> testConstructor [
3535

3636
{
3737
#category : #testing,
38-
#'squeak_changestamp' : 'TL 7/11/2024 12:20'
38+
#'squeak_changestamp' : 'TL 7/11/2024 16:52'
3939
}
4040
SPOCTestText >> testMouseEventHandling [
4141

4242
self assert: (self text handlesMouseOver: nil) not.
4343
self assert: (self text handlesMouseMove: nil) not.
4444
self assert: (self text handlesMouseDown: nil) not.
45-
self assert: (self text mouseDown: nil) = nil.
46-
self assert: (self text mouseEnter: nil) = nil.
47-
self assert: (self text mouseLeave: nil) = nil.
48-
self assert: (self text mouseMove: nil) = nil.
49-
self assert: (self text mouseUp: nil) = nil
45+
self assert: (self text mouseDown: nil) isNil.
46+
self assert: (self text mouseEnter: nil) isNil.
47+
self assert: (self text mouseLeave: nil) isNil.
48+
self assert: (self text mouseMove: nil) isNil.
49+
self assert: (self text mouseUp: nil) isNil
5050
]
5151

5252
{

Diff for: src/SpotifyConnect/SPOCUserLogin.class.st

-9
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,6 @@ SPOCUserLogin >> initialize [
7676

7777
]
7878

79-
{
80-
#category : #accessing,
81-
#'squeak_changestamp' : 'VE 7/2/2024 19:12'
82-
}
83-
SPOCUserLogin >> needsActiveDevice [
84-
85-
^ false
86-
]
87-
8879
{
8980
#category : #accessing,
9081
#'squeak_changestamp' : 'VE 7/2/2024 19:12'

Diff for: src/SpotifyConnect/SPOCVolumeSlider.class.st

+1-10
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,6 @@ SPOCVolumeSlider >> needsActiveDevice [
187187
^ true
188188
]
189189

190-
{
191-
#category : #updating,
192-
#'squeak_changestamp' : 'VE 7/2/2024 19:12'
193-
}
194-
SPOCVolumeSlider >> needsLogin [
195-
196-
^ true
197-
]
198-
199190
{
200191
#category : #accessing,
201192
#'squeak_changestamp' : 'TL 6/10/2024 03:19'
@@ -304,7 +295,7 @@ SPOCVolumeSlider >> volume: anObject [
304295

305296
{
306297
#category : #actions,
307-
#'squeak_changestamp' : 'TL 7/8/2024 18:30'
298+
#'squeak_changestamp' : 'TL 7/11/2024 16:57'
308299
}
309300
SPOCVolumeSlider >> volumeClicked: aBlock [
310301

0 commit comments

Comments
 (0)