Skip to content

feat: disabled close on swipe#131

Merged
hmbanan666 merged 1 commit intomainfrom
swipe
Sep 3, 2025
Merged

feat: disabled close on swipe#131
hmbanan666 merged 1 commit intomainfrom
swipe

Conversation

@hmbanan666
Copy link
Copy Markdown
Collaborator

@hmbanan666 hmbanan666 commented Sep 3, 2025

Summary by CodeRabbit

  • New Features

    • Added “Мои данные” button and a city selection button on the user page with a dynamic label and clear action.
    • Disabled vertical swipe gestures to reduce accidental app closures in Telegram.
  • Bug Fixes

    • City selection now clears after applying and closes the selector, preventing residual selections.
  • Style

    • Updated user points progress bar appearance with a softer primary-tinted background.

@hmbanan666 hmbanan666 self-assigned this Sep 3, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Sep 3, 2025

Walkthrough

Implements city selection cleanup in CitySelector.vue, adds two user-page buttons with city store integration, tweaks UserPointsCard progress UI, and updates app initialization to conditionally disable vertical swipes via @telegram-apps/sdk-vue.

Changes

Cohort / File(s) Summary
City selection UX
apps/storefront-telegram/app/components/CitySelector.vue, apps/storefront-telegram/app/pages/user.vue
CitySelector now clears selectedCities after applying selection and closes the drawer. User page adds city store usage, a “Мои данные” button, and a dynamic city-selection button that can clear cityStore.selected.
UI styling tweak
apps/storefront-telegram/app/components/UserPointsCard.vue
Passes :ui="{ base: 'bg-primary/10' }" to UProgress to adjust background styling; logic unchanged.
Initialization behavior
apps/storefront-telegram/app/utils/init.ts
Imports disableVerticalSwipes from @telegram-apps/sdk-vue and calls it when available during init to disable vertical swipe closes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant App as App Init
  participant SDK as Telegram SDK (vue)

  User->>App: Launch app
  App->>SDK: Initialize & setup close behavior
  alt Vertical swipe disabling available
    App->>SDK: disableVerticalSwipes()
    note right of SDK: Vertical swipe-to-close disabled
  else Not available
    App-->>SDK: Skip disabling
  end
  App-->>User: App ready
Loading
sequenceDiagram
  autonumber
  actor User
  participant CitySel as CitySelector.vue
  participant Store as City Store

  User->>CitySel: Select city (ID)
  CitySel->>Store: Apply selection
  CitySel->>CitySel: selectedCities = []  %% clear bound selection
  CitySel-->>User: Close city drawer

  User->>Store: Tap "Выбрать город" / city button
  alt Clear selection
    User->>Store: cityStore.selected = undefined
  else Already selected
    Store-->>User: Shows selected city name
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • chore: visual updates #128 — Also edits UserPointsCard.vue styling and utils/init.ts initialization, indicating overlapping UI and init concerns.

Poem

I hopped through drawers that softly close,
Cleared my basket—off it goes!
A city picked, then whisked away,
Progress bars in pastel play.
Swipes be still, the app stands tall—
Tap-tap, I choose, then nibble all. 🐰✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch swipe

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Sep 3, 2025

@hmbanan666 hmbanan666 merged commit d3a2eb9 into main Sep 3, 2025
7 of 8 checks passed
@hmbanan666 hmbanan666 deleted the swipe branch September 3, 2025 15:34
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
apps/storefront-telegram/app/components/UserPointsCard.vue (1)

67-69: Stabilize the ui object to avoid re-creation on each render

Hoist the object to script scope (minor perf/readability).

-      <UProgress
-        v-model="progress"
-        color="primary"
-        :ui="{
-          base: 'bg-primary/10',
-        }"
-      />
+      <UProgress
+        v-model="progress"
+        color="primary"
+        :ui="progressUi"
+      />

Add in <script setup>:

const progressUi = { base: 'bg-primary/10' } as const
apps/storefront-telegram/app/components/CitySelector.vue (3)

45-54: Avoid reopening the drawer after programmatic clear

Clearing selectedCities triggers the watcher again and flips isCitySelectOpened back to true in the same tick. It’s harmless (component unmounts due to v-if), but we can make it deterministic.

-watch(selectedCities, () => {
-  if (!selectedCities.value.length) {
-    isCitySelectOpened.value = true
-    return
-  }
-
-  cityStore.selected = cityStore.cities.find((c) => c.id === selectedCities.value[0])
-  selectedCities.value = []
-  isCitySelectOpened.value = false
-})
+watch(selectedCities, (next, prev) => {
+  if (next.length === 0) {
+    // Do not reopen right after programmatic clear
+    if (prev?.length > 0) return
+    isCitySelectOpened.value = true
+    return
+  }
+  cityStore.selected = cityStore.cities.find((c) => c.id === next[0])
+  isCitySelectOpened.value = false
+  selectedCities.value = []
+}, { flush: 'post' })

40-43: Keep items reactive to store updates

If city list changes later, items won’t update.

-const items = ref<CheckboxGroupItem[]>(cityStore.cities.map((c) => ({ label: c.name, value: c.id })))
+const items = computed<CheckboxGroupItem[]>(() =>
+  cityStore.cities.map((c) => ({ label: c.name, value: c.id })),
+)

42-52: Type safety for checkbox values

Ensure id type matches CheckboxGroupItem.value (string | number). Currently selectedCities is string[] which may mismatch numeric ids.

Potential fix:

-const selectedCities = ref<string[]>([])
+type Value = CheckboxGroupItem['value']
+const selectedCities = ref<Value[]>([])
apps/storefront-telegram/app/pages/user.vue (1)

28-40: Button behavior looks good; minor readability win for label

The clear-to-open flow is fine (CitySelector mounts via v-if). Consider a computed for label.

-        <UButton
-          color="neutral"
-          variant="ghost"
-          :label="cityStore.selected ? cityStore.selected.name : 'Выбрать город'"
-          icon="i-lucide-locate-fixed"
-          @click="cityStore.selected = undefined"
-        />
+        <UButton
+          color="neutral"
+          variant="ghost"
+          :label="cityLabel"
+          icon="i-lucide-locate-fixed"
+          @click="cityStore.selected = undefined"
+        />

Add in <script setup>:

const cityLabel = computed(() => cityStore.selected?.name ?? 'Выбрать город')
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 30f7e57 and 5839b6f.

📒 Files selected for processing (4)
  • apps/storefront-telegram/app/components/CitySelector.vue (1 hunks)
  • apps/storefront-telegram/app/components/UserPointsCard.vue (1 hunks)
  • apps/storefront-telegram/app/pages/user.vue (1 hunks)
  • apps/storefront-telegram/app/utils/init.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (1)
apps/storefront-telegram/app/utils/init.ts (1)

6-6: Good call: disable vertical swipes guarded by isAvailable

This aligns with Telegram Mini App UX and won’t break older clients. Please sanity-check on Android/iOS real clients.

Manual check suggestions:

  • Android: swipe-down should no longer minimize/close.
  • iOS: confirm no regressions with back button and closingBehavior confirmation.

Also applies to: 89-93

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant