mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 00:51:17 -08:00
unify naming and clean up press detection and fix selection
This commit is contained in:
1 parent
7e8c79ddcd
commit
9869bf3339
8 files changed
+170
-40
No files matched your search
@@ -24,9 +24,6 @@ if (updaterEndpoint && !updaterEndpoint.startsWith('https://')) {
|
||||
const file = 'src-tauri/tauri.conf.json';
|
||||
const config = JSON.parse(readFileSync(file, 'utf8'));
|
||||
config.version = version;
|
||||
if (version.includes('nightly')) {
|
||||
config.productName = 'Sable Nightly';
|
||||
}
|
||||
if (updaterEndpoint) {
|
||||
config.plugins.updater.endpoints = [updaterEndpoint];
|
||||
}
|
||||
|
||||
@@ -119,14 +119,17 @@ jobs:
|
||||
include:
|
||||
- name: macOS
|
||||
platform: macos-latest
|
||||
asset-platform: macos-universal
|
||||
rust-targets: aarch64-apple-darwin,x86_64-apple-darwin
|
||||
args: --target universal-apple-darwin
|
||||
- name: Windows
|
||||
platform: windows-latest
|
||||
asset-platform: windows-x86_64
|
||||
rust-targets: ''
|
||||
args: ''
|
||||
- name: Linux (CEF)
|
||||
platform: ubuntu-22.04
|
||||
asset-platform: linux-x86_64
|
||||
rust-targets: ''
|
||||
cef: true
|
||||
env:
|
||||
@@ -185,8 +188,7 @@ jobs:
|
||||
run: node .github/scripts/set-tauri-version.mjs "$VERSION" "$UPDATER_ENDPOINT"
|
||||
|
||||
# --- macOS / Windows: standard wry build via tauri-action ---
|
||||
- name: Configure desktop bundles
|
||||
if: ${{ !matrix.cef }}
|
||||
- name: Configure desktop build
|
||||
shell: bash
|
||||
env:
|
||||
IS_NIGHTLY: ${{ needs.setup-release.outputs.nightly }}
|
||||
@@ -199,6 +201,9 @@ jobs:
|
||||
if [ "$IS_NIGHTLY" = "true" ] && [ "$MATRIX_NAME" = "Windows" ]; then
|
||||
ARGS="$ARGS --bundles nsis"
|
||||
fi
|
||||
if [ "$IS_NIGHTLY" = "true" ]; then
|
||||
ARGS="$ARGS --config src-tauri/tauri.nightly.conf.json"
|
||||
fi
|
||||
echo "TAURI_BUILD_ARGS=${ARGS# }" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Build desktop bundles
|
||||
@@ -208,6 +213,30 @@ jobs:
|
||||
with:
|
||||
args: ${{ matrix.args }} ${{ env.TAURI_BUILD_ARGS }}
|
||||
|
||||
- name: Normalize desktop artifact names
|
||||
if: ${{ !matrix.cef }}
|
||||
shell: bash
|
||||
env:
|
||||
ASSET_PLATFORM: ${{ matrix.asset-platform }}
|
||||
run: |
|
||||
find src-tauri/target/release/bundle -type f -print0 \
|
||||
| while IFS= read -r -d '' path; do
|
||||
case "$path" in
|
||||
*.app.tar.gz.sig) suffix='.app.tar.gz.sig' ;;
|
||||
*.app.tar.gz) suffix='.app.tar.gz' ;;
|
||||
*.nsis.zip.sig) suffix='.nsis.zip.sig' ;;
|
||||
*.nsis.zip) suffix='.nsis.zip' ;;
|
||||
*-setup.exe.sig) suffix='-setup.exe.sig' ;;
|
||||
*-setup.exe) suffix='-setup.exe' ;;
|
||||
*.msi.sig) suffix='.msi.sig' ;;
|
||||
*.msi) suffix='.msi' ;;
|
||||
*.dmg) suffix='.dmg' ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
target="$(dirname "$path")/Sable-${VERSION}-${ASSET_PLATFORM}${suffix}"
|
||||
[ "$path" = "$target" ] || mv "$path" "$target"
|
||||
done
|
||||
|
||||
- name: Attest Windows bundles
|
||||
if: ${{ matrix.name == 'Windows' }}
|
||||
uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0
|
||||
@@ -223,24 +252,18 @@ jobs:
|
||||
shell: bash
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
ARTIFACTS: ${{ steps.tauri.outputs.artifactPaths }}
|
||||
run: |
|
||||
echo "$ARTIFACTS" | jq -r '.[]' | while read -r path; do
|
||||
path="${path%$'\r'}"
|
||||
[ -n "$path" ] || continue
|
||||
if [ -d "$path" ]; then
|
||||
echo "Skipping directory artifact: $path"
|
||||
continue
|
||||
fi
|
||||
echo "Uploading $path"
|
||||
gh release upload "$TAG" "$path" --clobber
|
||||
find src-tauri/target/release/bundle -type f -name 'Sable-*' -print0 \
|
||||
| while IFS= read -r -d '' path; do
|
||||
echo "Uploading $path"
|
||||
gh release upload "$TAG" "$path" --clobber
|
||||
done
|
||||
|
||||
# --- Linux: CEF runtime, packaged as deb / rpm / AppImage ---
|
||||
- name: Build CEF binary
|
||||
if: matrix.cef
|
||||
shell: bash
|
||||
run: pnpm tauri:cef build
|
||||
run: pnpm tauri:cef build $TAURI_BUILD_ARGS
|
||||
|
||||
- name: Build native packages
|
||||
if: matrix.cef
|
||||
@@ -251,7 +274,7 @@ jobs:
|
||||
if: ${{ matrix.cef && env.TAURI_SIGNING_PRIVATE_KEY != '' }}
|
||||
shell: bash
|
||||
run: |
|
||||
for f in src-tauri/target/release/bundle/appimage/Sable_*_amd64.AppImage; do
|
||||
for f in src-tauri/target/release/bundle/appimage/Sable-*-linux-x86_64.AppImage; do
|
||||
[ -e "$f" ] || continue
|
||||
pnpm tauri signer sign "$f"
|
||||
done
|
||||
@@ -273,9 +296,10 @@ jobs:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
BUNDLE="src-tauri/target/release/bundle"
|
||||
for f in "$BUNDLE"/deb/sable_*.deb "$BUNDLE"/rpm/sable-*.rpm \
|
||||
"$BUNDLE"/appimage/Sable_*_amd64.AppImage \
|
||||
"$BUNDLE"/appimage/Sable_*_amd64.AppImage.sig; do
|
||||
for f in "$BUNDLE"/deb/Sable-*-linux-x86_64.deb \
|
||||
"$BUNDLE"/rpm/Sable-*-linux-x86_64.rpm \
|
||||
"$BUNDLE"/appimage/Sable-*-linux-x86_64.AppImage \
|
||||
"$BUNDLE"/appimage/Sable-*-linux-x86_64.AppImage.sig; do
|
||||
[ -e "$f" ] || continue
|
||||
echo "Uploading $f"
|
||||
gh release upload "$TAG" "$f" --clobber
|
||||
@@ -351,7 +375,21 @@ jobs:
|
||||
|
||||
- name: Build Android bundles
|
||||
shell: bash
|
||||
run: pnpm tauri android build --apk --aab
|
||||
env:
|
||||
IS_NIGHTLY: ${{ needs.setup-release.outputs.nightly }}
|
||||
run: |
|
||||
ARGS=()
|
||||
if [ "$IS_NIGHTLY" = "true" ]; then
|
||||
ARGS+=(--config src-tauri/tauri.nightly.conf.json)
|
||||
fi
|
||||
pnpm tauri android build --apk --aab "${ARGS[@]}"
|
||||
OUT='src-tauri/gen/android/app/build/outputs'
|
||||
APK=$(find "$OUT/apk/universal/release" -name '*.apk' -type f | head -1)
|
||||
AAB=$(find "$OUT/bundle/universalRelease" -name '*.aab' -type f | head -1)
|
||||
[ -n "$APK" ] || { echo 'APK not found' >&2; exit 1; }
|
||||
[ -n "$AAB" ] || { echo 'AAB not found' >&2; exit 1; }
|
||||
mv "$APK" "$OUT/apk/universal/release/Sable-${VERSION}-android-universal.apk"
|
||||
mv "$AAB" "$OUT/bundle/universalRelease/Sable-${VERSION}-android-universal.aab"
|
||||
|
||||
- name: Attest Android bundles
|
||||
uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0
|
||||
@@ -425,10 +463,19 @@ jobs:
|
||||
- name: Build unsigned IPA
|
||||
id: ipa
|
||||
shell: bash
|
||||
env:
|
||||
IS_NIGHTLY: ${{ needs.setup-release.outputs.nightly }}
|
||||
run: |
|
||||
pnpm tauri ios build --no-sign --ci
|
||||
ARGS=()
|
||||
if [ "$IS_NIGHTLY" = "true" ]; then
|
||||
ARGS+=(--config src-tauri/tauri.nightly.conf.json)
|
||||
fi
|
||||
pnpm tauri ios build --no-sign --ci "${ARGS[@]}"
|
||||
IPA=$(find src-tauri/gen/apple/build -name '*.ipa' -type f | head -1)
|
||||
[ -n "$IPA" ] || { echo "IPA not found"; ls -R src-tauri/gen/apple/build 2>/dev/null || true; exit 1; }
|
||||
NORMALIZED_IPA="$(dirname "$IPA")/Sable-${VERSION}-ios-arm64.ipa"
|
||||
[ "$IPA" = "$NORMALIZED_IPA" ] || mv "$IPA" "$NORMALIZED_IPA"
|
||||
IPA="$NORMALIZED_IPA"
|
||||
echo "size=$(stat -f%z "$IPA")" >> "$GITHUB_OUTPUT"
|
||||
echo "path=$IPA" >> "$GITHUB_OUTPUT"
|
||||
echo "name=$(basename "$IPA")" >> "$GITHUB_OUTPUT"
|
||||
|
||||
@@ -25,12 +25,15 @@ WORK="$STAGE/cef-pkg"
|
||||
|
||||
if [ -x "$STAGE/Sable Nightly" ]; then
|
||||
BIN_NAME="Sable Nightly"
|
||||
DISPLAY_NAME="Sable Nightly"
|
||||
elif [ -x "$STAGE/Sable" ]; then
|
||||
BIN_NAME="Sable"
|
||||
DISPLAY_NAME="Sable"
|
||||
elif [ -x "$STAGE/sable" ]; then
|
||||
BIN_NAME="sable"
|
||||
DISPLAY_NAME="Sable"
|
||||
else
|
||||
echo "missing $STAGE/Sable or sable; build it first (pnpm tauri:cef build)" >&2
|
||||
echo "missing $STAGE/Sable Nightly, Sable, or sable; build it first (pnpm tauri:cef build)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -69,10 +72,10 @@ stage_appindicator() {
|
||||
}
|
||||
|
||||
write_desktop() {
|
||||
cat > "$1" <<'EOF'
|
||||
cat > "$1" <<EOF
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Sable
|
||||
Name=$DISPLAY_NAME
|
||||
Comment=A Matrix client
|
||||
Exec=sable %U
|
||||
Icon=sable
|
||||
@@ -114,7 +117,7 @@ EOF
|
||||
--depends libasound2 --depends libcups2 --depends xdg-utils
|
||||
--depends xwayland --depends libayatana-appindicator3-1)
|
||||
(cd "$OUT/deb" && fpm "${COMMON[@]}" -v "$DEB_VERSION" --iteration 1 \
|
||||
-t deb -a amd64 "${DEB_DEPS[@]}" -C "$PKGROOT" .)
|
||||
-t deb -a amd64 -p "Sable-${VERSION}-linux-x86_64.deb" "${DEB_DEPS[@]}" -C "$PKGROOT" .)
|
||||
|
||||
RPM_DEPS=(--depends gtk3 --depends nss --depends nspr
|
||||
--depends mesa-libgbm --depends libdrm --depends libxkbcommon
|
||||
@@ -122,7 +125,7 @@ EOF
|
||||
--depends xorg-x11-server-Xwayland
|
||||
--depends 'libayatana-appindicator3.so.1()(64bit)')
|
||||
(cd "$OUT/rpm" && fpm "${COMMON[@]}" -v "$RPM_VERSION" --iteration "$RPM_ITERATION" \
|
||||
-t rpm -a x86_64 "${RPM_DEPS[@]}" -C "$PKGROOT" .)
|
||||
-t rpm -a x86_64 -p "Sable-${VERSION}-linux-x86_64.rpm" "${RPM_DEPS[@]}" -C "$PKGROOT" .)
|
||||
else
|
||||
echo "fpm not found; skipping deb/rpm (building AppImage only)"
|
||||
fi
|
||||
@@ -149,6 +152,6 @@ curl -fsSL -o "$APPIMAGETOOL" \
|
||||
echo "${APPIMAGETOOL_SHA256} $APPIMAGETOOL" | sha256sum -c -
|
||||
chmod +x "$APPIMAGETOOL"
|
||||
APPIMAGE_EXTRACT_AND_RUN=1 ARCH=x86_64 "$APPIMAGETOOL" "$APPDIR" \
|
||||
"$OUT/appimage/Sable_${VERSION}_amd64.AppImage"
|
||||
"$OUT/appimage/Sable-${VERSION}-linux-x86_64.AppImage"
|
||||
|
||||
echo "Packages in: $OUT"
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
|
||||
"productName": "Sable Nightly"
|
||||
}
|
||||
@@ -493,7 +493,6 @@ export function RoomNavItem({
|
||||
ref={triggerRef}
|
||||
style={{
|
||||
...hideTextStyling(hideText),
|
||||
WebkitTouchCallout: 'none',
|
||||
WebkitTapHighlightColor: 'transparent',
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -938,9 +938,7 @@ function MessageInternal(
|
||||
style={{
|
||||
width: '100%',
|
||||
WebkitTouchCallout: 'none',
|
||||
WebkitUserSelect: 'none',
|
||||
WebkitTapHighlightColor: 'transparent',
|
||||
userSelect: 'none',
|
||||
}}
|
||||
onContextMenu={handleContextMenu}
|
||||
onTouchStart={onTouchStart}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import { act, renderHook } from '@testing-library/react';
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { useMobileLongPress } from './useMobileLongPress';
|
||||
|
||||
const touchEvent = (clientX: number, clientY: number) =>
|
||||
({ touches: [{ clientX, clientY }] }) as unknown as React.TouchEvent;
|
||||
|
||||
describe('useMobileLongPress', () => {
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it('fires after the hold delay', () => {
|
||||
vi.useFakeTimers();
|
||||
const callback = vi.fn<() => void>();
|
||||
const { result } = renderHook(() => useMobileLongPress(callback));
|
||||
|
||||
act(() => result.current.onTouchStart(touchEvent(20, 30)));
|
||||
expect(result.current.isPressing).toBe(true);
|
||||
|
||||
act(() => vi.advanceTimersByTime(500));
|
||||
expect(callback).toHaveBeenCalledOnce();
|
||||
expect(result.current.isPressing).toBe(false);
|
||||
expect(result.current.firedRef.current).toBe(true);
|
||||
});
|
||||
|
||||
it('allows small finger movement during a hold', () => {
|
||||
vi.useFakeTimers();
|
||||
const callback = vi.fn<() => void>();
|
||||
const { result } = renderHook(() => useMobileLongPress(callback));
|
||||
|
||||
act(() => {
|
||||
result.current.onTouchStart(touchEvent(20, 30));
|
||||
result.current.onTouchMove(touchEvent(32, 42));
|
||||
vi.advanceTimersByTime(500);
|
||||
});
|
||||
|
||||
expect(callback).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it('cancels when the touch becomes a scroll', () => {
|
||||
vi.useFakeTimers();
|
||||
const callback = vi.fn<() => void>();
|
||||
const { result } = renderHook(() => useMobileLongPress(callback));
|
||||
|
||||
act(() => {
|
||||
result.current.onTouchStart(touchEvent(20, 30));
|
||||
result.current.onTouchMove(touchEvent(20, 60));
|
||||
vi.advanceTimersByTime(500);
|
||||
});
|
||||
|
||||
expect(callback).not.toHaveBeenCalled();
|
||||
expect(result.current.isPressing).toBe(false);
|
||||
});
|
||||
|
||||
it('cancels a pending hold when unmounted', () => {
|
||||
vi.useFakeTimers();
|
||||
const callback = vi.fn<() => void>();
|
||||
const { result, unmount } = renderHook(() => useMobileLongPress(callback));
|
||||
|
||||
act(() => result.current.onTouchStart(touchEvent(20, 30)));
|
||||
unmount();
|
||||
act(() => vi.advanceTimersByTime(500));
|
||||
|
||||
expect(callback).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -1,12 +1,17 @@
|
||||
import { useRef, useCallback, useState } from 'react';
|
||||
import { useRef, useCallback, useEffect, useState } from 'react';
|
||||
|
||||
const MOVE_TOLERANCE = 16;
|
||||
|
||||
export function useMobileLongPress(callback: () => void, delay = 500) {
|
||||
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
const callbackRef = useRef(callback);
|
||||
const firedRef = useRef(false);
|
||||
const [isPressing, setIsPressing] = useState(false);
|
||||
const startY = useRef<number | null>(null);
|
||||
const startX = useRef<number | null>(null);
|
||||
|
||||
callbackRef.current = callback;
|
||||
|
||||
const clear = useCallback(() => {
|
||||
if (timerRef.current !== null) {
|
||||
clearTimeout(timerRef.current);
|
||||
@@ -19,22 +24,32 @@ export function useMobileLongPress(callback: () => void, delay = 500) {
|
||||
startX.current = null;
|
||||
}, []);
|
||||
|
||||
useEffect(
|
||||
() => () => {
|
||||
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
const onTouchStart = useCallback(
|
||||
(e: React.TouchEvent | TouchEvent) => {
|
||||
clear();
|
||||
firedRef.current = false;
|
||||
const touch = 'touches' in e && e.touches.length === 1 ? e.touches[0] : undefined;
|
||||
if (!touch) return;
|
||||
|
||||
setIsPressing(true);
|
||||
if ('touches' in e && e.touches[0]) {
|
||||
startY.current = e.touches[0].clientY;
|
||||
startX.current = e.touches[0].clientX;
|
||||
}
|
||||
startY.current = touch.clientY;
|
||||
startX.current = touch.clientX;
|
||||
|
||||
timerRef.current = setTimeout(() => {
|
||||
timerRef.current = null;
|
||||
firedRef.current = true;
|
||||
callback();
|
||||
setTimeout(() => setIsPressing(false), 300);
|
||||
setIsPressing(false);
|
||||
callbackRef.current();
|
||||
}, delay);
|
||||
},
|
||||
[callback, delay]
|
||||
[clear, delay]
|
||||
);
|
||||
|
||||
const onTouchEnd = useCallback(() => {
|
||||
@@ -55,7 +70,7 @@ export function useMobileLongPress(callback: () => void, delay = 500) {
|
||||
const diffY = Math.abs(e.touches[0].clientY - startY.current);
|
||||
const diffX = Math.abs(e.touches[0].clientX - startX.current);
|
||||
|
||||
if (diffY > 10 || diffX > 10) {
|
||||
if (diffY > MOVE_TOLERANCE || diffX > MOVE_TOLERANCE) {
|
||||
clear();
|
||||
}
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user