Skip to content

Commit 3a57396

Browse files
committed
Fix: Remove unnecessary isCallable helper usage.
1 parent 1871b2c commit 3a57396

5 files changed

Lines changed: 18 additions & 37 deletions

File tree

gnome-extensions/extension/features/RecentlyUsed/registry/recentlyUsedRuntimeService.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { isCallable } from '../../../shared/utilities/utilityFunction.js';
21
import { Logger } from '../../../shared/utilities/utilityLogger.js';
32

43
import { ensureRecentlyUsedSectionDefinition } from './recentlyUsedSectionDefinition.js';
@@ -40,7 +39,7 @@ export class RecentlyUsedRuntimeService {
4039
constructor({ extension, settings, onRender }) {
4140
this._extension = extension;
4241
this._settings = settings;
43-
this._onRender = isCallable(onRender) ? onRender : null;
42+
this._onRender = onRender || null;
4443
this._started = false;
4544
this._orderedSections = [];
4645
this._sectionsById = new Map();
@@ -119,10 +118,6 @@ export class RecentlyUsedRuntimeService {
119118
return null;
120119
}
121120

122-
if (!isCallable(sectionDefinition.createInstance)) {
123-
return sectionDefinition;
124-
}
125-
126121
try {
127122
const instance = sectionDefinition.createInstance();
128123
if (!instance || typeof instance !== 'object') {
@@ -404,7 +399,7 @@ export class RecentlyUsedRuntimeService {
404399
*/
405400
_resolveSectionBrowseTitle(sectionConfig) {
406401
const browseTitleResolver = sectionConfig?.titlePolicy?.browseTitle;
407-
if (isCallable(browseTitleResolver)) {
402+
if (browseTitleResolver) {
408403
return browseTitleResolver();
409404
}
410405

@@ -421,7 +416,7 @@ export class RecentlyUsedRuntimeService {
421416
*/
422417
_resolveSectionSearchTitle(sectionConfig, fallbackTitle) {
423418
const searchTitleResolver = sectionConfig?.titlePolicy?.searchTitle;
424-
if (isCallable(searchTitleResolver)) {
419+
if (searchTitleResolver) {
425420
return searchTitleResolver();
426421
}
427422

gnome-extensions/extension/features/RecentlyUsed/registry/recentlyUsedSearchStateManager.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { isCallable } from '../../../shared/utilities/utilityFunction.js';
2-
31
import { matchesRecentlyUsedSearch } from '../utilities/recentlyUsedSearch.js';
42
import { RecentlyUsedSearchTuning } from '../constants/recentlyUsedSearchConstants.js';
53

@@ -16,7 +14,7 @@ export class RecentlyUsedSearchStateManager {
1614
* @param {Function|null} options.onRender Callback to request re-render.
1715
*/
1816
constructor({ onRender = null } = {}) {
19-
this._onRender = isCallable(onRender) ? onRender : null;
17+
this._onRender = onRender || null;
2018
this._searchRequestSeq = 0;
2119
this._sectionSearchState = new Map();
2220
}

gnome-extensions/extension/features/RecentlyUsed/registry/recentlyUsedSignalManager.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { isCallable } from '../../../shared/utilities/utilityFunction.js';
21
import { Logger } from '../../../shared/utilities/utilityLogger.js';
32

43
import { RecentlyUsedPolicySettingKeys } from '../constants/recentlyUsedPolicyConstants.js';
@@ -19,10 +18,10 @@ export class RecentlyUsedSignalManager {
1918
* @param {Function|null} options.onRender Callback to request re-render.
2019
*/
2120
constructor({ getOrderedSections, extension, settings, onRender }) {
22-
this._getOrderedSections = isCallable(getOrderedSections) ? getOrderedSections : () => [];
21+
this._getOrderedSections = getOrderedSections || (() => []);
2322
this._extension = extension;
2423
this._settings = settings;
25-
this._onRender = isCallable(onRender) ? onRender : null;
24+
this._onRender = onRender || null;
2625
this._signalIds = [];
2726
}
2827

@@ -41,7 +40,7 @@ export class RecentlyUsedSignalManager {
4140
const id = descriptor?.id;
4241
const contextSuffix = context ? ` (${context})` : '';
4342

44-
if (!obj || !isCallable(obj.disconnect)) {
43+
if (!obj?.disconnect) {
4544
if (warn) {
4645
Logger.warn(`Ignoring invalid Recently Used signal descriptor${contextSuffix}: missing disconnect-capable object.`);
4746
}
@@ -98,7 +97,7 @@ export class RecentlyUsedSignalManager {
9897
});
9998
}
10099

101-
if (this._settings && isCallable(this._settings.connect)) {
100+
if (this._settings?.connect) {
102101
RecentlyUsedPolicySettingKeys.forEach((settingKey) => {
103102
try {
104103
const signalId = this._settings.connect(`changed::${settingKey}`, () => {
@@ -142,7 +141,7 @@ export class RecentlyUsedSignalManager {
142141
const { obj, id } = normalized;
143142

144143
try {
145-
if (isCallable(obj.signal_handler_is_connected) && !obj.signal_handler_is_connected(id)) {
144+
if (obj.signal_handler_is_connected && !obj.signal_handler_is_connected(id)) {
146145
return;
147146
}
148147
obj.disconnect(id);

gnome-extensions/extension/shared/services/serviceSearchHub.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { isCallable } from '../utilities/utilityFunction.js';
2-
31
const SEARCH_HANDOFF_TTL_MS = 10000;
42

53
let _providersById = null;
@@ -154,7 +152,7 @@ function resolveProvider(providerId) {
154152
* @returns {Function} Unsubscribe function.
155153
*/
156154
export function subscribeSearchHub(listener) {
157-
if (!isCallable(listener)) {
155+
if (!listener) {
158156
return () => {};
159157
}
160158

@@ -187,9 +185,9 @@ export function registerSearchProvider(provider) {
187185
getProvidersById().set(providerId, {
188186
id: providerId,
189187
targetTabs,
190-
search: isCallable(provider?.search) ? provider.search : null,
191-
applyToTab: isCallable(provider?.applyToTab) ? provider.applyToTab : null,
192-
clearOnTab: isCallable(provider?.clearOnTab) ? provider.clearOnTab : null,
188+
search: provider?.search || null,
189+
applyToTab: provider?.applyToTab || null,
190+
clearOnTab: provider?.clearOnTab || null,
193191
});
194192

195193
targetTabs.forEach((tabName) => {
@@ -245,7 +243,7 @@ export async function searchViaProvider(providerId, { query, context } = {}) {
245243
const provider = resolveProvider(providerId);
246244
const normalizedQuery = normalizeQuery(query);
247245

248-
if (!provider || !isCallable(provider.search) || !normalizedQuery) {
246+
if (!provider?.search || !normalizedQuery) {
249247
return [];
250248
}
251249

@@ -321,7 +319,7 @@ export async function applySearchHandoffToTab({ targetTab, tabActor } = {}) {
321319
}
322320

323321
let applied = false;
324-
if (provider && isCallable(provider.applyToTab)) {
322+
if (provider?.applyToTab) {
325323
try {
326324
applied = Boolean(
327325
await provider.applyToTab({
@@ -335,7 +333,7 @@ export async function applySearchHandoffToTab({ targetTab, tabActor } = {}) {
335333
}
336334
}
337335

338-
if (!applied && tabActor && isCallable(tabActor.applyExternalSearch)) {
336+
if (!applied && tabActor?.applyExternalSearch) {
339337
try {
340338
applied = Boolean(await tabActor.applyExternalSearch(handoff.query, handoff));
341339
} catch {
@@ -363,7 +361,7 @@ export async function clearSearchOnTab({ targetTab, tabActor } = {}) {
363361
const resolvedProviderId = resolveProviderIdByTab(targetTab);
364362
const provider = resolveProvider(resolvedProviderId);
365363

366-
if (provider && isCallable(provider.clearOnTab)) {
364+
if (provider?.clearOnTab) {
367365
try {
368366
return Boolean(
369367
await provider.clearOnTab({
@@ -376,7 +374,7 @@ export async function clearSearchOnTab({ targetTab, tabActor } = {}) {
376374
}
377375
}
378376

379-
if (tabActor && isCallable(tabActor.clearExternalSearch)) {
377+
if (tabActor?.clearExternalSearch) {
380378
try {
381379
return Boolean(await tabActor.clearExternalSearch());
382380
} catch {

gnome-extensions/extension/shared/utilities/utilityFunction.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)