From 60c6d2e712b690a11398ea6f683b6108e2caf449 Mon Sep 17 00:00:00 2001 From: dubisdev Date: Mon, 11 Mar 2024 19:51:07 +0100 Subject: [PATCH] fix: migrate to new API --- extensions/todoist/src/apps/TodayTasks.ts | 9 ++++++--- extensions/todoist/src/apps/ViewTasks.ts | 9 ++++++--- extensions/todoist/src/index.ts | 18 +++++------------- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/extensions/todoist/src/apps/TodayTasks.ts b/extensions/todoist/src/apps/TodayTasks.ts index 95356e7..aec731d 100644 --- a/extensions/todoist/src/apps/TodayTasks.ts +++ b/extensions/todoist/src/apps/TodayTasks.ts @@ -1,4 +1,4 @@ -import { ExtensionModule, InfoItem, ScriptItem } from '@rokii/api'; +import { ExtensionModule, InfoItem, ScriptItem, App } from '@rokii/api'; import { TodoistApi, Task } from '@doist/todoist-api-typescript'; import { completeTask, getTaskHour } from '../services/taskServices'; import lang from '../lang'; @@ -18,7 +18,7 @@ const taskToItem = (task: Task, api: TodoistApi): ScriptItem => { }); }; -const TodayTasks: ExtensionModule['run'] = async (ctx) => { +const TodayTasksRun: ExtensionModule['run'] = async (ctx) => { const { display, hide, settings, term } = ctx; const { showOverdue, token } = settings; @@ -39,4 +39,7 @@ const TodayTasks: ExtensionModule['run'] = async (ctx) => { display(items); }; -export default TodayTasks; +export const TodayTasks: App = { + id: 'TodayTasks', + run: TodayTasksRun +}; diff --git a/extensions/todoist/src/apps/ViewTasks.ts b/extensions/todoist/src/apps/ViewTasks.ts index f19462c..2cd2a9a 100644 --- a/extensions/todoist/src/apps/ViewTasks.ts +++ b/extensions/todoist/src/apps/ViewTasks.ts @@ -1,4 +1,4 @@ -import { ExtensionModule, InfoItem, ScriptItem } from '@rokii/api'; +import { App, ExtensionModule, InfoItem, ScriptItem } from '@rokii/api'; import { TodoistApi, Task } from '@doist/todoist-api-typescript'; import { completeTask, getTaskHour } from '../services/taskServices'; import lang from '../lang'; @@ -16,7 +16,7 @@ const taskToItem = (task: Task, api: TodoistApi): ScriptItem => { }); }; -const ViewTasks: ExtensionModule['run'] = async (ctx) => { +const ViewTasksRun: ExtensionModule['run'] = async (ctx) => { const { display, hide, settings, term } = ctx; const { token } = settings; @@ -32,4 +32,7 @@ const ViewTasks: ExtensionModule['run'] = async (ctx) => { display(items); }; -export default ViewTasks; +export const ViewTasks: App = { + id: 'ViewTasks', + run: ViewTasksRun +}; diff --git a/extensions/todoist/src/index.ts b/extensions/todoist/src/index.ts index b214f09..968559d 100644 --- a/extensions/todoist/src/index.ts +++ b/extensions/todoist/src/index.ts @@ -2,29 +2,24 @@ import { ExtensionModule, AppItem, ScriptItem, InfoItem } from '@rokii/api'; import { createTask } from './services'; import icon from './icons/icon.png'; import { settings } from './settings'; -import TodayTasks from './apps/TodayTasks'; -import ViewTasks from './apps/ViewTasks'; +import { TodayTasks } from './apps/TodayTasks'; +import { ViewTasks } from './apps/ViewTasks'; import lang from './lang'; if (!Notification.permission) Notification.requestPermission(); -const APP_NAMES = { - today: 'tds_today', - view: 'tds_view' -}; - const todayAppLauncherFabric = (command: string) => new AppItem({ title: lang.workflow_today, icon, keyword: [`tds ${command}`], - appName: APP_NAMES.today + appName: TodayTasks.id }); const viewAppLauncherFabric = (command: string) => new AppItem({ title: lang.workflow_view, icon, keyword: [`tds ${command}`], - appName: APP_NAMES.view + appName: ViewTasks.id }); const noTokenFound = new InfoItem({ title: lang.noTokenFound }); @@ -52,10 +47,7 @@ const TodoistExtension: ExtensionModule = { name: 'Todoist', icon, run, - apps: { - [APP_NAMES.today]: TodayTasks, - [APP_NAMES.view]: ViewTasks - }, + apps: [TodayTasks, ViewTasks], settings };