-
Notifications
You must be signed in to change notification settings - Fork 0
chore: feedback rework #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,18 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { hapticFeedback } from '@telegram-apps/sdk-vue' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function _useFeedback() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function vibrate() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (hapticFeedback.impactOccurred.isAvailable()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function vibrate(type: 'light' | 'success' | 'error' = 'light') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (type === 'light' && hapticFeedback.impactOccurred.isAvailable()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hapticFeedback.impactOccurred('light') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (type === 'success' && hapticFeedback.notificationOccurred.isAvailable()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hapticFeedback.notificationOccurred('success') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (type === 'error' && hapticFeedback.notificationOccurred.isAvailable()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hapticFeedback.notificationOccurred('error') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+4
to
16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Harden availability checks and add sensible fallbacks. Calling .isAvailable() without guarding can throw if the API isn’t wired (SSR, older clients). Also add a fallback impact for success/error when notification isn’t available, and consider supporting 'warning'. Apply: - function vibrate(type: 'light' | 'success' | 'error' = 'light') {
- if (type === 'light' && hapticFeedback.impactOccurred.isAvailable()) {
- hapticFeedback.impactOccurred('light')
- }
-
- if (type === 'success' && hapticFeedback.notificationOccurred.isAvailable()) {
- hapticFeedback.notificationOccurred('success')
- }
-
- if (type === 'error' && hapticFeedback.notificationOccurred.isAvailable()) {
- hapticFeedback.notificationOccurred('error')
- }
- }
+ function vibrate(type: 'light' | 'success' | 'warning' | 'error' = 'light') {
+ const impactAvailable = !!hapticFeedback?.impactOccurred?.isAvailable?.()
+ const notifAvailable = !!hapticFeedback?.notificationOccurred?.isAvailable?.()
+
+ switch (type) {
+ case 'light':
+ if (impactAvailable) hapticFeedback.impactOccurred('light')
+ break
+ case 'success':
+ case 'warning':
+ case 'error':
+ if (notifAvailable) {
+ hapticFeedback.notificationOccurred(type)
+ } else if (impactAvailable) {
+ hapticFeedback.impactOccurred(type === 'error' ? 'heavy' : 'medium')
+ }
+ break
+ }
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Double-check Tailwind class support for invert-50.
Tailwind’s core provides invert (100%) and invert-0; invert-50 isn’t standard unless you’ve extended utilities. Prefer invert or an arbitrary value (invert-[.5]) if partial inversion is desired.
Apply if you’re not extending Tailwind:
Run to verify Tailwind config and usage:
🏁 Script executed:
Length of output: 251
Replace non-standard
invert-50with a supported Tailwind utilityOur codebase doesn’t include a
tailwind.config.*file extendinginvertto 50%, soinvert-50won’t generate any CSS by default. You have two options:invert(100%) orinvert-0invert-[.5]Since there’s no existing extension, please update the class on line 5 of
apps/atrium-telegram/app/components/Loader.vue:📝 Committable suggestion
🤖 Prompt for AI Agents