Skip to content

Commit

Permalink
refactor: rename.
Browse files Browse the repository at this point in the history
  • Loading branch information
ujiro99 committed Jun 19, 2023
1 parent 11878e4 commit 9fe9382
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/components/LineEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useTaskManager } from '@/hooks/useTaskManager'
import { useEditFinish } from '@/hooks/useEditable'
import { useAnalytics } from '@/hooks/useAnalytics'
import { eventStop } from '@/services/util'
import { DEFAULT, KEYCODE_ENTER } from '@/const'
import { TASK_DEFAULT, KEYCODE_ENTER } from '@/const'

import './LineEditor.css'

Expand All @@ -22,7 +22,7 @@ export function LineEditor(props: Props): JSX.Element {
const finishEdit = useEditFinish()

function finish() {
if (text !== DEFAULT) {
if (text !== TASK_DEFAULT) {
manager.setTextByLine(line, text)
} else {
manager.removeLine(line)
Expand All @@ -38,7 +38,7 @@ export function LineEditor(props: Props): JSX.Element {
function onFocus() {
let current = manager.getTextByLine(line)
if (!current) {
current = DEFAULT
current = TASK_DEFAULT
}
analytics.track('edit line start')
setText(current)
Expand Down
2 changes: 1 addition & 1 deletion src/const.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const DEFAULT = '- [ ] '
export const TASK_DEFAULT = '- [ ] '
export const INDENT_SIZE = 2
export const KEY = {
TAB: 'Tab',
Expand Down
6 changes: 3 additions & 3 deletions src/models/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Log from '@/services/log'
import { rand, depthToIndent } from '@/services/util'
import { flat } from './flattenedNode'
import { IClonable } from '@/@types/global'
import { DEFAULT } from '@/const'
import { TASK_DEFAULT } from '@/const'

/**
* Represent types of the Node.
Expand Down Expand Up @@ -140,7 +140,7 @@ export class Node implements TreeItem, INode, IClonable<INode> {
const [cloned] = clone([this])
const found = cloned.find((n) => n.line === line)
if (found) {
const empty = new Node(NODE_TYPE.TASK, 0, Task.parse(DEFAULT))
const empty = new Node(NODE_TYPE.TASK, 0, Task.parse(TASK_DEFAULT))
if (found.type === NODE_TYPE.HEADING) {
empty.parent = found
found.children.unshift(empty)
Expand All @@ -158,7 +158,7 @@ export class Node implements TreeItem, INode, IClonable<INode> {
let cloned: Node
const parent = this.find(predicate)
if (parent) {
const empty = new Node(NODE_TYPE.TASK, 0, Task.parse(DEFAULT))
const empty = new Node(NODE_TYPE.TASK, 0, Task.parse(TASK_DEFAULT))
const newParent = parent.append(empty)
cloned = this.replace(newParent, (n) => n.id === parent.id, false)
}
Expand Down
4 changes: 2 additions & 2 deletions src/services/google/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { differenceInMinutes } from 'date-fns'
import { Time } from '@/models/time'
import { fetchWrapper, FetchMethod } from './util'
import Log from '@/services/log'
import { DEFAULT, API_KEY } from '@/const'
import { TASK_DEFAULT, API_KEY } from '@/const'

export type Calendar = {
id: string
Expand Down Expand Up @@ -106,7 +106,7 @@ async function fetchEvents(calendar: Calendar): Promise<CalendarEvent[]> {
e.end = item.end.dateTime
const d = differenceInMinutes(new Date(e.end), new Date(e.start))
e.time = new Time(0, d % 60, Math.floor(d / 60))
e.md = `${DEFAULT}${e.title} ~/${e.time.toString()}`
e.md = `${TASK_DEFAULT}${e.title} ~/${e.time.toString()}`
e.htmlLink = item.htmlLink
e.status = item.status

Expand Down
4 changes: 2 additions & 2 deletions src/services/google/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CalendarEvent } from './calendar'
import { Storage, STORAGE_KEY } from '@/services/storage'
import { Task } from '@/models/task'
import { Node, NODE_TYPE } from '@/models/node'
import { DEFAULT } from '@/const'
import { TASK_DEFAULT } from '@/const'
import Log from '@/services/log'

function getOptions(token: string) {
Expand Down Expand Up @@ -89,6 +89,6 @@ export function eventToNode(event: CalendarEvent): Node {
}

export function equalsEventAndTask(event: CalendarEvent, task: Task): boolean {
const taskMd = `${DEFAULT}${task.title} ~/${task.estimatedTimes.toString()}`
const taskMd = `${TASK_DEFAULT}${task.title} ~/${task.estimatedTimes.toString()}`
return event.md === taskMd
}

0 comments on commit 9fe9382

Please sign in to comment.