Skip to content

Commit 310a50e

Browse files
committed
Fix: Fixed duplicate GIF pagination requests.
1 parent a76db47 commit 310a50e

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

gnome-extensions/extension/features/GIF/services/gifFetchService.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const GifFetchService = GObject.registerClass(
3535
this._gifManager = gifManager;
3636
this._currentLoadingSession = null;
3737
this._currentCancellable = null;
38+
this._isLoading = false;
3839

3940
// Pagination and Query State
4041
this._currentNextPos = null;
@@ -62,6 +63,7 @@ export const GifFetchService = GObject.registerClass(
6263
*/
6364
startNewSession() {
6465
this.cancelPendingRequests();
66+
this._isLoading = false;
6567
const sessionId = Symbol('loading-session');
6668
this._currentLoadingSession = sessionId;
6769
return sessionId;
@@ -132,7 +134,7 @@ export const GifFetchService = GObject.registerClass(
132134
* @returns {Promise<void>}
133135
*/
134136
async fetchMore(sessionId = null) {
135-
if (!this._currentNextPos) return;
137+
if (this._isLoading || !this._currentNextPos) return;
136138

137139
if (this._currentQueryType === 'trending') {
138140
await this._performFetch(null, this._currentNextPos, sessionId);
@@ -155,6 +157,7 @@ export const GifFetchService = GObject.registerClass(
155157
async _performFetch(query, nextPos, sessionId) {
156158
if (!this.isSessionValid(sessionId)) return;
157159

160+
this._isLoading = true;
158161
this.emit('loading-state-changed', true, !!nextPos);
159162

160163
try {
@@ -178,6 +181,7 @@ export const GifFetchService = GObject.registerClass(
178181
}
179182
} finally {
180183
if (this.isSessionValid(sessionId)) {
184+
this._isLoading = false;
181185
this.emit('loading-state-changed', false, !!nextPos);
182186
}
183187
}

0 commit comments

Comments
 (0)