Skip to content

Commit 6df957e

Browse files
committed
feat: show results of random queries instead of a specific one
1 parent 9d643c3 commit 6df957e

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,7 +2208,25 @@ function RemoteFunctions(config = {}) {
22082208
`;
22092209
},
22102210

2211-
_fetchImages: function(searchQuery = 'sunshine', page = 1, append = false) {
2211+
_getDefaultQuery: function() {
2212+
// this are the default queries, so when image ribbon gallery is shown, we select a random query and show it
2213+
const qualityQueries = [
2214+
'nature', 'minimal', 'workspace', 'abstract', 'coffee',
2215+
'mountains', 'city', 'flowers', 'ocean', 'sunset',
2216+
'architecture', 'forest', 'travel', 'technology', 'sky',
2217+
'landscape', 'creative', 'design', 'art', 'modern',
2218+
'food', 'patterns', 'colors', 'photography', 'studio',
2219+
'light', 'winter', 'summer', 'vintage', 'geometric',
2220+
'water', 'beach', 'space', 'garden', 'textures',
2221+
'urban', 'portrait', 'music', 'books', 'home',
2222+
'cozy', 'aesthetic', 'autumn', 'spring', 'clouds'
2223+
];
2224+
2225+
const randIndex = Math.floor(Math.random() * qualityQueries.length);
2226+
return qualityQueries[randIndex];
2227+
},
2228+
2229+
_fetchImages: function(searchQuery, page = 1, append = false) {
22122230
this._currentSearchQuery = searchQuery;
22132231
const apiUrl = `https://images.phcode.dev/api/images/search?q=${encodeURIComponent(searchQuery)}&per_page=10&page=${page}`;
22142232

@@ -2572,7 +2590,7 @@ function RemoteFunctions(config = {}) {
25722590
this._style();
25732591
window.document.body.appendChild(this.body);
25742592
this._attachEventHandlers();
2575-
this._fetchImages();
2593+
this._fetchImages(this._getDefaultQuery());
25762594
setTimeout(() => this._updateNavButtons(), 0);
25772595
},
25782596

0 commit comments

Comments
 (0)