Skip to content

Commit

Permalink
fix: Migrate to new Apps API
Browse files Browse the repository at this point in the history
  • Loading branch information
dubisdev committed Mar 11, 2024
1 parent 75ea87d commit 6f24b10
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
11 changes: 7 additions & 4 deletions extensions/search/src/EngineSearchApp.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ExtensionModule, InfoItem, ScriptItem } from '@rokii/api';
import { App, ExtensionModule, InfoItem, ScriptItem } from '@rokii/api';
import {
google,
duckduckgo,
Expand All @@ -17,9 +17,7 @@ const handlers: Record<Engine, EngineHandler> = {
StartPage: startpage
};

export const EngineSearchAppName = 'EngineSearch';

export const EngineSearchApp: ExtensionModule['run'] = async (ctx) => {
const EngineSearchRun: ExtensionModule['run'] = async (ctx) => {
const { term, display, hide, actions, settings } = ctx;

const engine = settings['Search Engine'] as Engine;
Expand Down Expand Up @@ -47,3 +45,8 @@ export const EngineSearchApp: ExtensionModule['run'] = async (ctx) => {

display(items);
};

export const EngineSearchApp: App = {
id: 'EngineSearch',
run: EngineSearchRun
};
8 changes: 3 additions & 5 deletions extensions/search/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AppItem, ExtensionModule, ScriptItem } from '@rokii/api';
import { Engine } from './types';
import icons from './icons';
import settings from './settings';
import { EngineSearchApp, EngineSearchAppName } from './EngineSearchApp';
import { EngineSearchApp } from './EngineSearchApp';

const run: ExtensionModule['run'] = async ({ term, actions, settings, display }) => {
if (!navigator.onLine) return;
Expand All @@ -21,7 +21,7 @@ const run: ExtensionModule['run'] = async ({ term, actions, settings, display })
const engineIcon = icons[engine];

const engineLauncherItem = new AppItem({
appName: EngineSearchAppName,
appName: EngineSearchApp.id,
title: `Search ${term} with ${engine}`,
keepTerm: true,
icon: engineIcon
Expand All @@ -33,9 +33,7 @@ const run: ExtensionModule['run'] = async ({ term, actions, settings, display })
const SerachExtension: ExtensionModule = {
name: 'Search',
run,
apps: {
[EngineSearchAppName]: EngineSearchApp
},
apps: [EngineSearchApp],
icon: icons.Google,
settings
};
Expand Down

0 comments on commit 6f24b10

Please sign in to comment.