Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

feat(frontend): Open on touch on smartphones (#306)

BlaiseLebreton2f35b3f4d9a9
diff --git a/frontend/src/app/applications/spaces/components/spaces-browser.component.html b/frontend/src/app/applications/spaces/components/spaces-browser.component.html
index ad46d956..330dc3c9 100644
--- a/frontend/src/app/applications/spaces/components/spaces-browser.component.html
+++ b/frontend/src/app/applications/spaces/components/spaces-browser.component.html
@@ -290,7 +290,8 @@
@for (f of scrollView?.viewPortItems; track f.id) {
<div (click)="onSelect($event, f)"
(contextmenu)="onTargetContextMenu($event, f)"
- (appTap)="browse(f)"
+ (appTap)="onFileActivate(f)"
+ [singleTapOnTouch]="true"
[class.disabled]="f.isDisabled"
[class.deleted]="f.isBeingDeleted"
[class.selected]="f.isSelected"
@@ -320,7 +321,7 @@
draggable="true"
(error)="f.fallBackMimeUrl()">
}
- <span class="label-bottom-right">
+ <span class="label-bottom-right" data-app-tap-ignore>
@let maxBadges = galleryMode.maxBadges || 0;
@let hiddenBadges = f.nbBadges - maxBadges;
@for (badge of f.galleryBadges; track badge; let i = $index) {
@@ -462,7 +463,8 @@
@for (f of scrollView?.viewPortItems; track f.id) {
<tr (click)="onSelect($event, f)"
(contextmenu)="onTargetContextMenu($event, f)"
- (appTap)="browse(f)"
+ (appTap)="onFileActivate(f)"
+ [singleTapOnTouch]="true"
[class.disabled]="f.isDisabled"
[class.deleted]="f.isBeingDeleted"
[class.selected]="f.isSelected">
@@ -523,25 +525,29 @@
<span (click)="openLockDialog(f)"
tooltip="{{f.lock | fileLockFormatPipe}}"
placement="auto"
- class="badge bg-maroon cursor-pointer me-1">
+ class="badge bg-maroon cursor-pointer me-1"
+ data-app-tap-ignore>
<svg [lucideIcon]="f.lock.isExclusive ? icons.LucideLock : icons.LucideLockOpen"></svg>
</span>
}
@if (f.isFavorite) {
<span (click)="layout.showRSideBarTab(TAB_MENU.SELECTION, true)"
- class="badge bg-warning cursor-pointer me-1">
+ class="badge bg-warning cursor-pointer me-1"
+ data-app-tap-ignore>
<svg [lucideIcon]="icons.FAVORITES"></svg>
</span>
}
@if (f.hasComments) {
<span (click)="layout.showRSideBarTab(TAB_MENU.COMMENTS, true)"
- class="badge bg-success cursor-pointer me-1">
+ class="badge bg-success cursor-pointer me-1"
+ data-app-tap-ignore>
<svg [lucideIcon]="icons.LucideMessageSquareMore"></svg>
</span>
}
@if (f.shares.length) {
<span (click)="layout.showRSideBarTab(TAB_MENU.SELECTION, true)"
- class="badge bg-primary cursor-pointer me-1">
+ class="badge bg-primary cursor-pointer me-1"
+ data-app-tap-ignore>
<svg [lucideIcon]="icons.SHARED"></svg>
@if (f.shares.length > 1) {
{{ f.shares.length }}
@@ -550,7 +556,8 @@
}
@if (f.links.length) {
<span (click)="layout.showRSideBarTab(TAB_MENU.SELECTION, true)"
- class="badge bg-primary cursor-pointer me-1">
+ class="badge bg-primary cursor-pointer me-1"
+ data-app-tap-ignore>
<svg [lucideIcon]="icons.LINKS"></svg>
@if (f.links.length > 1) {
{{ f.links.length }}
@@ -559,7 +566,8 @@
}
@if (f.spaces.length) {
<span (click)="layout.showRSideBarTab(TAB_MENU.SELECTION, true)"
- class="badge bg-primary cursor-pointer me-1">
+ class="badge bg-primary cursor-pointer me-1"
+ data-app-tap-ignore>
<svg [lucideIcon]="icons.SPACES"></svg>
@if (f.spaces.length > 1) {
{{ f.spaces.length }}
@@ -568,7 +576,8 @@
}
@if (f.syncs.length) {
<span (click)="layout.showRSideBarTab(TAB_MENU.SELECTION, true)"
- class="badge bg-primary cursor-pointer">
+ class="badge bg-primary cursor-pointer"
+ data-app-tap-ignore>
<svg [lucideIcon]="icons.SYNC"></svg>
@if (f.syncs.length > 1) {
{{ f.syncs.length }}
diff --git a/frontend/src/app/applications/spaces/components/spaces-browser.component.ts b/frontend/src/app/applications/spaces/components/spaces-browser.component.ts
index 3338600e..80d1d951 100644
--- a/frontend/src/app/applications/spaces/components/spaces-browser.component.ts
+++ b/frontend/src/app/applications/spaces/components/spaces-browser.component.ts
@@ -436,6 +436,14 @@ export class SpacesBrowserComponent implements OnInit, AfterViewInit, OnDestroy
this.layout.openContextMenu(ev, this.fileContextMenu)
}
+ onFileActivate(file: FileModel) {
+ this.layout.closeContextMenu()
+ if (this.selection.length !== 1 || this.selection[0] !== file) {
+ this.setSelection([file], file, file)
+ }
+ this.browse(file)
+ }
+
browse(file: FileModel) {
if (file.isDisabled) {
this.layout.sendNotification('warning', file.name, 'Share is disabled')
@@ -445,7 +453,7 @@ export class SpacesBrowserComponent implements OnInit, AfterViewInit, OnDestroy
if (file.isDir) {
this.router.navigate([file.root?.alias || file.name], { relativeTo: this.activatedRoute }).catch(console.error)
} else {
- this.shortcutOpen()
+ this.shortcutOpen(file)
}
}
}
@@ -463,13 +471,12 @@ export class SpacesBrowserComponent implements OnInit, AfterViewInit, OnDestroy
}
}
- shortcutOpen() {
- const file = this.selection[0]
+ shortcutOpen(file: FileModel = this.selection[0]) {
if (!file) return
if (file.isDir) {
this.browse(file)
} else if (file.isViewable || file.isEditable) {
- this.openViewerDialog()
+ this.openViewerDialog(file)
} else {
this.notifyPreviewUnavailable(file)
}
@@ -742,8 +749,7 @@ export class SpacesBrowserComponent implements OnInit, AfterViewInit, OnDestroy
}
}
- private openViewerDialog() {
- const f = this.selection[0]
+ private openViewerDialog(f: FileModel) {
let permissions: string
if (this.isTrashRepo) {
permissions = ''
diff --git a/frontend/src/app/common/directives/tap.directive.ts b/frontend/src/app/common/directives/tap.directive.ts
index 1a59a376..94480bce 100644
--- a/frontend/src/app/common/directives/tap.directive.ts
+++ b/frontend/src/app/common/directives/tap.directive.ts
@@ -26,6 +26,8 @@ export class TapDirective implements OnDestroy {
@Input() doubleTapSlop = 24
/** Enables or disables double-tap detection */
@Input() enableDoubleTap = true
+ /** Emits a single tap immediately for touch pointers. */
+ @Input() singleTapOnTouch = false
/**
* ⚙️ Hammer-like behavior control.
* false → STRICT Hammer mode: no single tap is emitted if the second tap does not occur (default)
@@ -97,7 +99,7 @@ export class TapDirective implements OnDestroy {
ev.pointerType !== 'touch' ||
!ev.isPrimary ||
ev.button !== 0 ||
- this.isEditableTarget(ev.target)
+ this.isIgnoredTarget(ev.target)
) {
return
}
@@ -140,7 +142,7 @@ export class TapDirective implements OnDestroy {
}
private onDown = (ev: PointerEvent) => {
- if (this.disabled || ev.button !== 0 || this.active) return
+ if (this.disabled || ev.button !== 0 || this.active || this.isIgnoredTarget(ev.target)) return
this.active = true
this.pointerId = ev.pointerId
this.startX = ev.clientX
@@ -178,6 +180,11 @@ export class TapDirective implements OnDestroy {
const x = ev.clientX
const y = ev.clientY
+ if (this.singleTapOnTouch && ev.pointerType === 'touch') {
+ this.emit('single', x, y, ev)
+ return
+ }
+
if (!this.enableDoubleTap) {
this.emit('single', x, y, ev)
return
@@ -248,8 +255,12 @@ export class TapDirective implements OnDestroy {
this.longPressPointerId = null
}
- private isEditableTarget(target: EventTarget | null): boolean {
- return target instanceof Element && !!target.closest('input, textarea, select, [contenteditable]:not([contenteditable="false"])')
+ private isIgnoredTarget(target: EventTarget | null): boolean {
+ if (!(target instanceof Element)) return false
+ const ignoredTarget = target.closest(
+ 'button, a, input, textarea, select, [contenteditable]:not([contenteditable="false"]), [data-app-tap-ignore]'
+ )
+ return !!ignoredTarget && ignoredTarget !== this.el && this.el.contains(ignoredTarget)
}
private isIosTouchDevice(): boolean {
diff --git a/frontend/src/app/layout/layout.service.ts b/frontend/src/app/layout/layout.service.ts
index 130028c4..a06a8f5b 100644
--- a/frontend/src/app/layout/layout.service.ts
+++ b/frontend/src/app/layout/layout.service.ts
@@ -218,10 +218,14 @@ export class LayoutService {
}
openContextMenu(event: any, component: ContextMenuComponent<any>) {
+ this.closeContextMenu()
+ setTimeout(() => this.contextMenu.show(component, event.type === 'contextmenu' ? event : event.srcEvent), 5)
+ }
+
+ closeContextMenu(): void {
if (this.contextMenu.hasOpenMenu()) {
this.contextMenu.closeAll()
}
- setTimeout(() => this.contextMenu.show(component, event.type === 'contextmenu' ? event : event.srcEvent), 5)
}
sendNotification(