Skip to content

Commit

Permalink
fix: migrate to new API
Browse files Browse the repository at this point in the history
  • Loading branch information
dubisdev committed Mar 11, 2024
1 parent 6d19960 commit 60c6d2e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
9 changes: 6 additions & 3 deletions extensions/todoist/src/apps/TodayTasks.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand All @@ -39,4 +39,7 @@ const TodayTasks: ExtensionModule['run'] = async (ctx) => {
display(items);
};

export default TodayTasks;
export const TodayTasks: App = {
id: 'TodayTasks',
run: TodayTasksRun
};
9 changes: 6 additions & 3 deletions extensions/todoist/src/apps/ViewTasks.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 { TodoistApi, Task } from '@doist/todoist-api-typescript';
import { completeTask, getTaskHour } from '../services/taskServices';
import lang from '../lang';
Expand All @@ -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;
Expand All @@ -32,4 +32,7 @@ const ViewTasks: ExtensionModule['run'] = async (ctx) => {
display(items);
};

export default ViewTasks;
export const ViewTasks: App = {
id: 'ViewTasks',
run: ViewTasksRun
};
18 changes: 5 additions & 13 deletions extensions/todoist/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down Expand Up @@ -52,10 +47,7 @@ const TodoistExtension: ExtensionModule = {
name: 'Todoist',
icon,
run,
apps: {
[APP_NAMES.today]: TodayTasks,
[APP_NAMES.view]: ViewTasks
},
apps: [TodayTasks, ViewTasks],
settings
};

Expand Down

0 comments on commit 60c6d2e

Please sign in to comment.