Skip to content

Commit b602f4d

Browse files
committed
refactor
1 parent 69426d6 commit b602f4d

File tree

22 files changed

+135
-139
lines changed

22 files changed

+135
-139
lines changed

lib/actions/backButton/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { isVersionAtLeast } from '../isVersionAtLeast'
2+
13
export { offClick, onClick } from './events'
24
export { hide, show } from './visible'
3-
import { isVersionAtLeast } from '../isVersionAtLeast'
45

5-
export function isBackButtonSupported(): boolean {
6+
export function isSupported(): boolean {
67
return isVersionAtLeast('6.1')
78
}

lib/actions/backgroundColor/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { updateState } from '../../state'
2+
import { webApp } from '../../webApp'
3+
import { isVersionAtLeast } from '../isVersionAtLeast'
4+
5+
export function isSupported(): boolean {
6+
return isVersionAtLeast('6.1')
7+
}
8+
9+
export function set(color: string) {
10+
webApp.setBackgroundColor(color)
11+
updateState()
12+
}

lib/actions/closingConfirmation.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { updateState } from '../../state'
2+
import { webApp } from '../../webApp'
3+
import { isVersionAtLeast } from '../isVersionAtLeast'
4+
5+
export function isSupported(): boolean {
6+
return isVersionAtLeast('6.2')
7+
}
8+
9+
export function enable() {
10+
webApp.enableClosingConfirmation()
11+
updateState()
12+
}
13+
14+
export function disable() {
15+
webApp.disableClosingConfirmation()
16+
updateState()
17+
}

lib/actions/cloudStorage/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import { isVersionAtLeast } from '../isVersionAtLeast'
2+
13
export { getItem } from './getItem'
24
export { getItems } from './getItems'
35
export { getKeys } from './getKeys'
46
export { removeItem } from './removeItem'
57
export { removeItems } from './removeItems'
68
export { setItem } from './setItem'
7-
import { isVersionAtLeast } from '../isVersionAtLeast'
89

9-
export function isHapticFeedbackSupported(): boolean {
10+
export function isSupported(): boolean {
1011
return isVersionAtLeast('6.9')
1112
}

lib/actions/events.ts

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

lib/actions/events/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Events } from '../../enums'
2+
import { webApp } from '../../webApp'
3+
4+
export function onEvent(eventType: Events, eventHandler: (arg?: any) => void) {
5+
webApp.onEvent(eventType, eventHandler)
6+
}
7+
8+
export function offEvent(eventType: Events, eventHandler: (arg?: any) => void) {
9+
webApp.offEvent(eventType, eventHandler)
10+
}

lib/actions/expand.ts

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

lib/actions/expand/index.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { state } from '../../options'
2+
import { updateState } from '../../state'
3+
import { webApp } from '../../webApp'
4+
5+
let autoExpandHandler: any
6+
7+
export function index() {
8+
webApp.expand()
9+
updateState()
10+
}
11+
12+
export function enableAutoExpand() {
13+
autoExpandHandler = setInterval(() => {
14+
if (!webApp.isExpanded) {
15+
index()
16+
}
17+
}, state.autoExpandInterval)
18+
}
19+
20+
export function disableAutoExpand() {
21+
clearInterval(autoExpandHandler)
22+
}

lib/actions/hapticFeedback/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { isVersionAtLeast } from '../isVersionAtLeast'
2+
13
export { impactOccurred } from './impactOccurred'
24
export { notificationOccurred } from './notificationOccurred'
35
export { selectionChanged } from './selectionChanged'
4-
import { isVersionAtLeast } from '../isVersionAtLeast'
56

6-
export function isHapticFeedbackSupported(): boolean {
7+
export function isSupported(): boolean {
78
return isVersionAtLeast('6.1')
89
}

0 commit comments

Comments
 (0)