Skip to content

Commit

Permalink
implement CloudStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
kolirt committed Jul 24, 2024
1 parent a007b94 commit 3ed4ae6
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 4 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,25 @@ app.mount('#app')
- [X] headerColor
- [X] backgroundColor
- [X] isClosingConfirmationEnabled
- [X] BackButton
- [ ] BackButton
- [ ] isVisible
- [X] BackButton.onClick
- [X] BackButton.offClick
- [X] BackButton.show
- [X] BackButton.hide
- [ ] MainButton
- [ ] SettingsButton
- [X] HapticFeedback
- [ ] CloudStorage
- [X] HapticFeedback.impactOccurred
- [X] HapticFeedback.notificationOccurred
- [X] HapticFeedback.selectionChanged
- [X] CloudStorage
- [X] CloudStorage.setItem
- [X] CloudStorage.getItem
- [X] CloudStorage.getItems
- [X] CloudStorage.removeItem
- [X] CloudStorage.removeItems
- [X] CloudStorage.getKeys
- [ ] BiometricManager
- [ ] isVersionAtLeast
- [X] setHeaderColor(color)
Expand Down
13 changes: 13 additions & 0 deletions lib/actions/cloudStorage/getItem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { webApp } from '../../webApp'

export function getItem(key: string) {
return new Promise<string>((resolve, reject) => {
webApp.CloudStorage.getItem(key, function (error: any, value: string) {
if (error) {
reject(error)
}

resolve(value)
})
})
}
13 changes: 13 additions & 0 deletions lib/actions/cloudStorage/getItems.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { webApp } from '../../webApp'

export function getItems<T extends string[] = string[]>(keys: T) {
return new Promise<T>((resolve, reject) => {
webApp.CloudStorage.getItems(keys, function (error: any, value: T) {
if (error) {
reject(error)
}

resolve(value)
})
})
}
13 changes: 13 additions & 0 deletions lib/actions/cloudStorage/getKeys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { webApp } from '../../webApp'

export function getKeys() {
return new Promise<string[]>((resolve, reject) => {
webApp.CloudStorage.getKeys(function (error: any, value: string[]) {
if (error) {
reject(error)
}

resolve(value)
})
})
}
6 changes: 6 additions & 0 deletions lib/actions/cloudStorage/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export { getItem } from './getItem'
export { getItems } from './getItems'
export { getKeys } from './getKeys'
export { removeItem } from './removeItem'
export { removeItems } from './removeItems'
export { setItem } from './setItem'
13 changes: 13 additions & 0 deletions lib/actions/cloudStorage/removeItem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { webApp } from '../../webApp'

export function removeItem(key: string) {
return new Promise<void>((resolve, reject) => {
webApp.CloudStorage.removeItem(key, function (error: any) {
if (error) {
reject(error)
}

resolve()
})
})
}
13 changes: 13 additions & 0 deletions lib/actions/cloudStorage/removeItems.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { webApp } from '../../webApp'

export function removeItems(keys: string[]) {
return new Promise<void>((resolve, reject) => {
webApp.CloudStorage.removeItem(keys, function (error: any) {
if (error) {
reject(error)
}

resolve()
})
})
}
13 changes: 13 additions & 0 deletions lib/actions/cloudStorage/setItem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { webApp } from '../../webApp'

export function setItem(key: string, value: string) {
return new Promise<void>((resolve, reject) => {
webApp.CloudStorage.setItem(key, value, function (error: any) {
if (error) {
reject(error)
}

resolve()
})
})
}
3 changes: 2 additions & 1 deletion lib/actions/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as BackButton from './backButton'
import * as CloudStorage from './cloudStorage'
import * as HapticFeedback from './hapticFeedback'

export { close } from './close'
Expand All @@ -8,4 +9,4 @@ export { autoExpand, expand, stopAutoExpand } from './expand'
export { ready } from './ready'
export { setBackgroundColor } from './setBackgroundColor'
export { setHeaderColor } from './setHeaderColor'
export { BackButton, HapticFeedback }
export { BackButton, CloudStorage, HapticFeedback }
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kolirt/vue-telegram-mini-app",
"version": "0.0.6",
"version": "0.0.7",
"type": "module",
"description": "Vue 3 telegram mini app package",
"author": "kolirt",
Expand Down

0 comments on commit 3ed4ae6

Please sign in to comment.