Compare commits
25 Commits
69b94ab7c0
..
v1.0.7
| Author | SHA1 | Date | |
|---|---|---|---|
| d4c16ccf97 | |||
| 0696f5663e | |||
| 4a531df8bd | |||
| 365f44dbe4 | |||
| 40c2ce20f3 | |||
| aa516667cd | |||
| f6fcf35cf8 | |||
| 2869f4ee5f | |||
| 614a353b3c | |||
| 7111162f14 | |||
| aaf6b2aa07 | |||
| e051ce8e7f | |||
| 7f39d79190 | |||
| 979a5c1dd3 | |||
| 20226caef4 | |||
| 7aacb9a53e | |||
| bc0973ccaa | |||
| 4dc746514a | |||
| 55d283c264 | |||
| e1a294fc96 | |||
| 554b16d6cb | |||
| be57d581ac | |||
| 3d2ba858bb | |||
| 3191691fff | |||
| 803f147fbb |
@@ -0,0 +1,116 @@
|
|||||||
|
name: Release APK
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*.*.*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
if: github.server_url == 'https://github.com'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 60
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: temurin
|
||||||
|
java-version: '21'
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
|
||||||
|
- name: Install pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: 9
|
||||||
|
|
||||||
|
- name: Get pnpm store path
|
||||||
|
id: pnpm-cache
|
||||||
|
shell: bash
|
||||||
|
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Cache pnpm store
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
||||||
|
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-pnpm-
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
working-directory: artifacts/postiz-mobile
|
||||||
|
run: pnpm install --no-frozen-lockfile
|
||||||
|
|
||||||
|
- name: Set up Android SDK
|
||||||
|
uses: android-actions/setup-android@v3
|
||||||
|
|
||||||
|
- name: Accept Android SDK licenses
|
||||||
|
run: yes | sdkmanager --licenses || true
|
||||||
|
|
||||||
|
- name: Cache Android NDK
|
||||||
|
id: ndk-cache
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: /usr/local/lib/android/sdk/ndk/28.2.13676358
|
||||||
|
key: ndk-28.2.13676358-v1
|
||||||
|
|
||||||
|
- name: Install SDK components
|
||||||
|
run: |
|
||||||
|
sdkmanager "platform-tools" "platforms;android-35" "build-tools;35.0.0"
|
||||||
|
if [ "${{ steps.ndk-cache.outputs.cache-hit }}" != "true" ]; then
|
||||||
|
sdkmanager "ndk;28.2.13676358"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Cache Gradle
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.gradle/caches
|
||||||
|
~/.gradle/wrapper
|
||||||
|
key: ${{ runner.os }}-gradle-${{ hashFiles('artifacts/postiz-mobile/package.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-gradle-
|
||||||
|
|
||||||
|
- name: Decode keystore
|
||||||
|
run: |
|
||||||
|
mkdir -p ~/.config/postiz-mobile
|
||||||
|
echo "${{ secrets.KEYSTORE_B64 }}" | base64 -d > ~/.config/postiz-mobile/postiz-mobile.jks
|
||||||
|
cat > ~/.config/postiz-mobile/signing.env <<EOF
|
||||||
|
KEYSTORE_PATH=~/.config/postiz-mobile/postiz-mobile.jks
|
||||||
|
KEYSTORE_ALIAS=${{ secrets.KEYSTORE_ALIAS }}
|
||||||
|
KEYSTORE_STORE_PASSWORD=${{ secrets.KEYSTORE_STORE_PASSWORD }}
|
||||||
|
KEYSTORE_KEY_PASSWORD=${{ secrets.KEYSTORE_KEY_PASSWORD }}
|
||||||
|
EOF
|
||||||
|
chmod 600 ~/.config/postiz-mobile/signing.env ~/.config/postiz-mobile/postiz-mobile.jks
|
||||||
|
|
||||||
|
- name: Build signed APK
|
||||||
|
working-directory: artifacts/postiz-mobile
|
||||||
|
run: ./build-apk.sh
|
||||||
|
|
||||||
|
- name: Find built APK
|
||||||
|
id: apk
|
||||||
|
run: |
|
||||||
|
APK=$(ls artifacts/postiz-mobile/dist/*.apk | sort | tail -1)
|
||||||
|
echo "path=$APK" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Create GitHub Release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
name: "Postiz Mobile ${{ github.ref_name }}"
|
||||||
|
body: |
|
||||||
|
## Postiz Mobile ${{ github.ref_name }}
|
||||||
|
|
||||||
|
Signed APK for Android — direct install (sideload).
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
1. Enable "Unknown sources" on the device
|
||||||
|
2. Transfer the APK to the device and open it to install
|
||||||
|
files: ${{ steps.apk.outputs.path }}
|
||||||
|
draft: false
|
||||||
|
prerelease: ${{ contains(github.ref_name, '-') }}
|
||||||
@@ -47,3 +47,4 @@ Thumbs.db
|
|||||||
# Replit
|
# Replit
|
||||||
.cache/
|
.cache/
|
||||||
.local/
|
.local/
|
||||||
|
scripts/push-to-gitea.sh
|
||||||
|
|||||||
@@ -1,381 +1,110 @@
|
|||||||
# PostizMobile
|
# PostizMobile
|
||||||
|
|
||||||
Application mobile React Native (Expo) pour piloter une instance **Postiz** auto-hébergée depuis votre téléphone Android ou iOS.
|
React Native (Expo) mobile app to control a self-hosted [Postiz](https://postiz.com) instance from Android.
|
||||||
|
|
||||||
|
Build is fully local — no expo.dev account or EAS cloud required.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Sommaire
|
## Features
|
||||||
|
|
||||||
1. [Fonctionnalités](#fonctionnalités)
|
| Screen | Description |
|
||||||
2. [Prérequis](#prérequis)
|
|--------|-------------|
|
||||||
3. [Installation & développement](#installation--développement)
|
| **Calendar** | Monthly view with color dots per day (indigo = scheduled, green = published, red = error). Tap a day to see its posts. |
|
||||||
4. [Configuration de l'application](#configuration-de-lapplication)
|
| **Posts** | Filtered list (All / Queue / Published / Draft / Error) with sort toggle, pull-to-refresh, swipe left to delete, swipe right to reschedule. |
|
||||||
5. [Architecture du projet](#architecture-du-projet)
|
| **Compose** | Text editor with per-network character limit, channel picker, date/time picker, gallery image pick + upload, publish now or schedule. Local draft save/restore. |
|
||||||
6. [API Postiz utilisée](#api-postiz-utilisée)
|
| **Settings** | API key and base URL, connection test, secure storage. 401 auto-redirect to Settings. |
|
||||||
7. [Build APK Android (EAS)](#build-apk-android-eas)
|
| **Notifications** | Local alerts when a post transitions to PUBLISHED or ERROR (polling every 15 min). |
|
||||||
8. [Build iOS (Expo Launch)](#build-ios-expo-launch)
|
|
||||||
9. [Pousser les modifications sur Gitea](#pousser-les-modifications-sur-gitea)
|
**Theme**: forced dark. **Auth**: API key in `expo-secure-store`, never hardcoded.
|
||||||
10. [Variables d'environnement & secrets](#variables-denvironnement--secrets)
|
|
||||||
11. [Dépannage](#dépannage)
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Fonctionnalités
|
## Prerequisites
|
||||||
|
|
||||||
| Écran | Description |
|
| Tool | Version |
|
||||||
|-------|-------------|
|
|------|---------|
|
||||||
| **Calendrier** | Vue mensuelle avec points de couleur par jour (indigo = planifié, vert = publié, rouge = erreur). Tap sur un jour pour voir les posts. |
|
|
||||||
| **Posts** | Liste filtrée (Tous / Queue / Publié / Brouillon / Erreur) avec pull-to-refresh et swipe gauche pour supprimer. |
|
|
||||||
| **Composer** | Éditeur de texte, sélecteur de canaux, date/heure, importation d'image galerie + upload, publier maintenant ou planifier. |
|
|
||||||
| **Paramètres** | Saisie de la clé API et de l'URL de base, test de connexion, sauvegarde sécurisée (SecureStore). |
|
|
||||||
| **Notifications** | Alertes locales automatiques quand un post passe à PUBLISHED ou ERROR (polling toutes les 15 minutes). |
|
|
||||||
|
|
||||||
**Thème** : dark forcé (`userInterfaceStyle: dark`).
|
|
||||||
**Authentification** : clé API stockée dans `expo-secure-store`, jamais en dur dans le code.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Prérequis
|
|
||||||
|
|
||||||
| Outil | Version minimale |
|
|
||||||
|-------|-----------------|
|
|
||||||
| Node.js | 20 LTS |
|
| Node.js | 20 LTS |
|
||||||
| pnpm | 10+ |
|
| pnpm | 10+ |
|
||||||
| Expo Go (téléphone) | SDK 54 compatible |
|
| Java (JDK) | 17–24 (Java 25+ not yet supported by Gradle 8) |
|
||||||
| Compte EAS (pour APK) | gratuit sur expo.dev |
|
| Android SDK | see below |
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install -g pnpm
|
|
||||||
npm install -g eas-cli
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Installation & développement
|
## Installation & Development
|
||||||
|
|
||||||
### 1. Cloner le dépôt
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone ssh://gitea@homegit.gyozamancave.fr:2222/billisdead/Postiz-android.git
|
|
||||||
cd Postiz-android
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. Installer les dépendances
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
git clone https://github.com/pirona/postiz-android.git
|
||||||
|
cd postiz-android
|
||||||
pnpm install
|
pnpm install
|
||||||
```
|
```
|
||||||
|
|
||||||
### 3. Lancer le serveur de développement
|
Start the dev server (requires Expo Go on the device):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm --filter @workspace/postiz-mobile run dev
|
pnpm --filter @workspace/postiz-mobile run dev
|
||||||
```
|
```
|
||||||
|
|
||||||
Le terminal affiche un QR code. Scannez-le avec **Expo Go** (Android) ou l'app **Appareil photo** (iOS) pour voir l'app en direct.
|
|
||||||
|
|
||||||
### 4. Ouvrir dans le navigateur (web preview)
|
|
||||||
|
|
||||||
```
|
|
||||||
http://localhost:<PORT>
|
|
||||||
```
|
|
||||||
|
|
||||||
Le port est assigné dynamiquement par l'environnement Replit.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Configuration de l'application
|
## Building an APK (local, no EAS)
|
||||||
|
|
||||||
Au premier lancement, l'écran **Paramètres** s'affiche car aucune clé n'est configurée.
|
See **[artifacts/postiz-mobile/README.md](artifacts/postiz-mobile/README.md)** for the full build guide.
|
||||||
|
|
||||||
1. **URL de base** : `https://votre-instance-postiz.fr/public/v1`
|
Quick start:
|
||||||
2. **Clé API** : générée depuis votre instance Postiz → *Settings → API Keys*
|
|
||||||
3. Appuyez sur **Test Connection** pour valider
|
|
||||||
4. Appuyez sur **Save Settings**
|
|
||||||
|
|
||||||
La clé est chiffrée et stockée localement via `expo-secure-store`. Elle n'est jamais envoyée à un service tiers.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Architecture du projet
|
|
||||||
|
|
||||||
```
|
|
||||||
artifacts/postiz-mobile/
|
|
||||||
├── app/
|
|
||||||
│ ├── _layout.tsx # Root layout : providers, fonts, notifications
|
|
||||||
│ └── (tabs)/
|
|
||||||
│ ├── _layout.tsx # Tab bar (NativeTabs iOS 26+ / Tabs classique)
|
|
||||||
│ ├── index.tsx # Écran Calendrier
|
|
||||||
│ ├── posts.tsx # Écran Liste des posts
|
|
||||||
│ ├── compose.tsx # Écran Composer
|
|
||||||
│ └── settings.tsx # Écran Paramètres
|
|
||||||
├── components/
|
|
||||||
│ ├── ChannelChip.tsx # Chip de sélection de canal
|
|
||||||
│ ├── ErrorBoundary.tsx # Gestionnaire d'erreurs global
|
|
||||||
│ ├── PostCard.tsx # Carte post avec swipe-to-delete
|
|
||||||
│ └── StatusBadge.tsx # Badge QUEUE / PUBLISHED / ERROR / DRAFT
|
|
||||||
├── constants/
|
|
||||||
│ └── colors.ts # Palette dark theme
|
|
||||||
├── context/
|
|
||||||
│ └── PostizContext.tsx # Client axios + SecureStore (apiKey, baseUrl)
|
|
||||||
├── hooks/
|
|
||||||
│ ├── useColors.ts # Tokens couleur selon le thème
|
|
||||||
│ └── useNotifications.ts # Permissions + polling + notifications locales
|
|
||||||
├── assets/
|
|
||||||
│ └── images/
|
|
||||||
│ └── icon.png # Icône générée par IA
|
|
||||||
└── app.json # Config Expo (permissions, plugins, thème)
|
|
||||||
```
|
|
||||||
|
|
||||||
### Dépendances principales
|
|
||||||
|
|
||||||
| Package | Usage |
|
|
||||||
|---------|-------|
|
|
||||||
| `expo-router` | Navigation file-based |
|
|
||||||
| `axios` | Client HTTP vers l'API Postiz |
|
|
||||||
| `expo-secure-store` | Stockage chiffré de la clé API |
|
|
||||||
| `react-native-calendars` | Vue calendrier mensuelle |
|
|
||||||
| `@react-native-community/datetimepicker` | Sélecteur date/heure dans Composer |
|
|
||||||
| `expo-image-picker` | Accès galerie photos |
|
|
||||||
| `expo-notifications` | Notifications locales de statut |
|
|
||||||
| `expo-task-manager` | Tâche de fond pour le polling |
|
|
||||||
| `@tanstack/react-query` | Cache et refetch des données API |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## API Postiz utilisée
|
|
||||||
|
|
||||||
Base URL configurée par l'utilisateur (ex. `https://postiz.example.com/public/v1`).
|
|
||||||
|
|
||||||
| Méthode | Endpoint | Usage |
|
|
||||||
|---------|----------|-------|
|
|
||||||
| `GET` | `/integrations` | Lister les canaux (Twitter, LinkedIn, etc.) |
|
|
||||||
| `GET` | `/posts?startDate=&endDate=` | Posts sur une plage de dates |
|
|
||||||
| `POST` | `/posts` | Créer / planifier un post |
|
|
||||||
| `DELETE` | `/posts/:id` | Supprimer un post |
|
|
||||||
| `POST` | `/upload` | Uploader une image (multipart) |
|
|
||||||
|
|
||||||
### Exemple de payload POST /posts
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"type": "schedule",
|
|
||||||
"date": "2025-01-15T10:00:00.000Z",
|
|
||||||
"content": [
|
|
||||||
{
|
|
||||||
"content": "Mon super post 🚀",
|
|
||||||
"image": [{ "id": "upload-id", "path": "/uploads/photo.jpg" }]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"integrations": ["integration-id-twitter", "integration-id-linkedin"]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Pour publier immédiatement, utilisez `"type": "now"`.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Build APK Android (EAS)
|
|
||||||
|
|
||||||
> **Prérequis** : compte gratuit sur [expo.dev](https://expo.dev) et `eas-cli` installé.
|
|
||||||
|
|
||||||
### 1. Se connecter à EAS
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npx eas login
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. Initialiser EAS dans le projet
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd artifacts/postiz-mobile
|
cd artifacts/postiz-mobile
|
||||||
npx eas init
|
./install-android-sdk.sh # first time only
|
||||||
|
cp ~/.config/postiz-mobile/signing.env.example ~/.config/postiz-mobile/signing.env
|
||||||
|
$EDITOR ~/.config/postiz-mobile/signing.env # fill in keystore credentials
|
||||||
|
./build-apk.sh # → dist/postiz-mobile-YYYYMMDD-HHMM.apk
|
||||||
```
|
```
|
||||||
|
|
||||||
Cela génère un `projectId` dans `app.json`.
|
### GitHub Actions release
|
||||||
|
|
||||||
### 3. Fichier de configuration EAS
|
Pushing a tag triggers an automated signed APK release:
|
||||||
|
|
||||||
> **Déjà inclus dans le dépôt** : `artifacts/postiz-mobile/eas.json` est présent, vous pouvez passer cette étape.
|
|
||||||
|
|
||||||
Si vous souhaitez le recréer manuellement :
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"cli": {
|
|
||||||
"version": ">= 16.0.0"
|
|
||||||
},
|
|
||||||
"build": {
|
|
||||||
"preview": {
|
|
||||||
"android": {
|
|
||||||
"buildType": "apk"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"production": {
|
|
||||||
"android": {
|
|
||||||
"buildType": "app-bundle"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"submit": {
|
|
||||||
"production": {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 4. Lancer le build APK
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# APK de test (sideload)
|
git tag v1.0.0
|
||||||
npx eas build --platform android --profile preview
|
git push origin --tags
|
||||||
|
|
||||||
# AAB pour le Play Store
|
|
||||||
npx eas build --platform android --profile production
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Le build se fait dans le cloud EAS (~10-15 min). À la fin, EAS affiche un **lien de téléchargement** et un **QR code** pour récupérer le fichier `.apk`.
|
The workflow builds the APK on GitHub's infrastructure and attaches it to a GitHub Release.
|
||||||
|
Required secrets: `KEYSTORE_B64`, `KEYSTORE_ALIAS`, `KEYSTORE_STORE_PASSWORD`, `KEYSTORE_KEY_PASSWORD`.
|
||||||
### 5. Installer l'APK sur votre téléphone
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Via adb
|
|
||||||
adb install postiz-mobile.apk
|
|
||||||
|
|
||||||
# Ou scannez le QR code affiché par EAS
|
|
||||||
```
|
|
||||||
|
|
||||||
### 6. Publier l'APK comme Release Gitea
|
|
||||||
|
|
||||||
Une fois le `.apk` téléchargé depuis EAS, attachez-le à une release Gitea pour le rendre disponible directement depuis le dépôt :
|
|
||||||
|
|
||||||
1. Allez sur `https://homegit.gyozamancave.fr/billisdead/Postiz-android/releases`
|
|
||||||
2. Cliquez **New Release**
|
|
||||||
3. Choisissez un tag (ex. `v1.0.0`) et un titre
|
|
||||||
4. Glissez-déposez le fichier `.apk` dans la zone de pièces jointes
|
|
||||||
5. Cliquez **Publish Release**
|
|
||||||
|
|
||||||
L'APK sera alors téléchargeable directement depuis la page du dépôt Gitea.
|
|
||||||
|
|
||||||
### Permissions Android déclarées
|
|
||||||
|
|
||||||
```xml
|
|
||||||
READ_EXTERNAL_STORAGE
|
|
||||||
WRITE_EXTERNAL_STORAGE
|
|
||||||
READ_MEDIA_IMAGES <!-- photos galerie -->
|
|
||||||
RECEIVE_BOOT_COMPLETED
|
|
||||||
VIBRATE <!-- notifications -->
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Build iOS (Expo Launch)
|
## App Configuration
|
||||||
|
|
||||||
> Disponible uniquement via **Replit Expo Launch** (soumission App Store automatisée).
|
On first launch, go to **Settings**:
|
||||||
|
|
||||||
1. Dans Replit, cliquez sur le bouton **Publish**
|
1. **Base URL**: `https://your-postiz-instance/api/public/v1`
|
||||||
2. Sélectionnez **Expo Launch**
|
2. **API Key**: generated in Postiz → Settings → API Keys
|
||||||
3. Suivez le wizard (compte Apple Developer requis)
|
3. Tap **Test Connection**, then **Save Settings**
|
||||||
|
|
||||||
**Note** : la publication Google Play n'est pas encore supportée par Expo Launch — utilisez EAS pour Android.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Pousser les modifications sur Gitea
|
## Postiz API
|
||||||
|
|
||||||
Le dépôt distant est : `ssh://gitea@homegit.gyozamancave.fr:2222/billisdead/Postiz-android.git`
|
| Method | Endpoint | Usage |
|
||||||
|
|--------|----------|-------|
|
||||||
La clé SSH utilisée est stockée dans la variable d'environnement `GITEA_SSH_KEY` (côté Replit).
|
| `GET` | `/integrations` | List channels |
|
||||||
|
| `GET` | `/posts?startDate=&endDate=` | Posts over a date range |
|
||||||
### Push depuis votre machine locale
|
| `POST` | `/posts` | Create / schedule a post |
|
||||||
|
| `DELETE` | `/posts/:id` | Delete a post |
|
||||||
```bash
|
| `POST` | `/upload` | Upload an image (multipart) |
|
||||||
# Ajouter le remote (une seule fois)
|
|
||||||
git remote add gitea ssh://gitea@homegit.gyozamancave.fr:2222/billisdead/Postiz-android.git
|
|
||||||
|
|
||||||
# Pousser
|
|
||||||
git push gitea main
|
|
||||||
```
|
|
||||||
|
|
||||||
Assurez-vous que votre clé SSH publique est ajoutée dans Gitea → *Paramètres utilisateur → SSH / GPG Keys*.
|
|
||||||
|
|
||||||
### Push depuis Replit (via script)
|
|
||||||
|
|
||||||
Depuis Replit, les commandes `git push` directes sont protégées. Utilisez le script de bundle :
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Créer le bundle
|
|
||||||
git bundle create /tmp/postiz.bundle main
|
|
||||||
|
|
||||||
# Cloner le bundle et pousser
|
|
||||||
git clone /tmp/postiz.bundle /tmp/repo_push
|
|
||||||
cd /tmp/repo_push
|
|
||||||
git remote add gitea ssh://gitea@homegit.gyozamancave.fr:2222/billisdead/Postiz-android.git
|
|
||||||
GIT_SSH_COMMAND="ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=no -p 2222" \
|
|
||||||
git push --force gitea main
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Variables d'environnement & secrets
|
## Troubleshooting
|
||||||
|
|
||||||
| Variable | Stockage | Description |
|
**"Not Configured" on all screens** → Settings tab → enter API key and URL → Test Connection.
|
||||||
|----------|----------|-------------|
|
|
||||||
| `GITEA_SSH_KEY` | Replit Secrets (shared) | Clé SSH privée pour push vers Gitea |
|
|
||||||
| `SESSION_SECRET` | Replit Secrets | Secret de session (API server) |
|
|
||||||
|
|
||||||
Les variables côté app (clé API Postiz, URL) sont **saisies par l'utilisateur** dans l'écran Paramètres et stockées dans `expo-secure-store` — elles ne transitent jamais dans le code source.
|
**"Connection failed"** → URL must end with `/api/public/v1` — check Postiz is reachable.
|
||||||
|
|
||||||
---
|
**No notifications** → Accept permissions on first launch. Polling runs every 15 min.
|
||||||
|
|
||||||
## Dépannage
|
**Build fails at Gradle** → Make sure `ANDROID_HOME` is set and Java is ≤ 24 (the script auto-detects `~/jdk21`).
|
||||||
|
|
||||||
### L'app affiche "Not Configured" sur tous les écrans
|
**`expo prebuild` fails** → Run `pnpm install` from the repo root first.
|
||||||
|
|
||||||
→ Allez dans l'onglet **Paramètres**, entrez votre clé API et URL, puis tapez **Test Connection**.
|
|
||||||
|
|
||||||
### "Connection failed" dans les Paramètres
|
|
||||||
|
|
||||||
- Vérifiez que l'URL se termine bien par `/public/v1`
|
|
||||||
- Vérifiez que la clé API est valide (générée dans Postiz → API Keys)
|
|
||||||
- Vérifiez que votre instance Postiz est accessible depuis internet
|
|
||||||
|
|
||||||
### Pas de notifications reçues
|
|
||||||
|
|
||||||
- Acceptez les permissions de notification au premier lancement
|
|
||||||
- Le polling se fait toutes les 15 minutes — attendez un cycle complet
|
|
||||||
- Sur Android, vérifiez que les notifications de l'app ne sont pas désactivées dans les paramètres système
|
|
||||||
|
|
||||||
### Erreur Metro "module not found"
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pnpm install
|
|
||||||
# Puis redémarrer le workflow Expo
|
|
||||||
```
|
|
||||||
|
|
||||||
### Le calendrier ne charge pas les posts
|
|
||||||
|
|
||||||
- Vérifiez que l'API Postiz supporte les paramètres `startDate` / `endDate` sur `GET /posts`
|
|
||||||
- Consultez les logs réseau : dans Expo Go, secouez l'appareil → *Open Debugger*
|
|
||||||
|
|
||||||
### Build EAS échoue
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Vérifier la version Expo
|
|
||||||
npx expo --version
|
|
||||||
|
|
||||||
# Vérifier la cohérence des packages
|
|
||||||
npx expo install --check
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Contribuer
|
|
||||||
|
|
||||||
1. Forkez sur Gitea : `https://homegit.gyozamancave.fr/billisdead/Postiz-android`
|
|
||||||
2. Créez une branche feature : `git checkout -b feature/ma-fonctionnalite`
|
|
||||||
3. Committez vos changements
|
|
||||||
4. Poussez et ouvrez une Pull Request
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
*Généré avec ❤️ sur Replit — PostizMobile v1.0.0*
|
|
||||||
|
|||||||
@@ -9,16 +9,20 @@ dist/
|
|||||||
web-build/
|
web-build/
|
||||||
expo-env.d.ts
|
expo-env.d.ts
|
||||||
|
|
||||||
# Native
|
# Native — generated by expo prebuild, never committed
|
||||||
ios/
|
ios/
|
||||||
android/
|
android/
|
||||||
*.orig.*
|
*.orig.*
|
||||||
*.jks
|
*.jks
|
||||||
|
*.keystore
|
||||||
*.p8
|
*.p8
|
||||||
*.p12
|
*.p12
|
||||||
*.key
|
*.key
|
||||||
*.mobileprovision
|
*.mobileprovision
|
||||||
|
|
||||||
|
# Local build output
|
||||||
|
static-build/
|
||||||
|
|
||||||
# Metro
|
# Metro
|
||||||
.metro-health-check*
|
.metro-health-check*
|
||||||
|
|
||||||
|
|||||||
+169
-308
@@ -1,367 +1,228 @@
|
|||||||
# PostizMobile
|
# PostizMobile
|
||||||
|
|
||||||
Application mobile React Native (Expo) pour piloter une instance **Postiz** auto-hébergée depuis votre téléphone Android ou iOS.
|
React Native (Expo) mobile app to control a self-hosted [Postiz](https://postiz.com) instance from Android.
|
||||||
|
|
||||||
|
Build is fully local — no expo.dev account or EAS cloud required.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Sommaire
|
## Features
|
||||||
|
|
||||||
1. [Fonctionnalités](#fonctionnalités)
|
| Screen | Description |
|
||||||
2. [Prérequis](#prérequis)
|
|--------|-------------|
|
||||||
3. [Installation & développement](#installation--développement)
|
| **Calendar** | Monthly view with color dots per day (indigo = scheduled, green = published, red = error). Tap a day post to copy or edit it. |
|
||||||
4. [Configuration de l'application](#configuration-de-lapplication)
|
| **Posts** | Filtered list (All / Queue / Published / Draft / Error) with post counts, sort toggle (newest/oldest, persisted), pull-to-refresh, swipe left to delete, swipe right to reschedule. |
|
||||||
5. [Architecture du projet](#architecture-du-projet)
|
| **Compose** | Text editor with per-network character limit, channel picker, date/time picker, gallery image pick + upload, publish now or schedule. Local draft save/restore. |
|
||||||
6. [API Postiz utilisée](#api-postiz-utilisée)
|
| **Settings** | API key and base URL, connection test, secure storage. 401 auto-redirect to Settings. |
|
||||||
7. [Build APK Android (EAS)](#build-apk-android-eas)
|
| **Notifications** | Local alerts when a post transitions to PUBLISHED or ERROR (polling every 15 min). |
|
||||||
8. [Build iOS (Expo Launch)](#build-ios-expo-launch)
|
|
||||||
9. [Pousser les modifications sur Gitea](#pousser-les-modifications-sur-gitea)
|
**Theme**: forced dark. **Auth**: API key in `expo-secure-store`, never hardcoded.
|
||||||
10. [Variables d'environnement & secrets](#variables-denvironnement--secrets)
|
|
||||||
11. [Dépannage](#dépannage)
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Fonctionnalités
|
## Prerequisites
|
||||||
|
|
||||||
| Écran | Description |
|
| Tool | Version |
|
||||||
|-------|-------------|
|
|------|---------|
|
||||||
| **Calendrier** | Vue mensuelle avec points de couleur par jour (indigo = planifié, vert = publié, rouge = erreur). Tap sur un jour pour voir les posts. |
|
|
||||||
| **Posts** | Liste filtrée (Tous / Queue / Publié / Brouillon / Erreur) avec pull-to-refresh et swipe gauche pour supprimer. |
|
|
||||||
| **Composer** | Éditeur de texte, sélecteur de canaux, date/heure, importation d'image galerie + upload, publier maintenant ou planifier. |
|
|
||||||
| **Paramètres** | Saisie de la clé API et de l'URL de base, test de connexion, sauvegarde sécurisée (SecureStore). |
|
|
||||||
| **Notifications** | Alertes locales automatiques quand un post passe à PUBLISHED ou ERROR (polling toutes les 15 minutes). |
|
|
||||||
|
|
||||||
**Thème** : dark forcé (`userInterfaceStyle: dark`).
|
|
||||||
**Authentification** : clé API stockée dans `expo-secure-store`, jamais en dur dans le code.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Prérequis
|
|
||||||
|
|
||||||
| Outil | Version minimale |
|
|
||||||
|-------|-----------------|
|
|
||||||
| Node.js | 20 LTS |
|
| Node.js | 20 LTS |
|
||||||
| pnpm | 10+ |
|
| pnpm | 10+ |
|
||||||
| Expo Go (téléphone) | SDK 54 compatible |
|
| Java (JDK) | 17–24 (Java 25+ not yet supported by Gradle 8) |
|
||||||
| Compte EAS (pour APK) | gratuit sur expo.dev |
|
| Android SDK | see below |
|
||||||
|
|
||||||
```bash
|
No expo.dev account needed for builds.
|
||||||
npm install -g pnpm
|
|
||||||
npm install -g eas-cli
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Installation & développement
|
## Development
|
||||||
|
|
||||||
### 1. Cloner le dépôt
|
### Install dependencies
|
||||||
|
|
||||||
```bash
|
|
||||||
git clone ssh://gitea@homegit.gyozamancave.fr:2222/billisdead/Postiz-android.git
|
|
||||||
cd Postiz-android
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. Installer les dépendances
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
git clone https://github.com/pirona/postiz-android.git
|
||||||
|
cd postiz-android
|
||||||
pnpm install
|
pnpm install
|
||||||
```
|
```
|
||||||
|
|
||||||
### 3. Lancer le serveur de développement
|
### Start dev server (Expo Go)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm --filter @workspace/postiz-mobile run dev
|
pnpm --filter @workspace/postiz-mobile run dev
|
||||||
```
|
```
|
||||||
|
|
||||||
Le terminal affiche un QR code. Scannez-le avec **Expo Go** (Android) ou l'app **Appareil photo** (iOS) pour voir l'app en direct.
|
Scan the QR code with Expo Go on Android to preview the app live.
|
||||||
|
|
||||||
### 4. Ouvrir dans le navigateur (web preview)
|
|
||||||
|
|
||||||
```
|
|
||||||
http://localhost:<PORT>
|
|
||||||
```
|
|
||||||
|
|
||||||
Le port est assigné dynamiquement par l'environnement Replit.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Configuration de l'application
|
## Building an APK (local, no EAS)
|
||||||
|
|
||||||
Au premier lancement, l'écran **Paramètres** s'affiche car aucune clé n'est configurée.
|
### First-time setup
|
||||||
|
|
||||||
1. **URL de base** : `https://votre-instance-postiz.fr/public/v1`
|
**1. Java 21 LTS**
|
||||||
2. **Clé API** : générée depuis votre instance Postiz → *Settings → API Keys*
|
|
||||||
3. Appuyez sur **Test Connection** pour valider
|
|
||||||
4. Appuyez sur **Save Settings**
|
|
||||||
|
|
||||||
La clé est chiffrée et stockée localement via `expo-secure-store`. Elle n'est jamais envoyée à un service tiers.
|
Gradle 8 requires Java ≤ 24. If the system Java is 25+ (Fedora 44), install Temurin 21 locally:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
wget -O /tmp/jdk21.tar.gz \
|
||||||
|
"https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.7%2B6/OpenJDK21U-jdk_x64_linux_hotspot_21.0.7_6.tar.gz"
|
||||||
|
mkdir -p ~/jdk21 && tar -xzf /tmp/jdk21.tar.gz -C ~/jdk21 --strip-components=1
|
||||||
|
```
|
||||||
|
|
||||||
|
`build-apk.sh` will use `~/jdk21` automatically if the system Java is ≥ 25.
|
||||||
|
|
||||||
|
**2. Android SDK**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd artifacts/postiz-mobile
|
||||||
|
./install-android-sdk.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Add to `~/.bashrc` or `~/.zshrc`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export ANDROID_HOME="$HOME/android-sdk"
|
||||||
|
export PATH="$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools/35.0.0"
|
||||||
|
```
|
||||||
|
|
||||||
|
**2. Signing keystore**
|
||||||
|
|
||||||
|
The release keystore is stored at `~/.config/postiz-mobile/postiz-mobile.jks` (not in the repo).
|
||||||
|
|
||||||
|
To export it from EAS (one-time):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd artifacts/postiz-mobile
|
||||||
|
eas credentials --platform android
|
||||||
|
# → Keystore: Manage everything → Download existing keystore
|
||||||
|
# Note the key alias and passwords shown during export
|
||||||
|
```
|
||||||
|
|
||||||
|
**3. Signing credentials**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cp ~/.config/postiz-mobile/signing.env.example ~/.config/postiz-mobile/signing.env
|
||||||
|
$EDITOR ~/.config/postiz-mobile/signing.env
|
||||||
|
```
|
||||||
|
|
||||||
|
Fill in:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
KEYSTORE_PATH="$HOME/.config/postiz-mobile/postiz-mobile.jks"
|
||||||
|
KEYSTORE_ALIAS="<alias shown during export>"
|
||||||
|
KEYSTORE_STORE_PASSWORD="<store password>"
|
||||||
|
KEYSTORE_KEY_PASSWORD="<key password>"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd artifacts/postiz-mobile
|
||||||
|
./build-apk.sh # → dist/postiz-mobile-YYYYMMDD-HHMM.apk
|
||||||
|
./build-apk.sh --aab # → dist/postiz-mobile-YYYYMMDD-HHMM.aab (Play Store)
|
||||||
|
```
|
||||||
|
|
||||||
|
The script runs `expo prebuild`, patches `android/app/build.gradle` for release signing, runs Gradle, copies the artifact to `dist/`, then wipes the credentials from `gradle.properties`.
|
||||||
|
|
||||||
|
### Install on device
|
||||||
|
|
||||||
|
```bash
|
||||||
|
adb install dist/postiz-mobile-*.apk
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Architecture du projet
|
## How the build works
|
||||||
|
|
||||||
|
```
|
||||||
|
build-apk.sh
|
||||||
|
├── source ~/.config/postiz-mobile/signing.env
|
||||||
|
├── expo prebuild --platform android --clean
|
||||||
|
│ └── generates android/ from app.json + plugins
|
||||||
|
├── python3 patch: injects release signingConfig into build.gradle
|
||||||
|
├── append MYAPP_UPLOAD_* to gradle.properties
|
||||||
|
├── ./gradlew assembleRelease (or bundleRelease)
|
||||||
|
├── wipe signing block from gradle.properties
|
||||||
|
└── copy APK → dist/
|
||||||
|
```
|
||||||
|
|
||||||
|
The `android/` directory is not committed (gitignored). It is regenerated on each build.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## App configuration
|
||||||
|
|
||||||
|
On first launch, go to **Settings**:
|
||||||
|
|
||||||
|
1. **Base URL**: `https://your-postiz-instance/api/public/v1`
|
||||||
|
2. **API Key**: generated in Postiz → Settings → API Keys
|
||||||
|
3. Tap **Test Connection**, then **Save Settings**
|
||||||
|
|
||||||
|
The key is encrypted locally via `expo-secure-store` and never sent to third parties.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
```
|
```
|
||||||
artifacts/postiz-mobile/
|
artifacts/postiz-mobile/
|
||||||
├── app/
|
├── app/
|
||||||
│ ├── _layout.tsx # Root layout : providers, fonts, notifications
|
│ ├── _layout.tsx # Root layout: providers, fonts, 401 handler
|
||||||
│ └── (tabs)/
|
│ └── (tabs)/
|
||||||
│ ├── _layout.tsx # Tab bar (NativeTabs iOS 26+ / Tabs classique)
|
│ ├── _layout.tsx # Tab bar
|
||||||
│ ├── index.tsx # Écran Calendrier
|
│ ├── index.tsx # Calendar screen
|
||||||
│ ├── posts.tsx # Écran Liste des posts
|
│ ├── posts.tsx # Post list screen
|
||||||
│ ├── compose.tsx # Écran Composer
|
│ ├── compose.tsx # Compose screen
|
||||||
│ └── settings.tsx # Écran Paramètres
|
│ └── settings.tsx # Settings screen
|
||||||
├── components/
|
├── components/
|
||||||
│ ├── ChannelChip.tsx # Chip de sélection de canal
|
│ ├── ChannelChip.tsx # Channel selector chip
|
||||||
│ ├── ErrorBoundary.tsx # Gestionnaire d'erreurs global
|
│ ├── ErrorBoundary.tsx
|
||||||
│ ├── PostCard.tsx # Carte post avec swipe-to-delete
|
│ ├── PostCard.tsx # Swipe-to-delete / swipe-to-reschedule
|
||||||
│ └── StatusBadge.tsx # Badge QUEUE / PUBLISHED / ERROR / DRAFT
|
│ └── StatusBadge.tsx
|
||||||
├── constants/
|
|
||||||
│ └── colors.ts # Palette dark theme
|
|
||||||
├── context/
|
├── context/
|
||||||
│ └── PostizContext.tsx # Client axios + SecureStore (apiKey, baseUrl)
|
│ └── PostizContext.tsx # axios client + SecureStore + 401 interceptor
|
||||||
├── hooks/
|
├── hooks/
|
||||||
│ ├── useColors.ts # Tokens couleur selon le thème
|
│ ├── useColors.ts
|
||||||
│ └── useNotifications.ts # Permissions + polling + notifications locales
|
│ └── useNotifications.ts # Permission + polling + local notifications
|
||||||
├── assets/
|
├── lib/
|
||||||
│ └── images/
|
│ └── extractError.ts # Shared axios/fetch error formatter
|
||||||
│ └── icon.png # Icône générée par IA
|
├── build-apk.sh # Local build script
|
||||||
└── app.json # Config Expo (permissions, plugins, thème)
|
└── install-android-sdk.sh # One-time Android SDK bootstrap
|
||||||
```
|
```
|
||||||
|
|
||||||
### Dépendances principales
|
### Key dependencies
|
||||||
|
|
||||||
| Package | Usage |
|
| Package | Role |
|
||||||
|---------|-------|
|
|---------|------|
|
||||||
| `expo-router` | Navigation file-based |
|
| `expo-router` | File-based navigation |
|
||||||
| `axios` | Client HTTP vers l'API Postiz |
|
| `axios` | Postiz API HTTP client |
|
||||||
| `expo-secure-store` | Stockage chiffré de la clé API |
|
| `expo-secure-store` | Encrypted key storage |
|
||||||
| `react-native-calendars` | Vue calendrier mensuelle |
|
| `react-native-calendars` | Calendar view |
|
||||||
| `@react-native-community/datetimepicker` | Sélecteur date/heure dans Composer |
|
| `@react-native-community/datetimepicker` | Date/time picker |
|
||||||
| `expo-image-picker` | Accès galerie photos |
|
| `expo-image-picker` | Gallery access |
|
||||||
| `expo-notifications` | Notifications locales de statut |
|
| `expo-notifications` | Local status notifications |
|
||||||
| `expo-task-manager` | Tâche de fond pour le polling |
|
| `@tanstack/react-query` | API cache + refetch |
|
||||||
| `@tanstack/react-query` | Cache et refetch des données API |
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## API Postiz utilisée
|
## Postiz API
|
||||||
|
|
||||||
Base URL configurée par l'utilisateur (ex. `https://postiz.example.com/public/v1`).
|
| Method | Endpoint | Usage |
|
||||||
|
|--------|----------|-------|
|
||||||
| Méthode | Endpoint | Usage |
|
| `GET` | `/integrations` | List channels |
|
||||||
|---------|----------|-------|
|
| `GET` | `/posts?startDate=&endDate=` | Posts over a date range |
|
||||||
| `GET` | `/integrations` | Lister les canaux (Twitter, LinkedIn, etc.) |
|
| `POST` | `/posts` | Create / schedule a post |
|
||||||
| `GET` | `/posts?startDate=&endDate=` | Posts sur une plage de dates |
|
| `DELETE` | `/posts/:id` | Delete a post |
|
||||||
| `POST` | `/posts` | Créer / planifier un post |
|
| `POST` | `/upload` | Upload an image (multipart) |
|
||||||
| `DELETE` | `/posts/:id` | Supprimer un post |
|
|
||||||
| `POST` | `/upload` | Uploader une image (multipart) |
|
|
||||||
|
|
||||||
### Exemple de payload POST /posts
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"type": "schedule",
|
|
||||||
"date": "2025-01-15T10:00:00.000Z",
|
|
||||||
"content": [
|
|
||||||
{
|
|
||||||
"content": "Mon super post 🚀",
|
|
||||||
"image": [{ "id": "upload-id", "path": "/uploads/photo.jpg" }]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"integrations": ["integration-id-twitter", "integration-id-linkedin"]
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Pour publier immédiatement, utilisez `"type": "now"`.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Build APK Android (EAS)
|
## Troubleshooting
|
||||||
|
|
||||||
> **Prérequis** : compte gratuit sur [expo.dev](https://expo.dev) et `eas-cli` installé.
|
**"Not Configured" on all screens** → Settings tab → enter API key and URL → Test Connection.
|
||||||
|
|
||||||
### 1. Se connecter à EAS
|
**"Connection failed"** → URL must end with `/api/public/v1` — check Postiz is reachable.
|
||||||
|
|
||||||
```bash
|
**No notifications** → Accept permissions on first launch. Polling runs every 15 min.
|
||||||
npx eas login
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2. Initialiser EAS dans le projet
|
**Build fails at Gradle** → Make sure `ANDROID_HOME` is set and `./gradlew` is executable (`chmod +x android/gradlew`).
|
||||||
|
|
||||||
```bash
|
**`expo prebuild` fails** → Run `pnpm install` from the repo root first.
|
||||||
cd artifacts/postiz-mobile
|
|
||||||
npx eas init
|
|
||||||
```
|
|
||||||
|
|
||||||
Cela génère un `projectId` dans `app.json`.
|
|
||||||
|
|
||||||
### 3. Créer le fichier de configuration EAS
|
|
||||||
|
|
||||||
Créez `artifacts/postiz-mobile/eas.json` :
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"cli": {
|
|
||||||
"version": ">= 16.0.0"
|
|
||||||
},
|
|
||||||
"build": {
|
|
||||||
"preview": {
|
|
||||||
"android": {
|
|
||||||
"buildType": "apk"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"production": {
|
|
||||||
"android": {
|
|
||||||
"buildType": "app-bundle"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"submit": {
|
|
||||||
"production": {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### 4. Lancer le build APK
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# APK de test (sideload)
|
|
||||||
npx eas build --platform android --profile preview
|
|
||||||
|
|
||||||
# AAB pour le Play Store
|
|
||||||
npx eas build --platform android --profile production
|
|
||||||
```
|
|
||||||
|
|
||||||
Le build se fait dans le cloud EAS. Vous recevez un lien de téléchargement à la fin (~10-15 min).
|
|
||||||
|
|
||||||
### 5. Installer l'APK sur votre téléphone
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Via adb
|
|
||||||
adb install postiz-mobile.apk
|
|
||||||
|
|
||||||
# Ou scannez le QR code affiché par EAS
|
|
||||||
```
|
|
||||||
|
|
||||||
### Permissions Android déclarées
|
|
||||||
|
|
||||||
```xml
|
|
||||||
READ_EXTERNAL_STORAGE
|
|
||||||
WRITE_EXTERNAL_STORAGE
|
|
||||||
READ_MEDIA_IMAGES <!-- photos galerie -->
|
|
||||||
RECEIVE_BOOT_COMPLETED
|
|
||||||
VIBRATE <!-- notifications -->
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Build iOS (Expo Launch)
|
|
||||||
|
|
||||||
> Disponible uniquement via **Replit Expo Launch** (soumission App Store automatisée).
|
|
||||||
|
|
||||||
1. Dans Replit, cliquez sur le bouton **Publish**
|
|
||||||
2. Sélectionnez **Expo Launch**
|
|
||||||
3. Suivez le wizard (compte Apple Developer requis)
|
|
||||||
|
|
||||||
**Note** : la publication Google Play n'est pas encore supportée par Expo Launch — utilisez EAS pour Android.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Pousser les modifications sur Gitea
|
|
||||||
|
|
||||||
Le dépôt distant est : `ssh://gitea@homegit.gyozamancave.fr:2222/billisdead/Postiz-android.git`
|
|
||||||
|
|
||||||
La clé SSH utilisée est stockée dans la variable d'environnement `GITEA_SSH_KEY` (côté Replit).
|
|
||||||
|
|
||||||
### Push depuis votre machine locale
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Ajouter le remote (une seule fois)
|
|
||||||
git remote add gitea ssh://gitea@homegit.gyozamancave.fr:2222/billisdead/Postiz-android.git
|
|
||||||
|
|
||||||
# Pousser
|
|
||||||
git push gitea main
|
|
||||||
```
|
|
||||||
|
|
||||||
Assurez-vous que votre clé SSH publique est ajoutée dans Gitea → *Paramètres utilisateur → SSH / GPG Keys*.
|
|
||||||
|
|
||||||
### Push depuis Replit (via script)
|
|
||||||
|
|
||||||
Depuis Replit, les commandes `git push` directes sont protégées. Utilisez le script de bundle :
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Créer le bundle
|
|
||||||
git bundle create /tmp/postiz.bundle main
|
|
||||||
|
|
||||||
# Cloner le bundle et pousser
|
|
||||||
git clone /tmp/postiz.bundle /tmp/repo_push
|
|
||||||
cd /tmp/repo_push
|
|
||||||
git remote add gitea ssh://gitea@homegit.gyozamancave.fr:2222/billisdead/Postiz-android.git
|
|
||||||
GIT_SSH_COMMAND="ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=no -p 2222" \
|
|
||||||
git push --force gitea main
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Variables d'environnement & secrets
|
|
||||||
|
|
||||||
| Variable | Stockage | Description |
|
|
||||||
|----------|----------|-------------|
|
|
||||||
| `GITEA_SSH_KEY` | Replit Secrets (shared) | Clé SSH privée pour push vers Gitea |
|
|
||||||
| `SESSION_SECRET` | Replit Secrets | Secret de session (API server) |
|
|
||||||
|
|
||||||
Les variables côté app (clé API Postiz, URL) sont **saisies par l'utilisateur** dans l'écran Paramètres et stockées dans `expo-secure-store` — elles ne transitent jamais dans le code source.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Dépannage
|
|
||||||
|
|
||||||
### L'app affiche "Not Configured" sur tous les écrans
|
|
||||||
|
|
||||||
→ Allez dans l'onglet **Paramètres**, entrez votre clé API et URL, puis tapez **Test Connection**.
|
|
||||||
|
|
||||||
### "Connection failed" dans les Paramètres
|
|
||||||
|
|
||||||
- Vérifiez que l'URL se termine bien par `/public/v1`
|
|
||||||
- Vérifiez que la clé API est valide (générée dans Postiz → API Keys)
|
|
||||||
- Vérifiez que votre instance Postiz est accessible depuis internet
|
|
||||||
|
|
||||||
### Pas de notifications reçues
|
|
||||||
|
|
||||||
- Acceptez les permissions de notification au premier lancement
|
|
||||||
- Le polling se fait toutes les 15 minutes — attendez un cycle complet
|
|
||||||
- Sur Android, vérifiez que les notifications de l'app ne sont pas désactivées dans les paramètres système
|
|
||||||
|
|
||||||
### Erreur Metro "module not found"
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pnpm install
|
|
||||||
# Puis redémarrer le workflow Expo
|
|
||||||
```
|
|
||||||
|
|
||||||
### Le calendrier ne charge pas les posts
|
|
||||||
|
|
||||||
- Vérifiez que l'API Postiz supporte les paramètres `startDate` / `endDate` sur `GET /posts`
|
|
||||||
- Consultez les logs réseau : dans Expo Go, secouez l'appareil → *Open Debugger*
|
|
||||||
|
|
||||||
### Build EAS échoue
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Vérifier la version Expo
|
|
||||||
npx expo --version
|
|
||||||
|
|
||||||
# Vérifier la cohérence des packages
|
|
||||||
npx expo install --check
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Contribuer
|
|
||||||
|
|
||||||
1. Forkez sur Gitea : `https://homegit.gyozamancave.fr/billisdead/Postiz-android`
|
|
||||||
2. Créez une branche feature : `git checkout -b feature/ma-fonctionnalite`
|
|
||||||
3. Committez vos changements
|
|
||||||
4. Poussez et ouvrez une Pull Request
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
*Généré avec ❤️ sur Replit — PostizMobile v1.0.0*
|
|
||||||
|
|||||||
@@ -23,23 +23,19 @@
|
|||||||
"android": {
|
"android": {
|
||||||
"package": "fr.gyozamancave.postizmobile",
|
"package": "fr.gyozamancave.postizmobile",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"READ_EXTERNAL_STORAGE",
|
"android.permission.READ_EXTERNAL_STORAGE",
|
||||||
"WRITE_EXTERNAL_STORAGE",
|
"android.permission.WRITE_EXTERNAL_STORAGE",
|
||||||
"READ_MEDIA_IMAGES",
|
"android.permission.READ_MEDIA_IMAGES",
|
||||||
"RECEIVE_BOOT_COMPLETED",
|
"android.permission.RECEIVE_BOOT_COMPLETED",
|
||||||
"VIBRATE"
|
"android.permission.VIBRATE",
|
||||||
|
"android.permission.RECORD_AUDIO"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"web": {
|
"web": {
|
||||||
"favicon": "./assets/images/icon.png"
|
"favicon": "./assets/images/icon.png"
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
[
|
|
||||||
"expo-router",
|
"expo-router",
|
||||||
{
|
|
||||||
"origin": "https://replit.com/"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"expo-font",
|
"expo-font",
|
||||||
"expo-web-browser",
|
"expo-web-browser",
|
||||||
"expo-image-picker",
|
"expo-image-picker",
|
||||||
@@ -56,6 +52,11 @@
|
|||||||
"experiments": {
|
"experiments": {
|
||||||
"typedRoutes": true,
|
"typedRoutes": true,
|
||||||
"reactCompiler": true
|
"reactCompiler": true
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"eas": {
|
||||||
|
"projectId": "aeaaa2bd-3a27-4771-8e39-f2e14fe0e030"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
import { Feather } from "@expo/vector-icons";
|
import { Feather } from "@expo/vector-icons";
|
||||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import DateTimePicker from "@react-native-community/datetimepicker";
|
import DateTimePicker from "@react-native-community/datetimepicker";
|
||||||
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||||
import * as Haptics from "expo-haptics";
|
import * as Haptics from "expo-haptics";
|
||||||
import { Image } from "expo-image";
|
import { Image } from "expo-image";
|
||||||
|
import * as ImageManipulator from "expo-image-manipulator";
|
||||||
import * as ImagePicker from "expo-image-picker";
|
import * as ImagePicker from "expo-image-picker";
|
||||||
import { fetch as expoFetch } from "expo/fetch";
|
import { fetch as expoFetch } from "expo/fetch";
|
||||||
import React, { useState } from "react";
|
import { useLocalSearchParams } from "expo-router";
|
||||||
|
import React, { useEffect, useState } from "react";
|
||||||
import {
|
import {
|
||||||
ActivityIndicator,
|
ActivityIndicator,
|
||||||
Alert,
|
Alert,
|
||||||
@@ -21,14 +24,45 @@ import {
|
|||||||
import { KeyboardAwareScrollView } from "react-native-keyboard-controller";
|
import { KeyboardAwareScrollView } from "react-native-keyboard-controller";
|
||||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||||
import { ChannelChip } from "@/components/ChannelChip";
|
import { ChannelChip } from "@/components/ChannelChip";
|
||||||
|
import { MediaLibraryModal } from "@/components/MediaLibraryModal";
|
||||||
import { PostizIntegration, PostizUploadResult, usePostiz } from "@/context/PostizContext";
|
import { PostizIntegration, PostizUploadResult, usePostiz } from "@/context/PostizContext";
|
||||||
import { useColors } from "@/hooks/useColors";
|
import { useColors } from "@/hooks/useColors";
|
||||||
|
|
||||||
|
const DRAFT_STORAGE_KEY = "postiz_local_draft";
|
||||||
|
const MAX_IMAGES = 4;
|
||||||
|
|
||||||
|
const NETWORK_CHAR_LIMITS: Record<string, number> = {
|
||||||
|
twitter: 280, x: 280,
|
||||||
|
instagram: 2200,
|
||||||
|
linkedin: 3000,
|
||||||
|
facebook: 63206,
|
||||||
|
youtube: 5000,
|
||||||
|
tiktok: 2200,
|
||||||
|
};
|
||||||
|
|
||||||
|
type MediaItem =
|
||||||
|
| { type: "local"; uri: string }
|
||||||
|
| { type: "uploaded"; id: string; path: string };
|
||||||
|
|
||||||
|
function resolveMediaUrl(path: string, baseUrl: string): string {
|
||||||
|
if (path.startsWith("http://") || path.startsWith("https://")) return path;
|
||||||
|
const origin = baseUrl.replace(/\/api\/.*$/, "");
|
||||||
|
return `${origin}/${path.replace(/^\//, "")}`;
|
||||||
|
}
|
||||||
|
|
||||||
export default function ComposeScreen() {
|
export default function ComposeScreen() {
|
||||||
const colors = useColors();
|
const colors = useColors();
|
||||||
const insets = useSafeAreaInsets();
|
const insets = useSafeAreaInsets();
|
||||||
const { client, isConfigured, apiKey, baseUrl } = usePostiz();
|
const { client, isConfigured, apiKey, baseUrl } = usePostiz();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
const { prefillContent, prefillIntegrationIds, prefillImagePath, prefillImageId } =
|
||||||
|
useLocalSearchParams<{
|
||||||
|
prefillContent?: string;
|
||||||
|
prefillIntegrationIds?: string;
|
||||||
|
prefillImagePath?: string;
|
||||||
|
prefillImageId?: string;
|
||||||
|
}>();
|
||||||
|
|
||||||
const [content, setContent] = useState("");
|
const [content, setContent] = useState("");
|
||||||
const [selectedChannels, setSelectedChannels] = useState<string[]>([]);
|
const [selectedChannels, setSelectedChannels] = useState<string[]>([]);
|
||||||
const [postNow, setPostNow] = useState(false);
|
const [postNow, setPostNow] = useState(false);
|
||||||
@@ -37,9 +71,32 @@ export default function ComposeScreen() {
|
|||||||
);
|
);
|
||||||
const [showDatePicker, setShowDatePicker] = useState(false);
|
const [showDatePicker, setShowDatePicker] = useState(false);
|
||||||
const [showTimePicker, setShowTimePicker] = useState(false);
|
const [showTimePicker, setShowTimePicker] = useState(false);
|
||||||
const [imageUri, setImageUri] = useState<string | null>(null);
|
const [mediaItems, setMediaItems] = useState<MediaItem[]>([]);
|
||||||
|
const [showMediaLibrary, setShowMediaLibrary] = useState(false);
|
||||||
const [uploading, setUploading] = useState(false);
|
const [uploading, setUploading] = useState(false);
|
||||||
const [submitting, setSubmitting] = useState(false);
|
const [submitting, setSubmitting] = useState(false);
|
||||||
|
const [draftBanner, setDraftBanner] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (prefillContent) setContent(String(prefillContent));
|
||||||
|
if (prefillIntegrationIds) {
|
||||||
|
setSelectedChannels(String(prefillIntegrationIds).split(",").filter(Boolean));
|
||||||
|
}
|
||||||
|
if (prefillImagePath && prefillImageId) {
|
||||||
|
setMediaItems([{ type: "uploaded", id: String(prefillImageId), path: String(prefillImagePath) }]);
|
||||||
|
}
|
||||||
|
}, [prefillContent, prefillIntegrationIds, prefillImagePath, prefillImageId]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (prefillContent) return;
|
||||||
|
AsyncStorage.getItem(DRAFT_STORAGE_KEY).then((raw) => {
|
||||||
|
if (!raw) return;
|
||||||
|
try {
|
||||||
|
const draft = JSON.parse(raw);
|
||||||
|
if (draft?.content) setDraftBanner(true);
|
||||||
|
} catch {}
|
||||||
|
});
|
||||||
|
}, [prefillContent]);
|
||||||
|
|
||||||
const { data: integrations, isLoading: loadingIntegrations } =
|
const { data: integrations, isLoading: loadingIntegrations } =
|
||||||
useQuery<PostizIntegration[]>({
|
useQuery<PostizIntegration[]>({
|
||||||
@@ -53,6 +110,37 @@ export default function ComposeScreen() {
|
|||||||
staleTime: 60000,
|
staleTime: 60000,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const effectiveCharLimit = (() => {
|
||||||
|
if (selectedChannels.length === 0 || !integrations) return 3000;
|
||||||
|
const selected = integrations.filter((i) => selectedChannels.includes(i.id));
|
||||||
|
const limits = selected.map((i) => {
|
||||||
|
const t = (i.type ?? i.internalType ?? "").toLowerCase();
|
||||||
|
for (const [key, limit] of Object.entries(NETWORK_CHAR_LIMITS)) {
|
||||||
|
if (t.includes(key)) return limit;
|
||||||
|
}
|
||||||
|
return 3000;
|
||||||
|
});
|
||||||
|
return Math.min(...limits);
|
||||||
|
})();
|
||||||
|
|
||||||
|
const saveDraft = async () => {
|
||||||
|
const draft = { content, integrationIds: selectedChannels };
|
||||||
|
await AsyncStorage.setItem(DRAFT_STORAGE_KEY, JSON.stringify(draft));
|
||||||
|
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
|
||||||
|
Alert.alert("Draft saved", "Your draft has been saved locally.");
|
||||||
|
};
|
||||||
|
|
||||||
|
const restoreDraft = async () => {
|
||||||
|
const raw = await AsyncStorage.getItem(DRAFT_STORAGE_KEY);
|
||||||
|
if (!raw) return;
|
||||||
|
try {
|
||||||
|
const draft = JSON.parse(raw);
|
||||||
|
if (draft.content) setContent(draft.content);
|
||||||
|
if (draft.integrationIds?.length) setSelectedChannels(draft.integrationIds);
|
||||||
|
setDraftBanner(false);
|
||||||
|
} catch {}
|
||||||
|
};
|
||||||
|
|
||||||
const toggleChannel = (id: string) => {
|
const toggleChannel = (id: string) => {
|
||||||
setSelectedChannels((prev) =>
|
setSelectedChannels((prev) =>
|
||||||
prev.includes(id) ? prev.filter((c) => c !== id) : [...prev, id]
|
prev.includes(id) ? prev.filter((c) => c !== id) : [...prev, id]
|
||||||
@@ -60,34 +148,68 @@ export default function ComposeScreen() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const pickImage = async () => {
|
const pickImage = async () => {
|
||||||
|
if (mediaItems.length >= MAX_IMAGES) {
|
||||||
|
Alert.alert("Max images", `You can add up to ${MAX_IMAGES} images per post.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const { status } = await ImagePicker.requestMediaLibraryPermissionsAsync();
|
const { status } = await ImagePicker.requestMediaLibraryPermissionsAsync();
|
||||||
if (status !== "granted") {
|
if (status !== "granted") {
|
||||||
Alert.alert("Permission required", "Allow access to your photo library.");
|
Alert.alert("Permission required", "Allow access to your photo library.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const remaining = MAX_IMAGES - mediaItems.length;
|
||||||
const result = await ImagePicker.launchImageLibraryAsync({
|
const result = await ImagePicker.launchImageLibraryAsync({
|
||||||
mediaTypes: ["images"],
|
mediaTypes: ["images"],
|
||||||
|
allowsMultipleSelection: true,
|
||||||
|
selectionLimit: remaining,
|
||||||
allowsEditing: false,
|
allowsEditing: false,
|
||||||
quality: 0.85,
|
quality: 1,
|
||||||
});
|
});
|
||||||
if (!result.canceled && result.assets[0]) {
|
if (!result.canceled && result.assets.length > 0) {
|
||||||
setImageUri(result.assets[0].uri);
|
const MAX_DIM = 1920;
|
||||||
|
const processed: string[] = [];
|
||||||
|
for (const asset of result.assets) {
|
||||||
|
const w = asset.width ?? 0;
|
||||||
|
const h = asset.height ?? 0;
|
||||||
|
if (w > MAX_DIM || h > MAX_DIM) {
|
||||||
|
const landscape = w >= h;
|
||||||
|
const resized = await ImageManipulator.manipulateAsync(
|
||||||
|
asset.uri,
|
||||||
|
[{ resize: landscape ? { width: MAX_DIM } : { height: MAX_DIM } }],
|
||||||
|
{ compress: 0.85, format: ImageManipulator.SaveFormat.JPEG }
|
||||||
|
);
|
||||||
|
processed.push(resized.uri);
|
||||||
|
} else {
|
||||||
|
processed.push(asset.uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setMediaItems((prev) =>
|
||||||
|
[...prev, ...processed.map((uri): MediaItem => ({ type: "local", uri }))].slice(0, MAX_IMAGES)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeImage = () => setImageUri(null);
|
const removeMediaItem = (index: number) => {
|
||||||
|
setMediaItems((prev) => prev.filter((_, i) => i !== index));
|
||||||
|
};
|
||||||
|
|
||||||
const uploadImage = async (): Promise<PostizUploadResult> => {
|
const buildMediaPayload = async (): Promise<Array<{ id: string; path: string }>> => {
|
||||||
setUploading(true);
|
setUploading(true);
|
||||||
try {
|
try {
|
||||||
|
const result: Array<{ id: string; path: string }> = [];
|
||||||
|
for (const item of mediaItems) {
|
||||||
|
if (item.type === "uploaded") {
|
||||||
|
result.push({ id: item.id, path: item.path });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
if (Platform.OS === "web") {
|
if (Platform.OS === "web") {
|
||||||
const response = await expoFetch(imageUri!);
|
const response = await expoFetch(item.uri);
|
||||||
const blob = await response.blob();
|
const blob = await response.blob();
|
||||||
formData.append("file", blob, "upload.jpg");
|
formData.append("file", blob, "upload.jpg");
|
||||||
} else {
|
} else {
|
||||||
formData.append("file", {
|
formData.append("file", {
|
||||||
uri: imageUri!,
|
uri: item.uri,
|
||||||
name: "upload.jpg",
|
name: "upload.jpg",
|
||||||
type: "image/jpeg",
|
type: "image/jpeg",
|
||||||
} as unknown as Blob);
|
} as unknown as Blob);
|
||||||
@@ -102,7 +224,10 @@ export default function ComposeScreen() {
|
|||||||
const raw = await uploadRes.text().catch(() => uploadRes.statusText);
|
const raw = await uploadRes.text().catch(() => uploadRes.statusText);
|
||||||
throw new Error(`Upload HTTP ${uploadRes.status}: ${raw.slice(0, 200)}`);
|
throw new Error(`Upload HTTP ${uploadRes.status}: ${raw.slice(0, 200)}`);
|
||||||
}
|
}
|
||||||
return await uploadRes.json() as PostizUploadResult;
|
const uploaded = (await uploadRes.json()) as PostizUploadResult;
|
||||||
|
result.push({ id: uploaded.id, path: uploaded.path });
|
||||||
|
}
|
||||||
|
return result;
|
||||||
} finally {
|
} finally {
|
||||||
setUploading(false);
|
setUploading(false);
|
||||||
}
|
}
|
||||||
@@ -121,11 +246,7 @@ export default function ComposeScreen() {
|
|||||||
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium);
|
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium);
|
||||||
setSubmitting(true);
|
setSubmitting(true);
|
||||||
try {
|
try {
|
||||||
let media: Array<{ id: string; path: string }> = [];
|
const media = mediaItems.length > 0 ? await buildMediaPayload() : [];
|
||||||
if (imageUri) {
|
|
||||||
const uploaded = await uploadImage();
|
|
||||||
media = [{ id: uploaded.id, path: uploaded.path }];
|
|
||||||
}
|
|
||||||
const payload = {
|
const payload = {
|
||||||
type: postNow ? "now" : "schedule",
|
type: postNow ? "now" : "schedule",
|
||||||
date: postNow ? new Date().toISOString() : scheduleDate.toISOString(),
|
date: postNow ? new Date().toISOString() : scheduleDate.toISOString(),
|
||||||
@@ -133,18 +254,16 @@ export default function ComposeScreen() {
|
|||||||
tags: [] as string[],
|
tags: [] as string[],
|
||||||
posts: selectedChannels.map((integrationId) => ({
|
posts: selectedChannels.map((integrationId) => ({
|
||||||
integration: { id: integrationId },
|
integration: { id: integrationId },
|
||||||
value: [{ content: content.trim(), id: "", image: media }],
|
value: [{ content: content.trim(), image: media }],
|
||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
const body = JSON.stringify(payload);
|
const body = JSON.stringify(payload);
|
||||||
|
console.log("[compose] POST", `${baseUrl}/posts`, body);
|
||||||
|
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
const res = await globalThis.fetch(`${baseUrl}/posts`, {
|
const res = await globalThis.fetch(`${baseUrl}/posts`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: { Authorization: apiKey, "Content-Type": "application/json" },
|
||||||
Authorization: apiKey,
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
body,
|
body,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -152,7 +271,8 @@ export default function ComposeScreen() {
|
|||||||
let detail = "";
|
let detail = "";
|
||||||
try {
|
try {
|
||||||
const raw = await res.text();
|
const raw = await res.text();
|
||||||
detail = raw.slice(0, 300);
|
console.log("[compose] error body:", raw);
|
||||||
|
detail = raw.slice(0, 500);
|
||||||
} catch {
|
} catch {
|
||||||
detail = res.statusText;
|
detail = res.statusText;
|
||||||
}
|
}
|
||||||
@@ -160,6 +280,7 @@ export default function ComposeScreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
|
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
|
||||||
|
await AsyncStorage.removeItem(DRAFT_STORAGE_KEY);
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
"Posted!",
|
"Posted!",
|
||||||
postNow ? "Your post has been published." : "Post scheduled successfully.",
|
postNow ? "Your post has been published." : "Post scheduled successfully.",
|
||||||
@@ -180,16 +301,13 @@ export default function ComposeScreen() {
|
|||||||
setContent("");
|
setContent("");
|
||||||
setSelectedChannels([]);
|
setSelectedChannels([]);
|
||||||
setPostNow(false);
|
setPostNow(false);
|
||||||
setImageUri(null);
|
setMediaItems([]);
|
||||||
|
setDraftBanner(false);
|
||||||
setScheduleDate(new Date(Date.now() + 60 * 60 * 1000));
|
setScheduleDate(new Date(Date.now() + 60 * 60 * 1000));
|
||||||
};
|
};
|
||||||
|
|
||||||
const formatDateLabel = (d: Date) =>
|
const formatDateLabel = (d: Date) =>
|
||||||
d.toLocaleDateString("en-US", {
|
d.toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" });
|
||||||
month: "short",
|
|
||||||
day: "numeric",
|
|
||||||
year: "numeric",
|
|
||||||
});
|
|
||||||
|
|
||||||
const formatTimeLabel = (d: Date) =>
|
const formatTimeLabel = (d: Date) =>
|
||||||
d.toLocaleTimeString("en-US", { hour: "2-digit", minute: "2-digit" });
|
d.toLocaleTimeString("en-US", { hour: "2-digit", minute: "2-digit" });
|
||||||
@@ -198,17 +316,14 @@ export default function ComposeScreen() {
|
|||||||
return (
|
return (
|
||||||
<View style={[styles.centered, { backgroundColor: colors.background }]}>
|
<View style={[styles.centered, { backgroundColor: colors.background }]}>
|
||||||
<Feather name="lock" size={32} color={colors.mutedForeground} />
|
<Feather name="lock" size={32} color={colors.mutedForeground} />
|
||||||
<Text style={[styles.sectionTitle, { color: colors.foreground }]}>
|
<Text style={[styles.sectionTitle, { color: colors.foreground }]}>Not Configured</Text>
|
||||||
Not Configured
|
<Text style={[styles.hint, { color: colors.mutedForeground }]}>Add your API key in Settings</Text>
|
||||||
</Text>
|
|
||||||
<Text style={[styles.hint, { color: colors.mutedForeground }]}>
|
|
||||||
Add your API key in Settings
|
|
||||||
</Text>
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<KeyboardAwareScrollView
|
<KeyboardAwareScrollView
|
||||||
style={{ flex: 1, backgroundColor: colors.background }}
|
style={{ flex: 1, backgroundColor: colors.background }}
|
||||||
contentContainerStyle={[
|
contentContainerStyle={[
|
||||||
@@ -222,12 +337,20 @@ export default function ComposeScreen() {
|
|||||||
keyboardShouldPersistTaps="handled"
|
keyboardShouldPersistTaps="handled"
|
||||||
showsVerticalScrollIndicator={false}
|
showsVerticalScrollIndicator={false}
|
||||||
>
|
>
|
||||||
<View
|
{draftBanner && (
|
||||||
style={[
|
<View style={[styles.draftBanner, { backgroundColor: colors.card, borderColor: colors.border }]}>
|
||||||
styles.textArea,
|
<Feather name="file-text" size={14} color={colors.primary} />
|
||||||
{ backgroundColor: colors.card, borderColor: colors.border },
|
<Text style={[styles.draftBannerText, { color: colors.foreground }]}>You have a saved draft</Text>
|
||||||
]}
|
<TouchableOpacity onPress={restoreDraft} activeOpacity={0.7}>
|
||||||
>
|
<Text style={[styles.draftBannerAction, { color: colors.primary }]}>Restore</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
<TouchableOpacity onPress={() => setDraftBanner(false)} activeOpacity={0.7}>
|
||||||
|
<Feather name="x" size={14} color={colors.mutedForeground} />
|
||||||
|
</TouchableOpacity>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<View style={[styles.textArea, { backgroundColor: colors.card, borderColor: colors.border }]}>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={[styles.textInput, { color: colors.foreground }]}
|
style={[styles.textInput, { color: colors.foreground }]}
|
||||||
placeholder="What do you want to post?"
|
placeholder="What do you want to post?"
|
||||||
@@ -235,47 +358,92 @@ export default function ComposeScreen() {
|
|||||||
multiline
|
multiline
|
||||||
value={content}
|
value={content}
|
||||||
onChangeText={setContent}
|
onChangeText={setContent}
|
||||||
maxLength={3000}
|
maxLength={effectiveCharLimit}
|
||||||
textAlignVertical="top"
|
textAlignVertical="top"
|
||||||
/>
|
/>
|
||||||
<Text style={[styles.charCount, { color: colors.mutedForeground }]}>
|
<View style={styles.charCountRow}>
|
||||||
{content.length}/3000
|
{effectiveCharLimit < 3000 && selectedChannels.length > 0 && (
|
||||||
|
<Text style={[styles.charCountLabel, { color: colors.mutedForeground }]}>
|
||||||
|
limit: {effectiveCharLimit}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
styles.charCount,
|
||||||
|
{
|
||||||
|
color:
|
||||||
|
content.length >= effectiveCharLimit
|
||||||
|
? colors.error
|
||||||
|
: content.length > effectiveCharLimit * 0.9
|
||||||
|
? colors.warning
|
||||||
|
: colors.mutedForeground,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
{content.length}/{effectiveCharLimit}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
</View>
|
||||||
|
|
||||||
{imageUri && (
|
{mediaItems.length > 0 && (
|
||||||
<View style={styles.imagePreviewWrap}>
|
<ScrollView
|
||||||
|
horizontal
|
||||||
|
showsHorizontalScrollIndicator={false}
|
||||||
|
contentContainerStyle={styles.imageRow}
|
||||||
|
>
|
||||||
|
{mediaItems.map((item, idx) => {
|
||||||
|
const uri =
|
||||||
|
item.type === "local"
|
||||||
|
? item.uri
|
||||||
|
: resolveMediaUrl(item.path, baseUrl);
|
||||||
|
return (
|
||||||
|
<View key={idx} style={styles.imageThumbWrap}>
|
||||||
<Image
|
<Image
|
||||||
source={{ uri: imageUri }}
|
source={{ uri }}
|
||||||
style={[styles.imagePreview, { borderColor: colors.border }]}
|
style={[styles.imageThumb, { borderColor: colors.border }]}
|
||||||
contentFit="cover"
|
contentFit="cover"
|
||||||
/>
|
/>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={removeImage}
|
onPress={() => removeMediaItem(idx)}
|
||||||
style={[styles.removeImg, { backgroundColor: colors.destructive }]}
|
style={[styles.removeImg, { backgroundColor: colors.destructive }]}
|
||||||
>
|
>
|
||||||
<Feather name="x" size={12} color="#fff" />
|
<Feather name="x" size={12} color="#fff" />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
{item.type === "uploaded" && (
|
||||||
|
<View style={[styles.uploadedBadge, { backgroundColor: colors.success }]}>
|
||||||
|
<Feather name="cloud" size={8} color="#fff" />
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</ScrollView>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{mediaItems.length < MAX_IMAGES && (
|
||||||
|
<View style={styles.mediaBtnsRow}>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={pickImage}
|
onPress={pickImage}
|
||||||
activeOpacity={0.7}
|
activeOpacity={0.7}
|
||||||
style={[
|
style={[styles.mediaBtn, { backgroundColor: colors.card, borderColor: colors.border }]}
|
||||||
styles.mediaBtn,
|
|
||||||
{ backgroundColor: colors.card, borderColor: colors.border },
|
|
||||||
]}
|
|
||||||
>
|
>
|
||||||
<Feather name="image" size={16} color={colors.mutedForeground} />
|
<Feather name="image" size={16} color={colors.mutedForeground} />
|
||||||
<Text style={[styles.mediaBtnText, { color: colors.mutedForeground }]}>
|
<Text style={[styles.mediaBtnText, { color: colors.mutedForeground }]}>
|
||||||
{imageUri ? "Change image" : "Add image"}
|
{mediaItems.length === 0 ? "Add image" : "Add more"}
|
||||||
</Text>
|
</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={() => setShowMediaLibrary(true)}
|
||||||
|
activeOpacity={0.7}
|
||||||
|
style={[styles.mediaBtn, { backgroundColor: colors.card, borderColor: colors.border }]}
|
||||||
|
>
|
||||||
|
<Feather name="folder" size={16} color={colors.mutedForeground} />
|
||||||
|
<Text style={[styles.mediaBtnText, { color: colors.mutedForeground }]}>Library</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
<Text style={[styles.sectionLabel, { color: colors.mutedForeground }]}>
|
<Text style={[styles.sectionLabel, { color: colors.mutedForeground }]}>CHANNELS</Text>
|
||||||
CHANNELS
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
{loadingIntegrations ? (
|
{loadingIntegrations ? (
|
||||||
<ActivityIndicator color={colors.primary} style={{ marginVertical: 8 }} />
|
<ActivityIndicator color={colors.primary} style={{ marginVertical: 8 }} />
|
||||||
@@ -300,17 +468,10 @@ export default function ComposeScreen() {
|
|||||||
</ScrollView>
|
</ScrollView>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<View
|
<View style={[styles.scheduleRow, { backgroundColor: colors.card, borderColor: colors.border }]}>
|
||||||
style={[
|
|
||||||
styles.scheduleRow,
|
|
||||||
{ backgroundColor: colors.card, borderColor: colors.border },
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<View style={styles.scheduleRowLeft}>
|
<View style={styles.scheduleRowLeft}>
|
||||||
<Feather name="zap" size={16} color={colors.primary} />
|
<Feather name="zap" size={16} color={colors.primary} />
|
||||||
<Text style={[styles.scheduleLabel, { color: colors.foreground }]}>
|
<Text style={[styles.scheduleLabel, { color: colors.foreground }]}>Post now</Text>
|
||||||
Post now
|
|
||||||
</Text>
|
|
||||||
</View>
|
</View>
|
||||||
<Switch
|
<Switch
|
||||||
value={postNow}
|
value={postNow}
|
||||||
@@ -323,14 +484,8 @@ export default function ComposeScreen() {
|
|||||||
{!postNow && (
|
{!postNow && (
|
||||||
<View style={styles.dateTimeRow}>
|
<View style={styles.dateTimeRow}>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={() => {
|
onPress={() => { setShowTimePicker(false); setShowDatePicker((v) => !v); }}
|
||||||
setShowTimePicker(false);
|
style={[styles.dateBtn, { backgroundColor: colors.card, borderColor: colors.border }]}
|
||||||
setShowDatePicker((v) => !v);
|
|
||||||
}}
|
|
||||||
style={[
|
|
||||||
styles.dateBtn,
|
|
||||||
{ backgroundColor: colors.card, borderColor: colors.border },
|
|
||||||
]}
|
|
||||||
activeOpacity={0.7}
|
activeOpacity={0.7}
|
||||||
>
|
>
|
||||||
<Feather name="calendar" size={14} color={colors.primary} />
|
<Feather name="calendar" size={14} color={colors.primary} />
|
||||||
@@ -339,14 +494,8 @@ export default function ComposeScreen() {
|
|||||||
</Text>
|
</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={() => {
|
onPress={() => { setShowDatePicker(false); setShowTimePicker((v) => !v); }}
|
||||||
setShowDatePicker(false);
|
style={[styles.dateBtn, { backgroundColor: colors.card, borderColor: colors.border }]}
|
||||||
setShowTimePicker((v) => !v);
|
|
||||||
}}
|
|
||||||
style={[
|
|
||||||
styles.dateBtn,
|
|
||||||
{ backgroundColor: colors.card, borderColor: colors.border },
|
|
||||||
]}
|
|
||||||
activeOpacity={0.7}
|
activeOpacity={0.7}
|
||||||
>
|
>
|
||||||
<Feather name="clock" size={14} color={colors.primary} />
|
<Feather name="clock" size={14} color={colors.primary} />
|
||||||
@@ -394,27 +543,30 @@ export default function ComposeScreen() {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={saveDraft}
|
||||||
|
activeOpacity={0.7}
|
||||||
|
disabled={submitting || uploading || !content.trim()}
|
||||||
|
style={[styles.draftBtn, { backgroundColor: colors.card, borderColor: colors.border }]}
|
||||||
|
>
|
||||||
|
<Feather name="file-text" size={14} color={colors.mutedForeground} />
|
||||||
|
<Text style={[styles.draftBtnText, { color: colors.mutedForeground }]}>Save Draft</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={handleSubmit}
|
onPress={handleSubmit}
|
||||||
activeOpacity={0.85}
|
activeOpacity={0.85}
|
||||||
disabled={submitting || uploading}
|
disabled={submitting || uploading}
|
||||||
style={[
|
style={[
|
||||||
styles.submitBtn,
|
styles.submitBtn,
|
||||||
{
|
{ backgroundColor: submitting || uploading ? colors.muted : colors.primary },
|
||||||
backgroundColor:
|
|
||||||
submitting || uploading ? colors.muted : colors.primary,
|
|
||||||
},
|
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{submitting || uploading ? (
|
{submitting || uploading ? (
|
||||||
<ActivityIndicator color={colors.primaryForeground} size="small" />
|
<ActivityIndicator color={colors.primaryForeground} size="small" />
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Feather
|
<Feather name={postNow ? "send" : "clock"} size={16} color={colors.primaryForeground} />
|
||||||
name={postNow ? "send" : "clock"}
|
|
||||||
size={16}
|
|
||||||
color={colors.primaryForeground}
|
|
||||||
/>
|
|
||||||
<Text style={[styles.submitText, { color: colors.primaryForeground }]}>
|
<Text style={[styles.submitText, { color: colors.primaryForeground }]}>
|
||||||
{postNow ? "Publish Now" : "Schedule Post"}
|
{postNow ? "Publish Now" : "Schedule Post"}
|
||||||
</Text>
|
</Text>
|
||||||
@@ -422,139 +574,55 @@ export default function ComposeScreen() {
|
|||||||
)}
|
)}
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</KeyboardAwareScrollView>
|
</KeyboardAwareScrollView>
|
||||||
|
|
||||||
|
<MediaLibraryModal
|
||||||
|
visible={showMediaLibrary}
|
||||||
|
baseUrl={baseUrl}
|
||||||
|
apiKey={apiKey}
|
||||||
|
maxSelect={MAX_IMAGES - mediaItems.length}
|
||||||
|
onClose={() => setShowMediaLibrary(false)}
|
||||||
|
onSelect={(items) => {
|
||||||
|
setMediaItems((prev) =>
|
||||||
|
[...prev, ...items.map((i): MediaItem => ({ type: "uploaded", id: i.id, path: i.path }))].slice(0, MAX_IMAGES)
|
||||||
|
);
|
||||||
|
setShowMediaLibrary(false);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: { paddingHorizontal: 16, gap: 14 },
|
||||||
paddingHorizontal: 16,
|
centered: { flex: 1, alignItems: "center", justifyContent: "center", gap: 10 },
|
||||||
gap: 14,
|
textArea: { borderRadius: 14, borderWidth: 1, padding: 14, minHeight: 140 },
|
||||||
},
|
textInput: { fontSize: 15, fontFamily: "Inter_400Regular", lineHeight: 22, minHeight: 100 },
|
||||||
centered: {
|
charCountRow: { flexDirection: "row", justifyContent: "flex-end", alignItems: "center", gap: 6, marginTop: 4 },
|
||||||
flex: 1,
|
charCountLabel: { fontSize: 10, fontFamily: "Inter_400Regular" },
|
||||||
alignItems: "center",
|
charCount: { fontSize: 11, fontFamily: "Inter_400Regular" },
|
||||||
justifyContent: "center",
|
draftBanner: { flexDirection: "row", alignItems: "center", gap: 8, paddingHorizontal: 14, paddingVertical: 10, borderRadius: 12, borderWidth: 1 },
|
||||||
gap: 10,
|
draftBannerText: { flex: 1, fontSize: 13, fontFamily: "Inter_400Regular" },
|
||||||
},
|
draftBannerAction: { fontSize: 13, fontFamily: "Inter_600SemiBold" },
|
||||||
textArea: {
|
draftBtn: { flexDirection: "row", alignItems: "center", justifyContent: "center", gap: 6, paddingVertical: 10, borderRadius: 12, borderWidth: 1 },
|
||||||
borderRadius: 14,
|
draftBtnText: { fontSize: 13, fontFamily: "Inter_500Medium" },
|
||||||
borderWidth: 1,
|
imageRow: { gap: 10, paddingRight: 4 },
|
||||||
padding: 14,
|
imageThumbWrap: { position: "relative" },
|
||||||
minHeight: 140,
|
imageThumb: { width: 100, height: 100, borderRadius: 10, borderWidth: 1 },
|
||||||
},
|
removeImg: { position: "absolute", top: 4, right: 4, width: 20, height: 20, borderRadius: 10, alignItems: "center", justifyContent: "center" },
|
||||||
textInput: {
|
uploadedBadge: { position: "absolute", bottom: 4, left: 4, width: 16, height: 16, borderRadius: 8, alignItems: "center", justifyContent: "center" },
|
||||||
fontSize: 15,
|
mediaBtnsRow: { flexDirection: "row", gap: 8 },
|
||||||
fontFamily: "Inter_400Regular",
|
mediaBtn: { flexDirection: "row", alignItems: "center", gap: 8, paddingHorizontal: 14, paddingVertical: 10, borderRadius: 10, borderWidth: 1 },
|
||||||
lineHeight: 22,
|
mediaBtnText: { fontSize: 13, fontFamily: "Inter_500Medium" },
|
||||||
minHeight: 100,
|
sectionLabel: { fontSize: 11, fontFamily: "Inter_600SemiBold", letterSpacing: 0.8, marginBottom: -6 },
|
||||||
},
|
sectionTitle: { fontSize: 18, fontFamily: "Inter_600SemiBold" },
|
||||||
charCount: {
|
hint: { fontSize: 13, fontFamily: "Inter_400Regular", textAlign: "center" },
|
||||||
fontSize: 11,
|
channelList: { flexDirection: "row", gap: 8, flexWrap: "wrap" },
|
||||||
fontFamily: "Inter_400Regular",
|
scheduleRow: { flexDirection: "row", alignItems: "center", justifyContent: "space-between", paddingHorizontal: 16, paddingVertical: 12, borderRadius: 12, borderWidth: 1 },
|
||||||
alignSelf: "flex-end",
|
scheduleRowLeft: { flexDirection: "row", alignItems: "center", gap: 10 },
|
||||||
marginTop: 4,
|
scheduleLabel: { fontSize: 15, fontFamily: "Inter_500Medium" },
|
||||||
},
|
dateTimeRow: { flexDirection: "row", gap: 10 },
|
||||||
imagePreviewWrap: {
|
dateBtn: { flex: 1, flexDirection: "row", alignItems: "center", gap: 8, paddingHorizontal: 12, paddingVertical: 10, borderRadius: 10, borderWidth: 1 },
|
||||||
position: "relative",
|
dateBtnText: { fontSize: 13, fontFamily: "Inter_500Medium" },
|
||||||
alignSelf: "flex-start",
|
submitBtn: { flexDirection: "row", alignItems: "center", justifyContent: "center", gap: 8, paddingVertical: 14, borderRadius: 14, marginTop: 4 },
|
||||||
},
|
submitText: { fontSize: 15, fontFamily: "Inter_600SemiBold" },
|
||||||
imagePreview: {
|
|
||||||
width: 120,
|
|
||||||
height: 120,
|
|
||||||
borderRadius: 10,
|
|
||||||
borderWidth: 1,
|
|
||||||
},
|
|
||||||
removeImg: {
|
|
||||||
position: "absolute",
|
|
||||||
top: 4,
|
|
||||||
right: 4,
|
|
||||||
width: 20,
|
|
||||||
height: 20,
|
|
||||||
borderRadius: 10,
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "center",
|
|
||||||
},
|
|
||||||
mediaBtn: {
|
|
||||||
flexDirection: "row",
|
|
||||||
alignItems: "center",
|
|
||||||
gap: 8,
|
|
||||||
paddingHorizontal: 14,
|
|
||||||
paddingVertical: 10,
|
|
||||||
borderRadius: 10,
|
|
||||||
borderWidth: 1,
|
|
||||||
alignSelf: "flex-start",
|
|
||||||
},
|
|
||||||
mediaBtnText: {
|
|
||||||
fontSize: 13,
|
|
||||||
fontFamily: "Inter_500Medium",
|
|
||||||
},
|
|
||||||
sectionLabel: {
|
|
||||||
fontSize: 11,
|
|
||||||
fontFamily: "Inter_600SemiBold",
|
|
||||||
letterSpacing: 0.8,
|
|
||||||
marginBottom: -6,
|
|
||||||
},
|
|
||||||
sectionTitle: {
|
|
||||||
fontSize: 18,
|
|
||||||
fontFamily: "Inter_600SemiBold",
|
|
||||||
},
|
|
||||||
hint: {
|
|
||||||
fontSize: 13,
|
|
||||||
fontFamily: "Inter_400Regular",
|
|
||||||
textAlign: "center",
|
|
||||||
},
|
|
||||||
channelList: {
|
|
||||||
flexDirection: "row",
|
|
||||||
gap: 8,
|
|
||||||
flexWrap: "wrap",
|
|
||||||
},
|
|
||||||
scheduleRow: {
|
|
||||||
flexDirection: "row",
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "space-between",
|
|
||||||
paddingHorizontal: 16,
|
|
||||||
paddingVertical: 12,
|
|
||||||
borderRadius: 12,
|
|
||||||
borderWidth: 1,
|
|
||||||
},
|
|
||||||
scheduleRowLeft: {
|
|
||||||
flexDirection: "row",
|
|
||||||
alignItems: "center",
|
|
||||||
gap: 10,
|
|
||||||
},
|
|
||||||
scheduleLabel: {
|
|
||||||
fontSize: 15,
|
|
||||||
fontFamily: "Inter_500Medium",
|
|
||||||
},
|
|
||||||
dateTimeRow: {
|
|
||||||
flexDirection: "row",
|
|
||||||
gap: 10,
|
|
||||||
},
|
|
||||||
dateBtn: {
|
|
||||||
flex: 1,
|
|
||||||
flexDirection: "row",
|
|
||||||
alignItems: "center",
|
|
||||||
gap: 8,
|
|
||||||
paddingHorizontal: 12,
|
|
||||||
paddingVertical: 10,
|
|
||||||
borderRadius: 10,
|
|
||||||
borderWidth: 1,
|
|
||||||
},
|
|
||||||
dateBtnText: {
|
|
||||||
fontSize: 13,
|
|
||||||
fontFamily: "Inter_500Medium",
|
|
||||||
},
|
|
||||||
submitBtn: {
|
|
||||||
flexDirection: "row",
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "center",
|
|
||||||
gap: 8,
|
|
||||||
paddingVertical: 14,
|
|
||||||
borderRadius: 14,
|
|
||||||
marginTop: 4,
|
|
||||||
},
|
|
||||||
submitText: {
|
|
||||||
fontSize: 15,
|
|
||||||
fontFamily: "Inter_600SemiBold",
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import { Feather } from "@expo/vector-icons";
|
import { Feather } from "@expo/vector-icons";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import axios from "axios";
|
import * as Clipboard from "expo-clipboard";
|
||||||
|
import * as Haptics from "expo-haptics";
|
||||||
import { router } from "expo-router";
|
import { router } from "expo-router";
|
||||||
import React, { useMemo, useState } from "react";
|
import React, { useMemo, useState } from "react";
|
||||||
import {
|
import {
|
||||||
ActivityIndicator,
|
ActivityIndicator,
|
||||||
|
Alert,
|
||||||
FlatList,
|
FlatList,
|
||||||
Platform,
|
Platform,
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
@@ -17,24 +19,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|||||||
import { PostizPost, usePostiz } from "@/context/PostizContext";
|
import { PostizPost, usePostiz } from "@/context/PostizContext";
|
||||||
import { useColors } from "@/hooks/useColors";
|
import { useColors } from "@/hooks/useColors";
|
||||||
import { StatusBadge } from "@/components/StatusBadge";
|
import { StatusBadge } from "@/components/StatusBadge";
|
||||||
|
import { extractError } from "@/lib/extractError";
|
||||||
function extractError(err: unknown): string {
|
|
||||||
if (axios.isAxiosError(err)) {
|
|
||||||
const status = err.response?.status;
|
|
||||||
const data = err.response?.data;
|
|
||||||
if (data) {
|
|
||||||
const body =
|
|
||||||
typeof data === "string"
|
|
||||||
? data.slice(0, 200)
|
|
||||||
: (data?.message ?? data?.error ?? JSON.stringify(data)).toString().slice(0, 200);
|
|
||||||
return status ? `HTTP ${status}: ${body}` : body;
|
|
||||||
}
|
|
||||||
if (status) return `HTTP ${status} — ${err.message}`;
|
|
||||||
if (err.message) return err.message;
|
|
||||||
}
|
|
||||||
if (err instanceof Error) return err.message;
|
|
||||||
return "Unknown error";
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatDate(date: Date): string {
|
function formatDate(date: Date): string {
|
||||||
const y = date.getFullYear();
|
const y = date.getFullYear();
|
||||||
@@ -65,6 +50,39 @@ export default function CalendarScreen() {
|
|||||||
const insets = useSafeAreaInsets();
|
const insets = useSafeAreaInsets();
|
||||||
const { client, isConfigured } = usePostiz();
|
const { client, isConfigured } = usePostiz();
|
||||||
|
|
||||||
|
const showContextMenu = (post: PostizPost) => {
|
||||||
|
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium);
|
||||||
|
const preview = post.content.slice(0, 60) + (post.content.length > 60 ? "…" : "");
|
||||||
|
const integrations = post.integrations ?? (post.integration ? [post.integration] : []);
|
||||||
|
Alert.alert(
|
||||||
|
post.state === "PUBLISHED" ? "Published post" :
|
||||||
|
post.state === "QUEUE" ? "Scheduled post" :
|
||||||
|
post.state === "ERROR" ? "Failed post" : "Draft",
|
||||||
|
preview,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
text: "Copy text",
|
||||||
|
onPress: () => {
|
||||||
|
Clipboard.setStringAsync(post.content);
|
||||||
|
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: post.state === "PUBLISHED" ? "Repost" : "Edit",
|
||||||
|
onPress: () =>
|
||||||
|
router.push({
|
||||||
|
pathname: "/(tabs)/compose",
|
||||||
|
params: {
|
||||||
|
prefillContent: post.content,
|
||||||
|
prefillIntegrationIds: integrations.map((i) => i.id).join(","),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{ text: "Cancel", style: "cancel" },
|
||||||
|
]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const [currentMonth, setCurrentMonth] = useState({
|
const [currentMonth, setCurrentMonth] = useState({
|
||||||
year: now.getFullYear(),
|
year: now.getFullYear(),
|
||||||
@@ -255,6 +273,7 @@ export default function CalendarScreen() {
|
|||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={[styles.dayPost, { borderBottomColor: colors.border }]}
|
style={[styles.dayPost, { borderBottomColor: colors.border }]}
|
||||||
activeOpacity={0.7}
|
activeOpacity={0.7}
|
||||||
|
onPress={() => showContextMenu(item)}
|
||||||
>
|
>
|
||||||
<View style={styles.dayPostLeft}>
|
<View style={styles.dayPostLeft}>
|
||||||
<Text style={[styles.timeText, { color: colors.primary }]}>
|
<Text style={[styles.timeText, { color: colors.primary }]}>
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import { Feather } from "@expo/vector-icons";
|
import { Feather } from "@expo/vector-icons";
|
||||||
|
import DateTimePicker from "@react-native-community/datetimepicker";
|
||||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import axios from "axios";
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||||
import React, { useMemo, useState } from "react";
|
import * as Clipboard from "expo-clipboard";
|
||||||
|
import * as Haptics from "expo-haptics";
|
||||||
|
import { useRouter } from "expo-router";
|
||||||
|
import React, { useEffect, useMemo, useState } from "react";
|
||||||
import {
|
import {
|
||||||
ActivityIndicator,
|
ActivityIndicator,
|
||||||
Alert,
|
Alert,
|
||||||
@@ -17,24 +21,10 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|||||||
import { PostCard } from "@/components/PostCard";
|
import { PostCard } from "@/components/PostCard";
|
||||||
import { PostizPost, usePostiz } from "@/context/PostizContext";
|
import { PostizPost, usePostiz } from "@/context/PostizContext";
|
||||||
import { useColors } from "@/hooks/useColors";
|
import { useColors } from "@/hooks/useColors";
|
||||||
|
import { extractError } from "@/lib/extractError";
|
||||||
|
import { stripHtml } from "@/lib/stripHtml";
|
||||||
|
|
||||||
function extractError(err: unknown): string {
|
const SORT_STORAGE_KEY = "postiz_posts_sort";
|
||||||
if (axios.isAxiosError(err)) {
|
|
||||||
const status = err.response?.status;
|
|
||||||
const data = err.response?.data;
|
|
||||||
if (data) {
|
|
||||||
const body =
|
|
||||||
typeof data === "string"
|
|
||||||
? data.slice(0, 200)
|
|
||||||
: (data?.message ?? data?.error ?? JSON.stringify(data)).toString().slice(0, 200);
|
|
||||||
return status ? `HTTP ${status}: ${body}` : body;
|
|
||||||
}
|
|
||||||
if (status) return `HTTP ${status} — ${err.message}`;
|
|
||||||
if (err.message) return err.message;
|
|
||||||
}
|
|
||||||
if (err instanceof Error) return err.message;
|
|
||||||
return "Unknown error";
|
|
||||||
}
|
|
||||||
|
|
||||||
type FilterType = "all" | "QUEUE" | "PUBLISHED" | "ERROR" | "DRAFT";
|
type FilterType = "all" | "QUEUE" | "PUBLISHED" | "ERROR" | "DRAFT";
|
||||||
|
|
||||||
@@ -51,8 +41,28 @@ export default function PostsScreen() {
|
|||||||
const insets = useSafeAreaInsets();
|
const insets = useSafeAreaInsets();
|
||||||
const { client, isConfigured } = usePostiz();
|
const { client, isConfigured } = usePostiz();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
const router = useRouter();
|
||||||
const [filter, setFilter] = useState<FilterType>("all");
|
const [filter, setFilter] = useState<FilterType>("all");
|
||||||
|
const [sortOrder, setSortOrder] = useState<"desc" | "asc">("desc");
|
||||||
const [refreshing, setRefreshing] = useState(false);
|
const [refreshing, setRefreshing] = useState(false);
|
||||||
|
const [copyToast, setCopyToast] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
AsyncStorage.getItem(SORT_STORAGE_KEY).then((v) => {
|
||||||
|
if (v === "asc" || v === "desc") setSortOrder(v);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const toggleSort = () => {
|
||||||
|
const next = sortOrder === "desc" ? "asc" : "desc";
|
||||||
|
setSortOrder(next);
|
||||||
|
AsyncStorage.setItem(SORT_STORAGE_KEY, next);
|
||||||
|
};
|
||||||
|
|
||||||
|
// reschedule state
|
||||||
|
const [reschedulePost, setReschedulePost] = useState<PostizPost | null>(null);
|
||||||
|
const [rescheduleDate, setRescheduleDate] = useState(new Date());
|
||||||
|
const [rescheduleStep, setRescheduleStep] = useState<"date" | "time" | null>(null);
|
||||||
|
|
||||||
const { startDate, endDate } = useMemo(() => {
|
const { startDate, endDate } = useMemo(() => {
|
||||||
const s = new Date();
|
const s = new Date();
|
||||||
@@ -76,10 +86,27 @@ export default function PostsScreen() {
|
|||||||
staleTime: 0,
|
staleTime: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
const filteredPosts =
|
const filteredPosts = useMemo(() => {
|
||||||
|
const list =
|
||||||
filter === "all"
|
filter === "all"
|
||||||
? posts ?? []
|
? posts ?? []
|
||||||
: (posts ?? []).filter((p) => p.state === filter);
|
: (posts ?? []).filter((p) => p.state === filter);
|
||||||
|
return [...list].sort((a, b) => {
|
||||||
|
const diff = new Date(a.publishDate).getTime() - new Date(b.publishDate).getTime();
|
||||||
|
return sortOrder === "desc" ? -diff : diff;
|
||||||
|
});
|
||||||
|
}, [posts, filter, sortOrder]);
|
||||||
|
|
||||||
|
const filterCounts = useMemo(() => {
|
||||||
|
const all = posts ?? [];
|
||||||
|
return {
|
||||||
|
all: all.length,
|
||||||
|
QUEUE: all.filter((p) => p.state === "QUEUE").length,
|
||||||
|
PUBLISHED: all.filter((p) => p.state === "PUBLISHED").length,
|
||||||
|
DRAFT: all.filter((p) => p.state === "DRAFT").length,
|
||||||
|
ERROR: all.filter((p) => p.state === "ERROR").length,
|
||||||
|
};
|
||||||
|
}, [posts]);
|
||||||
|
|
||||||
const handleRefresh = async () => {
|
const handleRefresh = async () => {
|
||||||
setRefreshing(true);
|
setRefreshing(true);
|
||||||
@@ -99,6 +126,118 @@ export default function PostsScreen() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleRetry = async (post: PostizPost) => {
|
||||||
|
if (!client) return;
|
||||||
|
const integrations = post.integrations ?? (post.integration ? [post.integration] : []);
|
||||||
|
try {
|
||||||
|
const payload = {
|
||||||
|
type: "now",
|
||||||
|
date: new Date().toISOString(),
|
||||||
|
shortLink: false,
|
||||||
|
tags: [] as string[],
|
||||||
|
posts: integrations.map((intg) => ({
|
||||||
|
integration: { id: intg.id },
|
||||||
|
value: [{ content: post.content, id: "", image: post.image ?? [] }],
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
await client.post("posts", payload);
|
||||||
|
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["posts-list"] });
|
||||||
|
Alert.alert("Retried", "Post submitted again.");
|
||||||
|
} catch (e: unknown) {
|
||||||
|
const msg = extractError(e);
|
||||||
|
Alert.alert("Retry failed", msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlePrefillCompose = (post: PostizPost) => {
|
||||||
|
const integrations = post.integrations ?? (post.integration ? [post.integration] : []);
|
||||||
|
router.push({
|
||||||
|
pathname: "/(tabs)/compose",
|
||||||
|
params: {
|
||||||
|
prefillContent: stripHtml(post.content),
|
||||||
|
prefillIntegrationIds: integrations.map((i) => i.id).join(","),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const startReschedule = (post: PostizPost) => {
|
||||||
|
setReschedulePost(post);
|
||||||
|
setRescheduleDate(new Date(post.publishDate));
|
||||||
|
setRescheduleStep("date");
|
||||||
|
};
|
||||||
|
|
||||||
|
const submitReschedule = async (post: PostizPost, date: Date) => {
|
||||||
|
if (!client) return;
|
||||||
|
const integrations = post.integrations ?? (post.integration ? [post.integration] : []);
|
||||||
|
try {
|
||||||
|
await client.delete(`posts/${post.id}`);
|
||||||
|
await client.post("posts", {
|
||||||
|
type: "schedule",
|
||||||
|
date: date.toISOString(),
|
||||||
|
shortLink: false,
|
||||||
|
tags: [] as string[],
|
||||||
|
posts: integrations.map((intg) => ({
|
||||||
|
integration: { id: intg.id },
|
||||||
|
value: [{ content: post.content, image: post.image ?? [] }],
|
||||||
|
})),
|
||||||
|
});
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["posts-list"] });
|
||||||
|
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
|
||||||
|
Alert.alert("Rescheduled", `Post moved to ${date.toLocaleDateString("en-US", { month: "short", day: "numeric", hour: "2-digit", minute: "2-digit" })}`);
|
||||||
|
} catch (e: unknown) {
|
||||||
|
const msg = extractError(e);
|
||||||
|
Alert.alert("Reschedule failed", msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const showContextMenu = (post: PostizPost) => {
|
||||||
|
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium);
|
||||||
|
|
||||||
|
const plain = stripHtml(post.content);
|
||||||
|
const preview = plain.slice(0, 60) + (plain.length > 60 ? "…" : "");
|
||||||
|
|
||||||
|
const buttons: Array<{ text: string; style?: "cancel" | "destructive" | "default"; onPress?: () => void }> = [];
|
||||||
|
|
||||||
|
buttons.push({
|
||||||
|
text: "Copy text",
|
||||||
|
onPress: async () => {
|
||||||
|
await Clipboard.setStringAsync(stripHtml(post.content));
|
||||||
|
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
|
||||||
|
setCopyToast(true);
|
||||||
|
setTimeout(() => setCopyToast(false), 2000);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (post.state === "ERROR") {
|
||||||
|
if (post.errorMessage) {
|
||||||
|
buttons.push({
|
||||||
|
text: "View error",
|
||||||
|
onPress: () => Alert.alert("Error details", post.errorMessage),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
buttons.push({ text: "Retry now", onPress: () => handleRetry(post) });
|
||||||
|
buttons.push({ text: "Edit & retry", onPress: () => handlePrefillCompose(post) });
|
||||||
|
} else if (post.state === "QUEUE") {
|
||||||
|
buttons.push({ text: "Edit", onPress: () => handlePrefillCompose(post) });
|
||||||
|
buttons.push({ text: "Reschedule", onPress: () => startReschedule(post) });
|
||||||
|
} else if (post.state === "PUBLISHED") {
|
||||||
|
buttons.push({ text: "Repost", onPress: () => handlePrefillCompose(post) });
|
||||||
|
} else if (post.state === "DRAFT") {
|
||||||
|
buttons.push({ text: "Edit & schedule", onPress: () => handlePrefillCompose(post) });
|
||||||
|
}
|
||||||
|
|
||||||
|
buttons.push({ text: "Cancel", style: "cancel" });
|
||||||
|
|
||||||
|
Alert.alert(
|
||||||
|
post.state === "ERROR" ? "Failed post" :
|
||||||
|
post.state === "QUEUE" ? "Scheduled post" :
|
||||||
|
post.state === "PUBLISHED" ? "Published post" : "Draft",
|
||||||
|
preview,
|
||||||
|
buttons
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
if (!isConfigured) {
|
if (!isConfigured) {
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
@@ -128,43 +267,61 @@ export default function PostsScreen() {
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
|
<View style={[styles.filterRow, { borderBottomColor: colors.border }]}>
|
||||||
<FlatList
|
<FlatList
|
||||||
horizontal
|
horizontal
|
||||||
data={FILTERS}
|
data={FILTERS}
|
||||||
keyExtractor={(item) => item.key}
|
keyExtractor={(item) => item.key}
|
||||||
showsHorizontalScrollIndicator={false}
|
showsHorizontalScrollIndicator={false}
|
||||||
contentContainerStyle={styles.filterList}
|
contentContainerStyle={styles.filterList}
|
||||||
renderItem={({ item }) => (
|
renderItem={({ item }) => {
|
||||||
|
const count = posts ? filterCounts[item.key] : undefined;
|
||||||
|
const active = filter === item.key;
|
||||||
|
return (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={() => setFilter(item.key)}
|
onPress={() => setFilter(item.key)}
|
||||||
activeOpacity={0.7}
|
activeOpacity={0.7}
|
||||||
style={[
|
style={[
|
||||||
styles.filterChip,
|
styles.filterChip,
|
||||||
{
|
{
|
||||||
backgroundColor:
|
backgroundColor: active ? colors.primary : colors.secondary,
|
||||||
filter === item.key ? colors.primary : colors.secondary,
|
borderColor: active ? colors.primary : colors.border,
|
||||||
borderColor:
|
|
||||||
filter === item.key ? colors.primary : colors.border,
|
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Text
|
<Text
|
||||||
style={[
|
style={[
|
||||||
styles.filterText,
|
styles.filterText,
|
||||||
{
|
{ color: active ? colors.primaryForeground : colors.mutedForeground },
|
||||||
color:
|
|
||||||
filter === item.key
|
|
||||||
? colors.primaryForeground
|
|
||||||
: colors.mutedForeground,
|
|
||||||
},
|
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
{item.label}
|
{item.label}
|
||||||
|
{count !== undefined && count > 0 ? ` ${count}` : ""}
|
||||||
</Text>
|
</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)}
|
);
|
||||||
style={[styles.filterBar, { borderBottomColor: colors.border }]}
|
}}
|
||||||
|
style={styles.filterBar}
|
||||||
/>
|
/>
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={toggleSort}
|
||||||
|
activeOpacity={0.7}
|
||||||
|
style={[styles.sortBtn, { borderColor: colors.border, backgroundColor: colors.secondary }]}
|
||||||
|
>
|
||||||
|
<Feather
|
||||||
|
name={sortOrder === "desc" ? "arrow-down" : "arrow-up"}
|
||||||
|
size={14}
|
||||||
|
color={colors.mutedForeground}
|
||||||
|
/>
|
||||||
|
</TouchableOpacity>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{copyToast && (
|
||||||
|
<View style={[styles.toast, { backgroundColor: colors.success }]}>
|
||||||
|
<Feather name="check" size={13} color="#fff" />
|
||||||
|
<Text style={styles.toastText}>Copied</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<View style={styles.centered}>
|
<View style={styles.centered}>
|
||||||
@@ -193,7 +350,12 @@ export default function PostsScreen() {
|
|||||||
data={filteredPosts}
|
data={filteredPosts}
|
||||||
keyExtractor={(item) => item.id}
|
keyExtractor={(item) => item.id}
|
||||||
renderItem={({ item }) => (
|
renderItem={({ item }) => (
|
||||||
<PostCard post={item} onDelete={handleDelete} />
|
<PostCard
|
||||||
|
post={item}
|
||||||
|
onDelete={handleDelete}
|
||||||
|
onLongPress={showContextMenu}
|
||||||
|
onReschedule={startReschedule}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
refreshControl={
|
refreshControl={
|
||||||
<RefreshControl
|
<RefreshControl
|
||||||
@@ -220,6 +382,37 @@ export default function PostsScreen() {
|
|||||||
scrollEnabled={filteredPosts.length > 0}
|
scrollEnabled={filteredPosts.length > 0}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{rescheduleStep !== null && reschedulePost !== null && (
|
||||||
|
<DateTimePicker
|
||||||
|
value={rescheduleDate}
|
||||||
|
mode={rescheduleStep}
|
||||||
|
display="default"
|
||||||
|
minimumDate={rescheduleStep === "date" ? new Date() : undefined}
|
||||||
|
textColor={colors.foreground}
|
||||||
|
accentColor={colors.primary}
|
||||||
|
onChange={(_: unknown, date?: Date) => {
|
||||||
|
if (!date) {
|
||||||
|
setRescheduleStep(null);
|
||||||
|
setReschedulePost(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (rescheduleStep === "date") {
|
||||||
|
const merged = new Date(rescheduleDate);
|
||||||
|
merged.setFullYear(date.getFullYear(), date.getMonth(), date.getDate());
|
||||||
|
setRescheduleDate(merged);
|
||||||
|
setRescheduleStep("time");
|
||||||
|
} else {
|
||||||
|
const merged = new Date(rescheduleDate);
|
||||||
|
merged.setHours(date.getHours(), date.getMinutes());
|
||||||
|
const post = reschedulePost;
|
||||||
|
setRescheduleStep(null);
|
||||||
|
setReschedulePost(null);
|
||||||
|
submitReschedule(post, merged);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -233,13 +426,28 @@ const styles = StyleSheet.create({
|
|||||||
gap: 10,
|
gap: 10,
|
||||||
paddingHorizontal: 32,
|
paddingHorizontal: 32,
|
||||||
},
|
},
|
||||||
filterBar: { borderBottomWidth: StyleSheet.hairlineWidth, flexGrow: 0 },
|
filterRow: { flexDirection: "row", alignItems: "center", borderBottomWidth: StyleSheet.hairlineWidth },
|
||||||
|
filterBar: { flex: 1 },
|
||||||
filterList: { paddingHorizontal: 16, paddingVertical: 10, gap: 8 },
|
filterList: { paddingHorizontal: 16, paddingVertical: 10, gap: 8 },
|
||||||
filterChip: { paddingHorizontal: 14, paddingVertical: 6, borderRadius: 20, borderWidth: 1 },
|
filterChip: { paddingHorizontal: 14, paddingVertical: 6, borderRadius: 20, borderWidth: 1 },
|
||||||
|
sortBtn: { marginRight: 12, padding: 7, borderRadius: 8, borderWidth: 1 },
|
||||||
filterText: { fontSize: 13, fontFamily: "Inter_500Medium" },
|
filterText: { fontSize: 13, fontFamily: "Inter_500Medium" },
|
||||||
emptyState: { alignItems: "center", paddingTop: 64, gap: 10 },
|
emptyState: { alignItems: "center", paddingTop: 64, gap: 10 },
|
||||||
emptyTitle: { fontSize: 18, fontFamily: "Inter_600SemiBold" },
|
emptyTitle: { fontSize: 18, fontFamily: "Inter_600SemiBold" },
|
||||||
emptyText: { fontSize: 14, fontFamily: "Inter_400Regular", textAlign: "center" },
|
emptyText: { fontSize: 14, fontFamily: "Inter_400Regular", textAlign: "center" },
|
||||||
retryBtn: { marginTop: 4, paddingHorizontal: 20, paddingVertical: 10, borderRadius: 10 },
|
retryBtn: { marginTop: 4, paddingHorizontal: 20, paddingVertical: 10, borderRadius: 10 },
|
||||||
retryText: { fontSize: 14, fontFamily: "Inter_600SemiBold" },
|
retryText: { fontSize: 14, fontFamily: "Inter_600SemiBold" },
|
||||||
|
toast: {
|
||||||
|
position: "absolute",
|
||||||
|
bottom: 100,
|
||||||
|
alignSelf: "center",
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: 6,
|
||||||
|
paddingHorizontal: 14,
|
||||||
|
paddingVertical: 8,
|
||||||
|
borderRadius: 20,
|
||||||
|
zIndex: 999,
|
||||||
|
},
|
||||||
|
toastText: { fontSize: 13, fontFamily: "Inter_600SemiBold", color: "#fff" },
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,29 +15,9 @@ import {
|
|||||||
} from "react-native";
|
} from "react-native";
|
||||||
import { KeyboardAwareScrollView } from "react-native-keyboard-controller";
|
import { KeyboardAwareScrollView } from "react-native-keyboard-controller";
|
||||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||||
import { usePostiz } from "@/context/PostizContext";
|
import { usePostiz, DEFAULT_BASE_URL } from "@/context/PostizContext";
|
||||||
import { useColors } from "@/hooks/useColors";
|
import { useColors } from "@/hooks/useColors";
|
||||||
|
import { extractError } from "@/lib/extractError";
|
||||||
const DEFAULT_BASE_URL = "https://postiz.gyozamancave.fr/api/public/v1";
|
|
||||||
|
|
||||||
function extractAxiosError(err: unknown): string {
|
|
||||||
if (axios.isAxiosError(err)) {
|
|
||||||
const status = err.response?.status;
|
|
||||||
const data = err.response?.data;
|
|
||||||
if (data) {
|
|
||||||
const body =
|
|
||||||
typeof data === "string"
|
|
||||||
? data.slice(0, 200)
|
|
||||||
: (data?.message ?? data?.error ?? JSON.stringify(data)).toString().slice(0, 200);
|
|
||||||
return status ? `HTTP ${status}: ${body}` : body;
|
|
||||||
}
|
|
||||||
if (status) return `HTTP ${status} — ${err.message}`;
|
|
||||||
if (err.code === "ECONNABORTED") return "Request timed out (10s). Check that the URL is reachable.";
|
|
||||||
if (err.message) return err.message;
|
|
||||||
}
|
|
||||||
if (err instanceof Error) return err.message;
|
|
||||||
return "Unknown error";
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function SettingsScreen() {
|
export default function SettingsScreen() {
|
||||||
const colors = useColors();
|
const colors = useColors();
|
||||||
@@ -98,7 +78,7 @@ export default function SettingsScreen() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastError = extractAxiosError(err);
|
lastError = extractError(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +99,7 @@ export default function SettingsScreen() {
|
|||||||
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
|
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success);
|
||||||
Alert.alert("Saved", "Settings saved successfully.");
|
Alert.alert("Saved", "Settings saved successfully.");
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
Alert.alert("Error", `Failed to save settings.\n${extractAxiosError(err)}`);
|
Alert.alert("Error", `Failed to save settings.\n${extractError(err)}`);
|
||||||
} finally {
|
} finally {
|
||||||
setSaving(false);
|
setSaving(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,15 +6,16 @@ import {
|
|||||||
useFonts,
|
useFonts,
|
||||||
} from "@expo-google-fonts/inter";
|
} from "@expo-google-fonts/inter";
|
||||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||||
import { Stack } from "expo-router";
|
import { router, Stack } from "expo-router";
|
||||||
import * as SplashScreen from "expo-splash-screen";
|
import * as SplashScreen from "expo-splash-screen";
|
||||||
import React, { useEffect } from "react";
|
import React, { useEffect } from "react";
|
||||||
|
import { Alert } from "react-native";
|
||||||
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
||||||
import { KeyboardProvider } from "react-native-keyboard-controller";
|
import { KeyboardProvider } from "react-native-keyboard-controller";
|
||||||
import { SafeAreaProvider } from "react-native-safe-area-context";
|
import { SafeAreaProvider } from "react-native-safe-area-context";
|
||||||
|
|
||||||
import { ErrorBoundary } from "@/components/ErrorBoundary";
|
import { ErrorBoundary } from "@/components/ErrorBoundary";
|
||||||
import { PostizProvider } from "@/context/PostizContext";
|
import { PostizProvider, usePostiz } from "@/context/PostizContext";
|
||||||
import { useNotifications } from "@/hooks/useNotifications";
|
import { useNotifications } from "@/hooks/useNotifications";
|
||||||
|
|
||||||
SplashScreen.preventAutoHideAsync();
|
SplashScreen.preventAutoHideAsync();
|
||||||
@@ -33,6 +34,28 @@ function NotificationBootstrap() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function UnauthorizedHandler() {
|
||||||
|
const { unauthorized, clearUnauthorized } = usePostiz();
|
||||||
|
useEffect(() => {
|
||||||
|
if (!unauthorized) return;
|
||||||
|
Alert.alert(
|
||||||
|
"API key invalid",
|
||||||
|
"Your API key was rejected (401). Update it in Settings.",
|
||||||
|
[
|
||||||
|
{
|
||||||
|
text: "Open Settings",
|
||||||
|
onPress: () => {
|
||||||
|
clearUnauthorized();
|
||||||
|
router.push("/(tabs)/settings");
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ text: "Dismiss", style: "cancel", onPress: clearUnauthorized },
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}, [unauthorized, clearUnauthorized]);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
function RootLayoutNav() {
|
function RootLayoutNav() {
|
||||||
return (
|
return (
|
||||||
<Stack screenOptions={{ headerBackTitle: "Back" }}>
|
<Stack screenOptions={{ headerBackTitle: "Back" }}>
|
||||||
@@ -63,6 +86,7 @@ export default function RootLayout() {
|
|||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
<PostizProvider>
|
<PostizProvider>
|
||||||
<NotificationBootstrap />
|
<NotificationBootstrap />
|
||||||
|
<UnauthorizedHandler />
|
||||||
<GestureHandlerRootView style={{ flex: 1 }}>
|
<GestureHandlerRootView style={{ flex: 1 }}>
|
||||||
<KeyboardProvider>
|
<KeyboardProvider>
|
||||||
<RootLayoutNav />
|
<RootLayoutNav />
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 652 KiB After Width: | Height: | Size: 49 KiB |
Executable
+182
@@ -0,0 +1,182 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# build-apk.sh — Build a signed release APK locally without expo.dev / EAS.
|
||||||
|
#
|
||||||
|
# Prerequisites (first time only):
|
||||||
|
# 1. Export EAS keystore:
|
||||||
|
# cd artifacts/postiz-mobile
|
||||||
|
# eas credentials --platform android
|
||||||
|
# → "Download existing keystore" → save to ~/.config/postiz-mobile/postiz-mobile.jks
|
||||||
|
# 2. Fill in signing credentials:
|
||||||
|
# cp ~/.config/postiz-mobile/signing.env.example ~/.config/postiz-mobile/signing.env
|
||||||
|
# $EDITOR ~/.config/postiz-mobile/signing.env
|
||||||
|
# 3. Install Android SDK (if not already):
|
||||||
|
# ./install-android-sdk.sh
|
||||||
|
# # then add ANDROID_HOME to your shell profile and reload it
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# ./build-apk.sh # → dist/postiz-mobile-YYYYMMDD-HHMM.apk
|
||||||
|
# ./build-apk.sh --aab # → dist/postiz-mobile-YYYYMMDD-HHMM.aab (Play Store)
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
SIGNING_ENV="$HOME/.config/postiz-mobile/signing.env"
|
||||||
|
DIST_DIR="$SCRIPT_DIR/dist"
|
||||||
|
BUILD_TYPE="${1:-}"
|
||||||
|
|
||||||
|
# ─── Colours ───────────────────────────────────────────────────────────────
|
||||||
|
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m'
|
||||||
|
info() { echo -e "${GREEN}[build]${NC} $*"; }
|
||||||
|
warn() { echo -e "${YELLOW}[warn]${NC} $*"; }
|
||||||
|
abort() { echo -e "${RED}[error]${NC} $*" >&2; exit 1; }
|
||||||
|
|
||||||
|
# ─── 1. Signing credentials ────────────────────────────────────────────────
|
||||||
|
if [ ! -f "$SIGNING_ENV" ]; then
|
||||||
|
abort "Missing signing.env.\n\n cp ~/.config/postiz-mobile/signing.env.example ~/.config/postiz-mobile/signing.env\n # then fill in your keystore path and passwords"
|
||||||
|
fi
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
source "$SIGNING_ENV"
|
||||||
|
|
||||||
|
[ -z "${KEYSTORE_PATH:-}" ] && abort "KEYSTORE_PATH not set in signing.env"
|
||||||
|
[ -z "${KEYSTORE_ALIAS:-}" ] && abort "KEYSTORE_ALIAS not set in signing.env"
|
||||||
|
[ -z "${KEYSTORE_STORE_PASSWORD:-}" ] && abort "KEYSTORE_STORE_PASSWORD not set in signing.env"
|
||||||
|
[ -z "${KEYSTORE_KEY_PASSWORD:-}" ] && abort "KEYSTORE_KEY_PASSWORD not set in signing.env"
|
||||||
|
|
||||||
|
KEYSTORE_PATH_EXPANDED="${KEYSTORE_PATH/#\$HOME/$HOME}"
|
||||||
|
KEYSTORE_PATH_EXPANDED="${KEYSTORE_PATH_EXPANDED/#~/$HOME}"
|
||||||
|
|
||||||
|
[ ! -f "$KEYSTORE_PATH_EXPANDED" ] && \
|
||||||
|
abort "Keystore not found: $KEYSTORE_PATH_EXPANDED\n\nExport it from EAS:\n eas credentials --platform android\n → Download existing keystore → save to $KEYSTORE_PATH_EXPANDED"
|
||||||
|
|
||||||
|
# ─── 2. Java 17/21 — Gradle requires Java ≤ 24 (system Java 25 is too new) ──
|
||||||
|
# Use ~/jdk21 if present, otherwise rely on JAVA_HOME already being set correctly.
|
||||||
|
if [ -z "${JAVA_HOME:-}" ] || "$JAVA_HOME/bin/java" -version 2>&1 | grep -qE '"(2[5-9]|[3-9][0-9])\.' ; then
|
||||||
|
if [ -d "$HOME/jdk21" ]; then
|
||||||
|
export JAVA_HOME="$HOME/jdk21"
|
||||||
|
export PATH="$JAVA_HOME/bin:$PATH"
|
||||||
|
info "Using local JDK 21: $JAVA_HOME"
|
||||||
|
else
|
||||||
|
abort "Java 25+ detected but Gradle only supports ≤ Java 24.\n\nInstall JDK 21 locally:\n wget -O /tmp/jdk21.tar.gz https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.7%2B6/OpenJDK21U-jdk_x64_linux_hotspot_21.0.7_6.tar.gz\n mkdir -p ~/jdk21 && tar -xzf /tmp/jdk21.tar.gz -C ~/jdk21 --strip-components=1"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
info "Java: $("$JAVA_HOME/bin/java" -version 2>&1 | head -1)"
|
||||||
|
|
||||||
|
# ─── 3. Android SDK ────────────────────────────────────────────────────────
|
||||||
|
if [ -z "${ANDROID_HOME:-}" ]; then
|
||||||
|
for candidate in "$HOME/android-sdk" "$HOME/Android/Sdk" "/opt/android-sdk"; do
|
||||||
|
if [ -d "$candidate/platform-tools" ]; then
|
||||||
|
export ANDROID_HOME="$candidate"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${ANDROID_HOME:-}" ]; then
|
||||||
|
abort "Android SDK not found.\n\nRun: ./install-android-sdk.sh\nThen: export ANDROID_HOME=\"\$HOME/android-sdk\" && source ~/.bashrc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
export PATH="$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/cmdline-tools/latest/bin"
|
||||||
|
info "Android SDK: $ANDROID_HOME"
|
||||||
|
|
||||||
|
# ─── 4. expo prebuild ──────────────────────────────────────────────────────
|
||||||
|
info "Running expo prebuild (Android)…"
|
||||||
|
cd "$SCRIPT_DIR"
|
||||||
|
pnpm exec expo prebuild --platform android --clean --no-install
|
||||||
|
|
||||||
|
# ─── 4. Patch build.gradle — inject release signingConfig ──────────────────
|
||||||
|
info "Patching android/app/build.gradle for release signing…"
|
||||||
|
|
||||||
|
python3 - "$SCRIPT_DIR/android/app/build.gradle" << 'PYEOF'
|
||||||
|
import sys, re
|
||||||
|
|
||||||
|
path = sys.argv[1]
|
||||||
|
with open(path, 'r') as f:
|
||||||
|
content = f.read()
|
||||||
|
|
||||||
|
if 'MYAPP_UPLOAD_STORE_FILE' in content:
|
||||||
|
print('[patch] build.gradle already patched, skipping.')
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
release_signing = """\n release {
|
||||||
|
if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
|
||||||
|
storeFile file(MYAPP_UPLOAD_STORE_FILE)
|
||||||
|
storePassword MYAPP_UPLOAD_STORE_PASSWORD
|
||||||
|
keyAlias MYAPP_UPLOAD_KEY_ALIAS
|
||||||
|
keyPassword MYAPP_UPLOAD_KEY_PASSWORD
|
||||||
|
}
|
||||||
|
}"""
|
||||||
|
|
||||||
|
# Insert release block right after the closing brace of the debug signingConfig
|
||||||
|
content = re.sub(
|
||||||
|
r'(signingConfigs\s*\{[\s\S]*?debug\s*\{[\s\S]*?\})',
|
||||||
|
r'\1' + release_signing,
|
||||||
|
content,
|
||||||
|
count=1
|
||||||
|
)
|
||||||
|
|
||||||
|
# Switch release buildType from debug signing to release signing
|
||||||
|
# Only replace the first occurrence after "release {" (not the debug one)
|
||||||
|
def replace_release_signing(m):
|
||||||
|
return m.group(0).replace('signingConfig signingConfigs.debug',
|
||||||
|
'signingConfig signingConfigs.release', 1)
|
||||||
|
|
||||||
|
content = re.sub(
|
||||||
|
r'release\s*\{[^}]*signingConfig\s+signingConfigs\.debug',
|
||||||
|
replace_release_signing,
|
||||||
|
content,
|
||||||
|
count=1,
|
||||||
|
flags=re.DOTALL
|
||||||
|
)
|
||||||
|
|
||||||
|
with open(path, 'w') as f:
|
||||||
|
f.write(content)
|
||||||
|
|
||||||
|
print('[patch] build.gradle patched for release signing.')
|
||||||
|
PYEOF
|
||||||
|
|
||||||
|
# ─── 5. Inject signing props into gradle.properties ────────────────────────
|
||||||
|
info "Injecting signing credentials into gradle.properties…"
|
||||||
|
GRADLE_PROPS="$SCRIPT_DIR/android/gradle.properties"
|
||||||
|
|
||||||
|
# Remove any previous signing block left by this script
|
||||||
|
sed -i '/^# --- postiz release signing/,/^# --- end signing/d' "$GRADLE_PROPS" 2>/dev/null || true
|
||||||
|
|
||||||
|
cat >> "$GRADLE_PROPS" << EOF
|
||||||
|
|
||||||
|
# --- postiz release signing (injected by build-apk.sh — wiped after build)
|
||||||
|
MYAPP_UPLOAD_STORE_FILE=$KEYSTORE_PATH_EXPANDED
|
||||||
|
MYAPP_UPLOAD_STORE_PASSWORD=$KEYSTORE_STORE_PASSWORD
|
||||||
|
MYAPP_UPLOAD_KEY_ALIAS=$KEYSTORE_ALIAS
|
||||||
|
MYAPP_UPLOAD_KEY_PASSWORD=$KEYSTORE_KEY_PASSWORD
|
||||||
|
# --- end signing
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# ─── 6. Gradle build ───────────────────────────────────────────────────────
|
||||||
|
cd "$SCRIPT_DIR/android"
|
||||||
|
|
||||||
|
if [ "$BUILD_TYPE" = "--aab" ]; then
|
||||||
|
info "Building AAB (release)…"
|
||||||
|
./gradlew bundleRelease
|
||||||
|
ARTIFACT="app/build/outputs/bundle/release/app-release.aab"
|
||||||
|
EXT="aab"
|
||||||
|
else
|
||||||
|
info "Building APK (release)…"
|
||||||
|
./gradlew assembleRelease
|
||||||
|
ARTIFACT="app/build/outputs/apk/release/app-release.apk"
|
||||||
|
EXT="apk"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ─── 7. Wipe credentials from gradle.properties ───────────────────────────
|
||||||
|
sed -i '/^# --- postiz release signing/,/^# --- end signing/d' "$GRADLE_PROPS"
|
||||||
|
info "Signing credentials wiped from gradle.properties."
|
||||||
|
|
||||||
|
# ─── 8. Copy to dist/ ─────────────────────────────────────────────────────
|
||||||
|
mkdir -p "$DIST_DIR"
|
||||||
|
TIMESTAMP="$(date +%Y%m%d-%H%M)"
|
||||||
|
OUTPUT="$DIST_DIR/postiz-mobile-$TIMESTAMP.$EXT"
|
||||||
|
cp "$ARTIFACT" "$OUTPUT"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
info "Build complete!"
|
||||||
|
echo -e " ${GREEN}→ $OUTPUT${NC}"
|
||||||
|
echo ""
|
||||||
@@ -0,0 +1,209 @@
|
|||||||
|
import { Feather } from "@expo/vector-icons";
|
||||||
|
import { Image } from "expo-image";
|
||||||
|
import React, { useCallback, useEffect, useState } from "react";
|
||||||
|
import {
|
||||||
|
ActivityIndicator,
|
||||||
|
FlatList,
|
||||||
|
Modal,
|
||||||
|
StyleSheet,
|
||||||
|
Text,
|
||||||
|
TouchableOpacity,
|
||||||
|
View,
|
||||||
|
} from "react-native";
|
||||||
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||||
|
import { useColors } from "@/hooks/useColors";
|
||||||
|
|
||||||
|
interface MediaItem {
|
||||||
|
id: string;
|
||||||
|
path: string;
|
||||||
|
createdAt?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
visible: boolean;
|
||||||
|
baseUrl: string;
|
||||||
|
apiKey: string;
|
||||||
|
maxSelect: number;
|
||||||
|
onClose: () => void;
|
||||||
|
onSelect: (items: MediaItem[]) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveUrl(path: string, baseUrl: string): string {
|
||||||
|
if (path.startsWith("http://") || path.startsWith("https://")) return path;
|
||||||
|
const origin = baseUrl.replace(/\/api\/.*$/, "");
|
||||||
|
return `${origin}/${path.replace(/^\//, "")}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function MediaLibraryModal({ visible, baseUrl, apiKey, maxSelect, onClose, onSelect }: Props) {
|
||||||
|
const colors = useColors();
|
||||||
|
const insets = useSafeAreaInsets();
|
||||||
|
const [items, setItems] = useState<MediaItem[]>([]);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
const [selected, setSelected] = useState<Set<string>>(new Set());
|
||||||
|
|
||||||
|
const load = useCallback(async () => {
|
||||||
|
if (!baseUrl || !apiKey) return;
|
||||||
|
setLoading(true);
|
||||||
|
setError(null);
|
||||||
|
try {
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
|
const res = await globalThis.fetch(`${baseUrl}/media`, {
|
||||||
|
headers: { Authorization: apiKey },
|
||||||
|
});
|
||||||
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
||||||
|
const data = await res.json();
|
||||||
|
const list: MediaItem[] = Array.isArray(data)
|
||||||
|
? data
|
||||||
|
: (data?.media ?? data?.items ?? data?.files ?? []);
|
||||||
|
setItems(list);
|
||||||
|
} catch (e: unknown) {
|
||||||
|
setError(e instanceof Error ? e.message : "Failed to load media");
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}, [baseUrl, apiKey]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (visible) {
|
||||||
|
setSelected(new Set());
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
}, [visible, load]);
|
||||||
|
|
||||||
|
const toggle = (id: string) => {
|
||||||
|
setSelected((prev) => {
|
||||||
|
const next = new Set(prev);
|
||||||
|
if (next.has(id)) {
|
||||||
|
next.delete(id);
|
||||||
|
} else if (next.size < maxSelect) {
|
||||||
|
next.add(id);
|
||||||
|
}
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleConfirm = () => {
|
||||||
|
const chosen = items.filter((i) => selected.has(i.id));
|
||||||
|
onSelect(chosen);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal visible={visible} animationType="slide" onRequestClose={onClose}>
|
||||||
|
<View style={[styles.root, { backgroundColor: colors.background, paddingTop: insets.top }]}>
|
||||||
|
<View style={[styles.header, { borderBottomColor: colors.border }]}>
|
||||||
|
<TouchableOpacity onPress={onClose} activeOpacity={0.7} style={styles.closeBtn}>
|
||||||
|
<Feather name="x" size={20} color={colors.foreground} />
|
||||||
|
</TouchableOpacity>
|
||||||
|
<Text style={[styles.title, { color: colors.foreground }]}>Media Library</Text>
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={handleConfirm}
|
||||||
|
disabled={selected.size === 0}
|
||||||
|
activeOpacity={0.8}
|
||||||
|
style={[
|
||||||
|
styles.addBtn,
|
||||||
|
{ backgroundColor: selected.size > 0 ? colors.primary : colors.muted },
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Text style={[styles.addBtnText, { color: colors.primaryForeground }]}>
|
||||||
|
{selected.size > 0 ? `Add ${selected.size}` : "Add"}
|
||||||
|
</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{loading ? (
|
||||||
|
<View style={styles.centered}>
|
||||||
|
<ActivityIndicator color={colors.primary} size="large" />
|
||||||
|
</View>
|
||||||
|
) : error ? (
|
||||||
|
<View style={styles.centered}>
|
||||||
|
<Feather name="alert-circle" size={28} color={colors.error} />
|
||||||
|
<Text style={[styles.errorText, { color: colors.mutedForeground }]}>{error}</Text>
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={load}
|
||||||
|
style={[styles.retryBtn, { backgroundColor: colors.primary }]}
|
||||||
|
activeOpacity={0.8}
|
||||||
|
>
|
||||||
|
<Text style={[styles.retryText, { color: colors.primaryForeground }]}>Retry</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
</View>
|
||||||
|
) : items.length === 0 ? (
|
||||||
|
<View style={styles.centered}>
|
||||||
|
<Feather name="image" size={36} color={colors.mutedForeground} />
|
||||||
|
<Text style={[styles.emptyText, { color: colors.mutedForeground }]}>No media found</Text>
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<FlatList
|
||||||
|
data={items}
|
||||||
|
keyExtractor={(item) => item.id}
|
||||||
|
numColumns={3}
|
||||||
|
contentContainerStyle={[styles.grid, { paddingBottom: insets.bottom + 16 }]}
|
||||||
|
renderItem={({ item }) => {
|
||||||
|
const isSelected = selected.has(item.id);
|
||||||
|
const uri = resolveUrl(item.path, baseUrl);
|
||||||
|
return (
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={() => toggle(item.id)}
|
||||||
|
activeOpacity={0.8}
|
||||||
|
style={styles.cell}
|
||||||
|
>
|
||||||
|
<Image
|
||||||
|
source={{ uri }}
|
||||||
|
style={styles.cellImage}
|
||||||
|
contentFit="cover"
|
||||||
|
/>
|
||||||
|
{isSelected && (
|
||||||
|
<View style={[styles.selectedOverlay, { backgroundColor: colors.primary + "99" }]}>
|
||||||
|
<View style={[styles.checkCircle, { backgroundColor: colors.primary }]}>
|
||||||
|
<Feather name="check" size={14} color="#fff" />
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</TouchableOpacity>
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const CELL = 120;
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
root: { flex: 1 },
|
||||||
|
header: {
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
paddingHorizontal: 16,
|
||||||
|
paddingVertical: 14,
|
||||||
|
borderBottomWidth: StyleSheet.hairlineWidth,
|
||||||
|
gap: 12,
|
||||||
|
},
|
||||||
|
closeBtn: { padding: 4 },
|
||||||
|
title: { flex: 1, fontSize: 17, fontFamily: "Inter_600SemiBold" },
|
||||||
|
addBtn: { paddingHorizontal: 16, paddingVertical: 8, borderRadius: 20 },
|
||||||
|
addBtnText: { fontSize: 14, fontFamily: "Inter_600SemiBold" },
|
||||||
|
centered: { flex: 1, alignItems: "center", justifyContent: "center", gap: 12 },
|
||||||
|
errorText: { fontSize: 14, fontFamily: "Inter_400Regular", textAlign: "center", paddingHorizontal: 32 },
|
||||||
|
emptyText: { fontSize: 14, fontFamily: "Inter_400Regular" },
|
||||||
|
retryBtn: { paddingHorizontal: 20, paddingVertical: 10, borderRadius: 10 },
|
||||||
|
retryText: { fontSize: 14, fontFamily: "Inter_600SemiBold" },
|
||||||
|
grid: { padding: 2 },
|
||||||
|
cell: { width: CELL, height: CELL, margin: 2 },
|
||||||
|
cellImage: { width: CELL, height: CELL, borderRadius: 4 },
|
||||||
|
selectedOverlay: {
|
||||||
|
...StyleSheet.absoluteFillObject,
|
||||||
|
borderRadius: 4,
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
},
|
||||||
|
checkCircle: {
|
||||||
|
width: 28,
|
||||||
|
height: 28,
|
||||||
|
borderRadius: 14,
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -12,11 +12,14 @@ import {
|
|||||||
import { Swipeable } from "react-native-gesture-handler";
|
import { Swipeable } from "react-native-gesture-handler";
|
||||||
import { useColors } from "@/hooks/useColors";
|
import { useColors } from "@/hooks/useColors";
|
||||||
import { PostizPost } from "@/context/PostizContext";
|
import { PostizPost } from "@/context/PostizContext";
|
||||||
|
import { stripHtml } from "@/lib/stripHtml";
|
||||||
import { StatusBadge } from "./StatusBadge";
|
import { StatusBadge } from "./StatusBadge";
|
||||||
|
|
||||||
interface PostCardProps {
|
interface PostCardProps {
|
||||||
post: PostizPost;
|
post: PostizPost;
|
||||||
onDelete: (id: string) => Promise<void>;
|
onDelete: (id: string) => Promise<void>;
|
||||||
|
onLongPress: (post: PostizPost) => void;
|
||||||
|
onReschedule?: (post: PostizPost) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatDate(dateStr: string): string {
|
function formatDate(dateStr: string): string {
|
||||||
@@ -43,7 +46,7 @@ function getNetworkIcon(type?: string): React.ComponentProps<typeof Feather>["na
|
|||||||
return "globe";
|
return "globe";
|
||||||
}
|
}
|
||||||
|
|
||||||
export function PostCard({ post, onDelete }: PostCardProps) {
|
export function PostCard({ post, onDelete, onLongPress, onReschedule }: PostCardProps) {
|
||||||
const colors = useColors();
|
const colors = useColors();
|
||||||
const swipeRef = useRef<Swipeable>(null);
|
const swipeRef = useRef<Swipeable>(null);
|
||||||
|
|
||||||
@@ -87,20 +90,54 @@ export function PostCard({ post, onDelete }: PostCardProps) {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const renderLeftActions =
|
||||||
|
post.state === "QUEUE" && onReschedule
|
||||||
|
? (
|
||||||
|
_progress: Animated.AnimatedInterpolation<number>,
|
||||||
|
dragX: Animated.AnimatedInterpolation<number>
|
||||||
|
) => {
|
||||||
|
const scale = dragX.interpolate({
|
||||||
|
inputRange: [0, 80],
|
||||||
|
outputRange: [0.8, 1],
|
||||||
|
extrapolate: "clamp",
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<TouchableOpacity
|
||||||
|
style={[styles.rescheduleAction, { backgroundColor: colors.warning }]}
|
||||||
|
onPress={() => {
|
||||||
|
swipeRef.current?.close();
|
||||||
|
onReschedule(post);
|
||||||
|
}}
|
||||||
|
activeOpacity={0.8}
|
||||||
|
>
|
||||||
|
<Animated.View style={{ transform: [{ scale }] }}>
|
||||||
|
<Feather name="clock" size={20} color="#fff" />
|
||||||
|
</Animated.View>
|
||||||
|
</TouchableOpacity>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
: undefined;
|
||||||
|
|
||||||
const integrations = post.integrations ?? (post.integration ? [post.integration] : []);
|
const integrations = post.integrations ?? (post.integration ? [post.integration] : []);
|
||||||
|
const plainContent = stripHtml(post.content);
|
||||||
const truncatedContent =
|
const truncatedContent =
|
||||||
post.content.length > 140
|
plainContent.length > 140
|
||||||
? post.content.slice(0, 140) + "…"
|
? plainContent.slice(0, 140) + "…"
|
||||||
: post.content;
|
: plainContent;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Swipeable
|
<Swipeable
|
||||||
ref={swipeRef}
|
ref={swipeRef}
|
||||||
renderRightActions={renderRightActions}
|
renderRightActions={renderRightActions}
|
||||||
|
renderLeftActions={renderLeftActions}
|
||||||
rightThreshold={40}
|
rightThreshold={40}
|
||||||
|
leftThreshold={40}
|
||||||
friction={2}
|
friction={2}
|
||||||
>
|
>
|
||||||
<View
|
<TouchableOpacity
|
||||||
|
activeOpacity={0.85}
|
||||||
|
onLongPress={() => onLongPress(post)}
|
||||||
|
delayLongPress={400}
|
||||||
style={[
|
style={[
|
||||||
styles.card,
|
styles.card,
|
||||||
{ backgroundColor: colors.card, borderBottomColor: colors.border },
|
{ backgroundColor: colors.card, borderBottomColor: colors.border },
|
||||||
@@ -135,12 +172,25 @@ export function PostCard({ post, onDelete }: PostCardProps) {
|
|||||||
{truncatedContent}
|
{truncatedContent}
|
||||||
</Text>
|
</Text>
|
||||||
<View style={styles.footer}>
|
<View style={styles.footer}>
|
||||||
|
{integrations.length > 0 && (
|
||||||
|
<>
|
||||||
|
<Text style={[styles.accountName, { color: colors.mutedForeground }]} numberOfLines={1}>
|
||||||
|
{integrations
|
||||||
|
.slice(0, 2)
|
||||||
|
.map((i) => i.name || i.identifier || "")
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(", ")}
|
||||||
|
{integrations.length > 2 ? ` +${integrations.length - 2}` : ""}
|
||||||
|
</Text>
|
||||||
|
<Text style={[styles.dot, { color: colors.mutedForeground }]}>·</Text>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<Feather name="clock" size={12} color={colors.mutedForeground} />
|
<Feather name="clock" size={12} color={colors.mutedForeground} />
|
||||||
<Text style={[styles.date, { color: colors.mutedForeground }]}>
|
<Text style={[styles.date, { color: colors.mutedForeground }]}>
|
||||||
{formatDate(post.publishDate)}
|
{formatDate(post.publishDate)}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</TouchableOpacity>
|
||||||
</Swipeable>
|
</Swipeable>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -187,9 +237,23 @@ const styles = StyleSheet.create({
|
|||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontFamily: "Inter_400Regular",
|
fontFamily: "Inter_400Regular",
|
||||||
},
|
},
|
||||||
|
accountName: {
|
||||||
|
fontSize: 12,
|
||||||
|
fontFamily: "Inter_400Regular",
|
||||||
|
flexShrink: 1,
|
||||||
|
},
|
||||||
|
dot: {
|
||||||
|
fontSize: 12,
|
||||||
|
marginHorizontal: 3,
|
||||||
|
},
|
||||||
deleteAction: {
|
deleteAction: {
|
||||||
width: 72,
|
width: 72,
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
},
|
},
|
||||||
|
rescheduleAction: {
|
||||||
|
width: 72,
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,12 +5,13 @@ import React, {
|
|||||||
useCallback,
|
useCallback,
|
||||||
useContext,
|
useContext,
|
||||||
useEffect,
|
useEffect,
|
||||||
|
useRef,
|
||||||
useState,
|
useState,
|
||||||
} from "react";
|
} from "react";
|
||||||
|
|
||||||
const API_KEY_STORAGE = "postiz_api_key";
|
const API_KEY_STORAGE = "postiz_api_key";
|
||||||
const BASE_URL_STORAGE = "postiz_base_url";
|
const BASE_URL_STORAGE = "postiz_base_url";
|
||||||
const DEFAULT_BASE_URL = "https://postiz.gyozamancave.fr/api/public/v1";
|
export const DEFAULT_BASE_URL = "https://postiz.gyozamancave.fr/api/public/v1";
|
||||||
|
|
||||||
export interface PostizIntegration {
|
export interface PostizIntegration {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -35,6 +36,7 @@ export interface PostizPost {
|
|||||||
integrations?: PostizIntegration[];
|
integrations?: PostizIntegration[];
|
||||||
image?: PostizMediaItem[];
|
image?: PostizMediaItem[];
|
||||||
group?: string;
|
group?: string;
|
||||||
|
errorMessage?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PostizUploadResult {
|
export interface PostizUploadResult {
|
||||||
@@ -47,6 +49,8 @@ interface PostizContextValue {
|
|||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
isConfigured: boolean;
|
isConfigured: boolean;
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
|
unauthorized: boolean;
|
||||||
|
clearUnauthorized: () => void;
|
||||||
client: AxiosInstance | null;
|
client: AxiosInstance | null;
|
||||||
saveSettings: (apiKey: string, baseUrl: string) => Promise<void>;
|
saveSettings: (apiKey: string, baseUrl: string) => Promise<void>;
|
||||||
clearSettings: () => Promise<void>;
|
clearSettings: () => Promise<void>;
|
||||||
@@ -57,12 +61,18 @@ const PostizContext = createContext<PostizContextValue>({
|
|||||||
baseUrl: DEFAULT_BASE_URL,
|
baseUrl: DEFAULT_BASE_URL,
|
||||||
isConfigured: false,
|
isConfigured: false,
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
|
unauthorized: false,
|
||||||
|
clearUnauthorized: () => {},
|
||||||
client: null,
|
client: null,
|
||||||
saveSettings: async () => {},
|
saveSettings: async () => {},
|
||||||
clearSettings: async () => {},
|
clearSettings: async () => {},
|
||||||
});
|
});
|
||||||
|
|
||||||
function createClient(apiKey: string, baseUrl: string): AxiosInstance {
|
function createClient(
|
||||||
|
apiKey: string,
|
||||||
|
baseUrl: string,
|
||||||
|
onUnauthorized?: () => void
|
||||||
|
): AxiosInstance {
|
||||||
const normalizedUrl = baseUrl.endsWith("/") ? baseUrl : baseUrl + "/";
|
const normalizedUrl = baseUrl.endsWith("/") ? baseUrl : baseUrl + "/";
|
||||||
const instance = axios.create({
|
const instance = axios.create({
|
||||||
baseURL: normalizedUrl,
|
baseURL: normalizedUrl,
|
||||||
@@ -76,6 +86,15 @@ function createClient(apiKey: string, baseUrl: string): AxiosInstance {
|
|||||||
console.log(">>> REQUEST:", config.method?.toUpperCase(), (config.baseURL || "") + (config.url || ""));
|
console.log(">>> REQUEST:", config.method?.toUpperCase(), (config.baseURL || "") + (config.url || ""));
|
||||||
return config;
|
return config;
|
||||||
});
|
});
|
||||||
|
instance.interceptors.response.use(
|
||||||
|
(res) => res,
|
||||||
|
(err) => {
|
||||||
|
if (axios.isAxiosError(err) && err.response?.status === 401) {
|
||||||
|
onUnauthorized?.();
|
||||||
|
}
|
||||||
|
return Promise.reject(err);
|
||||||
|
}
|
||||||
|
);
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,6 +103,19 @@ export function PostizProvider({ children }: { children: React.ReactNode }) {
|
|||||||
const [baseUrl, setBaseUrl] = useState(DEFAULT_BASE_URL);
|
const [baseUrl, setBaseUrl] = useState(DEFAULT_BASE_URL);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [client, setClient] = useState<AxiosInstance | null>(null);
|
const [client, setClient] = useState<AxiosInstance | null>(null);
|
||||||
|
const [unauthorized, setUnauthorized] = useState(false);
|
||||||
|
const unauthorizedFiredRef = useRef(false);
|
||||||
|
|
||||||
|
const handleUnauthorized = useCallback(() => {
|
||||||
|
if (unauthorizedFiredRef.current) return;
|
||||||
|
unauthorizedFiredRef.current = true;
|
||||||
|
setUnauthorized(true);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const clearUnauthorized = useCallback(() => {
|
||||||
|
unauthorizedFiredRef.current = false;
|
||||||
|
setUnauthorized(false);
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
@@ -94,14 +126,14 @@ export function PostizProvider({ children }: { children: React.ReactNode }) {
|
|||||||
const url = (storedUrl || DEFAULT_BASE_URL).replace(/\/$/, "");
|
const url = (storedUrl || DEFAULT_BASE_URL).replace(/\/$/, "");
|
||||||
setApiKey(storedKey);
|
setApiKey(storedKey);
|
||||||
setBaseUrl(url);
|
setBaseUrl(url);
|
||||||
setClient(() => createClient(storedKey, url));
|
setClient(() => createClient(storedKey, url, handleUnauthorized));
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
}, []);
|
}, [handleUnauthorized]);
|
||||||
|
|
||||||
const saveSettings = useCallback(
|
const saveSettings = useCallback(
|
||||||
async (newApiKey: string, newBaseUrl: string) => {
|
async (newApiKey: string, newBaseUrl: string) => {
|
||||||
@@ -109,9 +141,10 @@ export function PostizProvider({ children }: { children: React.ReactNode }) {
|
|||||||
await SecureStore.setItemAsync(BASE_URL_STORAGE, newBaseUrl);
|
await SecureStore.setItemAsync(BASE_URL_STORAGE, newBaseUrl);
|
||||||
setApiKey(newApiKey);
|
setApiKey(newApiKey);
|
||||||
setBaseUrl(newBaseUrl);
|
setBaseUrl(newBaseUrl);
|
||||||
setClient(() => createClient(newApiKey, newBaseUrl));
|
clearUnauthorized();
|
||||||
|
setClient(() => createClient(newApiKey, newBaseUrl, handleUnauthorized));
|
||||||
},
|
},
|
||||||
[]
|
[handleUnauthorized, clearUnauthorized]
|
||||||
);
|
);
|
||||||
|
|
||||||
const clearSettings = useCallback(async () => {
|
const clearSettings = useCallback(async () => {
|
||||||
@@ -120,7 +153,8 @@ export function PostizProvider({ children }: { children: React.ReactNode }) {
|
|||||||
setApiKey("");
|
setApiKey("");
|
||||||
setBaseUrl(DEFAULT_BASE_URL);
|
setBaseUrl(DEFAULT_BASE_URL);
|
||||||
setClient(null);
|
setClient(null);
|
||||||
}, []);
|
clearUnauthorized();
|
||||||
|
}, [clearUnauthorized]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PostizContext.Provider
|
<PostizContext.Provider
|
||||||
@@ -129,6 +163,8 @@ export function PostizProvider({ children }: { children: React.ReactNode }) {
|
|||||||
baseUrl,
|
baseUrl,
|
||||||
isConfigured: !!apiKey,
|
isConfigured: !!apiKey,
|
||||||
isLoading,
|
isLoading,
|
||||||
|
unauthorized,
|
||||||
|
clearUnauthorized,
|
||||||
client,
|
client,
|
||||||
saveSettings,
|
saveSettings,
|
||||||
clearSettings,
|
clearSettings,
|
||||||
|
|||||||
@@ -4,20 +4,8 @@
|
|||||||
},
|
},
|
||||||
"build": {
|
"build": {
|
||||||
"preview": {
|
"preview": {
|
||||||
"android": {
|
"android": { "buildType": "apk" },
|
||||||
"buildType": "apk"
|
"ios": { "simulator": true }
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"production": {
|
|
||||||
"android": {
|
|
||||||
"buildType": "app-bundle"
|
|
||||||
},
|
|
||||||
"ios": {
|
|
||||||
"resourceClass": "m-medium"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"submit": {
|
|
||||||
"production": {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { useCallback, useEffect, useRef } from "react";
|
|||||||
import { Platform } from "react-native";
|
import { Platform } from "react-native";
|
||||||
import { usePostiz } from "@/context/PostizContext";
|
import { usePostiz } from "@/context/PostizContext";
|
||||||
import { PostizPost } from "@/context/PostizContext";
|
import { PostizPost } from "@/context/PostizContext";
|
||||||
|
import { stripHtml } from "@/lib/stripHtml";
|
||||||
|
|
||||||
const POLL_INTERVAL_MS = 15 * 60 * 1000;
|
const POLL_INTERVAL_MS = 15 * 60 * 1000;
|
||||||
const SEEN_KEY = "postiz_seen_statuses";
|
const SEEN_KEY = "postiz_seen_statuses";
|
||||||
@@ -44,10 +45,7 @@ async function sendStatusNotification(post: PostizPost) {
|
|||||||
await Notifications.scheduleNotificationAsync({
|
await Notifications.scheduleNotificationAsync({
|
||||||
content: {
|
content: {
|
||||||
title: isError ? "Post failed to publish" : "Post published!",
|
title: isError ? "Post failed to publish" : "Post published!",
|
||||||
body:
|
body: (() => { const t = stripHtml(post.content); return t.length > 80 ? t.slice(0, 80) + "…" : t; })(),
|
||||||
post.content.length > 80
|
|
||||||
? post.content.slice(0, 80) + "…"
|
|
||||||
: post.content,
|
|
||||||
data: { postId: post.id },
|
data: { postId: post.id },
|
||||||
},
|
},
|
||||||
trigger: null,
|
trigger: null,
|
||||||
|
|||||||
+46
@@ -0,0 +1,46 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# install-android-sdk.sh — Install Android SDK command-line tools only (no Android Studio).
|
||||||
|
# Installs to ~/android-sdk. Run once; takes ~1 GB of disk space.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
SDK_DIR="$HOME/android-sdk"
|
||||||
|
CMDLINE_TOOLS_URL="https://dl.google.com/android/repository/commandlinetools-linux-12266719_latest.zip"
|
||||||
|
CMDLINE_ZIP="/tmp/android-cmdline-tools.zip"
|
||||||
|
|
||||||
|
GREEN='\033[0;32m'; NC='\033[0m'
|
||||||
|
info() { echo -e "${GREEN}[sdk-install]${NC} $*"; }
|
||||||
|
|
||||||
|
if [ -d "$SDK_DIR/cmdline-tools/latest/bin" ]; then
|
||||||
|
info "Android SDK already installed at $SDK_DIR"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
info "Downloading Android command-line tools…"
|
||||||
|
wget -q --show-progress -O "$CMDLINE_ZIP" "$CMDLINE_TOOLS_URL"
|
||||||
|
|
||||||
|
info "Extracting…"
|
||||||
|
mkdir -p "$SDK_DIR/cmdline-tools"
|
||||||
|
unzip -q "$CMDLINE_ZIP" -d "$SDK_DIR/cmdline-tools"
|
||||||
|
mv "$SDK_DIR/cmdline-tools/cmdline-tools" "$SDK_DIR/cmdline-tools/latest"
|
||||||
|
rm "$CMDLINE_ZIP"
|
||||||
|
|
||||||
|
export ANDROID_HOME="$SDK_DIR"
|
||||||
|
export PATH="$PATH:$SDK_DIR/cmdline-tools/latest/bin:$SDK_DIR/platform-tools"
|
||||||
|
|
||||||
|
info "Accepting licenses…"
|
||||||
|
yes | sdkmanager --licenses > /dev/null 2>&1 || true
|
||||||
|
|
||||||
|
info "Installing SDK components (platform-tools, build-tools 35, NDK 28)…"
|
||||||
|
sdkmanager \
|
||||||
|
"platform-tools" \
|
||||||
|
"platforms;android-35" \
|
||||||
|
"build-tools;35.0.0" \
|
||||||
|
"ndk;28.2.13676358"
|
||||||
|
|
||||||
|
info "Done. Add this to your ~/.bashrc or ~/.zshrc:"
|
||||||
|
echo ""
|
||||||
|
echo ' export ANDROID_HOME="$HOME/android-sdk"'
|
||||||
|
echo ' export PATH="$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools"'
|
||||||
|
echo ""
|
||||||
|
info "Then reload your shell: source ~/.bashrc"
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
export function extractError(err: unknown): string {
|
||||||
|
if (axios.isAxiosError(err)) {
|
||||||
|
const status = err.response?.status;
|
||||||
|
const data = err.response?.data;
|
||||||
|
if (data) {
|
||||||
|
const body =
|
||||||
|
typeof data === "string"
|
||||||
|
? data.slice(0, 200)
|
||||||
|
: (data?.message ?? data?.error ?? JSON.stringify(data)).toString().slice(0, 200);
|
||||||
|
return status ? `HTTP ${status}: ${body}` : body;
|
||||||
|
}
|
||||||
|
if (status) return `HTTP ${status} — ${err.message}`;
|
||||||
|
if (err.code === "ECONNABORTED") return "Request timed out. Check that the URL is reachable.";
|
||||||
|
if (err.message) return err.message;
|
||||||
|
}
|
||||||
|
if (err instanceof Error) return err.message;
|
||||||
|
return "Unknown error";
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
export function stripHtml(html: string): string {
|
||||||
|
// Decode entities first so encoded tags like <p> are also stripped
|
||||||
|
let s = html
|
||||||
|
.replace(/&/g, "&")
|
||||||
|
.replace(/</g, "<")
|
||||||
|
.replace(/>/g, ">")
|
||||||
|
.replace(/"/g, '"')
|
||||||
|
.replace(/'/g, "'")
|
||||||
|
.replace(/ /g, " ");
|
||||||
|
// Block-level tags → newlines
|
||||||
|
s = s
|
||||||
|
.replace(/<br\s*\/?>/gi, "\n")
|
||||||
|
.replace(/<\/p>/gi, "\n")
|
||||||
|
.replace(/<\/div>/gi, "\n")
|
||||||
|
.replace(/<\/li>/gi, "\n");
|
||||||
|
// Strip all remaining tags
|
||||||
|
s = s.replace(/<[^>]+>/g, "");
|
||||||
|
return s.replace(/\n{3,}/g, "\n\n").trim();
|
||||||
|
}
|
||||||
@@ -1,3 +1,16 @@
|
|||||||
const { getDefaultConfig } = require("expo/metro-config");
|
const { getDefaultConfig } = require("expo/metro-config");
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
module.exports = getDefaultConfig(__dirname);
|
const projectRoot = __dirname;
|
||||||
|
const workspaceRoot = path.resolve(projectRoot, "../..");
|
||||||
|
|
||||||
|
const config = getDefaultConfig(projectRoot);
|
||||||
|
|
||||||
|
// pnpm monorepo: expose workspace root node_modules to Metro
|
||||||
|
config.watchFolders = [workspaceRoot];
|
||||||
|
config.resolver.nodeModulesPaths = [
|
||||||
|
path.resolve(projectRoot, "node_modules"),
|
||||||
|
path.resolve(workspaceRoot, "node_modules"),
|
||||||
|
];
|
||||||
|
|
||||||
|
module.exports = config;
|
||||||
|
|||||||
@@ -4,13 +4,16 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"main": "expo-router/entry",
|
"main": "expo-router/entry",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "EXPO_PACKAGER_PROXY_URL=https://$REPLIT_EXPO_DEV_DOMAIN EXPO_PUBLIC_DOMAIN=$REPLIT_DEV_DOMAIN EXPO_PUBLIC_REPL_ID=$REPL_ID REACT_NATIVE_PACKAGER_HOSTNAME=$REPLIT_DEV_DOMAIN pnpm exec expo start --localhost --port $PORT",
|
"dev": "pnpm exec expo start",
|
||||||
"build": "node scripts/build.js",
|
"build": "node scripts/build.js",
|
||||||
"serve": "node server/serve.js",
|
"serve": "node server/serve.js",
|
||||||
"typecheck": "tsc -p tsconfig.json --noEmit"
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
||||||
|
"android": "expo run:android",
|
||||||
|
"ios": "expo run:ios"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.25.2",
|
"@babel/core": "^7.25.2",
|
||||||
|
"babel-preset-expo": "~54.0.10",
|
||||||
"@expo-google-fonts/inter": "^0.4.0",
|
"@expo-google-fonts/inter": "^0.4.0",
|
||||||
"@expo/cli": "54.0.23",
|
"@expo/cli": "54.0.23",
|
||||||
"@expo/ngrok": "^4.1.0",
|
"@expo/ngrok": "^4.1.0",
|
||||||
@@ -23,13 +26,14 @@
|
|||||||
"@ungap/structured-clone": "^1.3.0",
|
"@ungap/structured-clone": "^1.3.0",
|
||||||
"@workspace/api-client-react": "workspace:*",
|
"@workspace/api-client-react": "workspace:*",
|
||||||
"babel-plugin-react-compiler": "^19.0.0-beta-e993439-20250117",
|
"babel-plugin-react-compiler": "^19.0.0-beta-e993439-20250117",
|
||||||
"expo": "~54.0.27",
|
"expo": "~54.0.34",
|
||||||
"expo-blur": "~15.0.8",
|
"expo-blur": "~15.0.8",
|
||||||
"expo-constants": "~18.0.11",
|
"expo-constants": "~18.0.11",
|
||||||
"expo-font": "~14.0.10",
|
"expo-font": "~14.0.10",
|
||||||
"expo-glass-effect": "~0.1.4",
|
"expo-glass-effect": "~0.1.4",
|
||||||
"expo-haptics": "~15.0.8",
|
"expo-haptics": "~15.0.8",
|
||||||
"expo-image": "~3.0.11",
|
"expo-image": "~3.0.11",
|
||||||
|
"expo-image-manipulator": "~13.0.6",
|
||||||
"expo-image-picker": "~17.0.9",
|
"expo-image-picker": "~17.0.9",
|
||||||
"expo-linear-gradient": "~15.0.8",
|
"expo-linear-gradient": "~15.0.8",
|
||||||
"expo-linking": "~8.0.10",
|
"expo-linking": "~8.0.10",
|
||||||
@@ -58,9 +62,12 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-native-community/datetimepicker": "8.4.4",
|
"@react-native-community/datetimepicker": "8.4.4",
|
||||||
"axios": "^1.15.2",
|
"axios": "^1.15.2",
|
||||||
|
"expo-clipboard": "~8.0.8",
|
||||||
"expo-notifications": "~0.32.17",
|
"expo-notifications": "~0.32.17",
|
||||||
"expo-secure-store": "~15.0.8",
|
"expo-secure-store": "~15.0.8",
|
||||||
"expo-task-manager": "~14.0.9",
|
"react-native-calendars": "^1.1314.0",
|
||||||
"react-native-calendars": "^1.1314.0"
|
"expo": "~54.0.34",
|
||||||
|
"react": "19.1.0",
|
||||||
|
"react-native": "0.81.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,20 +55,12 @@ function stripProtocol(domain) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getDeploymentDomain() {
|
function getDeploymentDomain() {
|
||||||
if (process.env.REPLIT_INTERNAL_APP_DOMAIN) {
|
|
||||||
return stripProtocol(process.env.REPLIT_INTERNAL_APP_DOMAIN);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.env.REPLIT_DEV_DOMAIN) {
|
|
||||||
return stripProtocol(process.env.REPLIT_DEV_DOMAIN);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.env.EXPO_PUBLIC_DOMAIN) {
|
if (process.env.EXPO_PUBLIC_DOMAIN) {
|
||||||
return stripProtocol(process.env.EXPO_PUBLIC_DOMAIN);
|
return stripProtocol(process.env.EXPO_PUBLIC_DOMAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.error(
|
console.error(
|
||||||
"ERROR: No deployment domain found. Set REPLIT_INTERNAL_APP_DOMAIN, REPLIT_DEV_DOMAIN, or EXPO_PUBLIC_DOMAIN",
|
"ERROR: No deployment domain found. Set EXPO_PUBLIC_DOMAIN.",
|
||||||
);
|
);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
@@ -124,7 +116,7 @@ async function checkMetroHealth() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getExpoPublicReplId() {
|
function getExpoPublicReplId() {
|
||||||
return process.env.REPL_ID || process.env.EXPO_PUBLIC_REPL_ID;
|
return process.env.EXPO_PUBLIC_REPL_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startMetro(expoPublicDomain, expoPublicReplId) {
|
async function startMetro(expoPublicDomain, expoPublicReplId) {
|
||||||
|
|||||||
Generated
+52
-21
@@ -398,15 +398,15 @@ importers:
|
|||||||
axios:
|
axios:
|
||||||
specifier: ^1.15.2
|
specifier: ^1.15.2
|
||||||
version: 1.15.2
|
version: 1.15.2
|
||||||
|
expo-clipboard:
|
||||||
|
specifier: ~8.0.8
|
||||||
|
version: 8.0.8(expo@54.0.34)(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)
|
||||||
expo-notifications:
|
expo-notifications:
|
||||||
specifier: ~0.32.17
|
specifier: ~0.32.17
|
||||||
version: 0.32.17(expo@54.0.34)(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)(typescript@5.9.3)
|
version: 0.32.17(expo@54.0.34)(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)(typescript@5.9.3)
|
||||||
expo-secure-store:
|
expo-secure-store:
|
||||||
specifier: ~15.0.8
|
specifier: ~15.0.8
|
||||||
version: 15.0.8(expo@54.0.34)
|
version: 15.0.8(expo@54.0.34)
|
||||||
expo-task-manager:
|
|
||||||
specifier: ~14.0.9
|
|
||||||
version: 14.0.9(expo@54.0.34)(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))
|
|
||||||
react-native-calendars:
|
react-native-calendars:
|
||||||
specifier: ^1.1314.0
|
specifier: ^1.1314.0
|
||||||
version: 1.1314.0(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)
|
version: 1.1314.0(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)
|
||||||
@@ -450,8 +450,11 @@ importers:
|
|||||||
babel-plugin-react-compiler:
|
babel-plugin-react-compiler:
|
||||||
specifier: ^19.0.0-beta-e993439-20250117
|
specifier: ^19.0.0-beta-e993439-20250117
|
||||||
version: 19.0.0-beta-ebf51a3-20250411
|
version: 19.0.0-beta-ebf51a3-20250411
|
||||||
|
babel-preset-expo:
|
||||||
|
specifier: ~54.0.10
|
||||||
|
version: 54.0.10(@babel/core@7.29.0)(@babel/runtime@7.28.6)(expo@54.0.34)(react-refresh@0.18.0)
|
||||||
expo:
|
expo:
|
||||||
specifier: ~54.0.27
|
specifier: ~54.0.34
|
||||||
version: 54.0.34(@babel/core@7.29.0)(@expo/metro-runtime@6.1.2)(expo-router@6.0.23)(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)(typescript@5.9.3)
|
version: 54.0.34(@babel/core@7.29.0)(@expo/metro-runtime@6.1.2)(expo-router@6.0.23)(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)(typescript@5.9.3)
|
||||||
expo-blur:
|
expo-blur:
|
||||||
specifier: ~15.0.8
|
specifier: ~15.0.8
|
||||||
@@ -3384,6 +3387,13 @@ packages:
|
|||||||
react: '*'
|
react: '*'
|
||||||
react-native: '*'
|
react-native: '*'
|
||||||
|
|
||||||
|
expo-clipboard@8.0.8:
|
||||||
|
resolution: {integrity: sha512-VKoBkHIpZZDJTB0jRO4/PZskHdMNOEz3P/41tmM6fDuODMpqhvyWK053X0ebspkxiawJX9lX33JXHBCvVsTTOA==}
|
||||||
|
peerDependencies:
|
||||||
|
expo: '*'
|
||||||
|
react: '*'
|
||||||
|
react-native: '*'
|
||||||
|
|
||||||
expo-constants@18.0.13:
|
expo-constants@18.0.13:
|
||||||
resolution: {integrity: sha512-FnZn12E1dRYKDHlAdIyNFhBurKTS3F9CrfrBDJI5m3D7U17KBHMQ6JEfYlSj7LG7t+Ulr+IKaj58L1k5gBwTcQ==}
|
resolution: {integrity: sha512-FnZn12E1dRYKDHlAdIyNFhBurKTS3F9CrfrBDJI5m3D7U17KBHMQ6JEfYlSj7LG7t+Ulr+IKaj58L1k5gBwTcQ==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -3546,12 +3556,6 @@ packages:
|
|||||||
react-native-web:
|
react-native-web:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
expo-task-manager@14.0.9:
|
|
||||||
resolution: {integrity: sha512-GKWtXrkedr4XChHfTm5IyTcSfMtCPxzx89y4CMVqKfyfROATibrE/8UI5j7UC/pUOfFoYlQvulQEvECMreYuUA==}
|
|
||||||
peerDependencies:
|
|
||||||
expo: '*'
|
|
||||||
react-native: '*'
|
|
||||||
|
|
||||||
expo-web-browser@15.0.11:
|
expo-web-browser@15.0.11:
|
||||||
resolution: {integrity: sha512-r2LS4Ro6DgUPZkcaEfgt8mp9eJuoA93x11Jh7S6utFe0FEzvUNn2yFhxg8XVwESaaHGt2k5V8LuK36rsp0BeIw==}
|
resolution: {integrity: sha512-r2LS4Ro6DgUPZkcaEfgt8mp9eJuoA93x11Jh7S6utFe0FEzvUNn2yFhxg8XVwESaaHGt2k5V8LuK36rsp0BeIw==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -5571,9 +5575,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-wH590V9VNgYH9g3lH9wWjTrUoKsjLF6sGLjhR4sH1LWpLmCOH0Zf7PukhDA8BiS7KHe4oPNkcTHqYkj7SOGUOw==}
|
resolution: {integrity: sha512-wH590V9VNgYH9g3lH9wWjTrUoKsjLF6sGLjhR4sH1LWpLmCOH0Zf7PukhDA8BiS7KHe4oPNkcTHqYkj7SOGUOw==}
|
||||||
engines: {node: '>=20'}
|
engines: {node: '>=20'}
|
||||||
|
|
||||||
unimodules-app-loader@6.0.8:
|
|
||||||
resolution: {integrity: sha512-fqS8QwT/MC/HAmw1NKCHdzsPA6WaLm0dNmoC5Pz6lL+cDGYeYCNdHMO9fy08aL2ZD7cVkNM0pSR/AoNRe+rslA==}
|
|
||||||
|
|
||||||
universalify@2.0.1:
|
universalify@2.0.1:
|
||||||
resolution: {integrity: sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==}
|
resolution: {integrity: sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==}
|
||||||
engines: {node: '>= 10.0.0'}
|
engines: {node: '>= 10.0.0'}
|
||||||
@@ -8773,6 +8774,38 @@ snapshots:
|
|||||||
- '@babel/core'
|
- '@babel/core'
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
|
babel-preset-expo@54.0.10(@babel/core@7.29.0)(@babel/runtime@7.28.6)(expo@54.0.34)(react-refresh@0.18.0):
|
||||||
|
dependencies:
|
||||||
|
'@babel/helper-module-imports': 7.28.6
|
||||||
|
'@babel/plugin-proposal-decorators': 7.29.0(@babel/core@7.29.0)
|
||||||
|
'@babel/plugin-proposal-export-default-from': 7.27.1(@babel/core@7.29.0)
|
||||||
|
'@babel/plugin-syntax-export-default-from': 7.28.6(@babel/core@7.29.0)
|
||||||
|
'@babel/plugin-transform-class-static-block': 7.28.6(@babel/core@7.29.0)
|
||||||
|
'@babel/plugin-transform-export-namespace-from': 7.27.1(@babel/core@7.29.0)
|
||||||
|
'@babel/plugin-transform-flow-strip-types': 7.27.1(@babel/core@7.29.0)
|
||||||
|
'@babel/plugin-transform-modules-commonjs': 7.28.6(@babel/core@7.29.0)
|
||||||
|
'@babel/plugin-transform-object-rest-spread': 7.28.6(@babel/core@7.29.0)
|
||||||
|
'@babel/plugin-transform-parameters': 7.27.7(@babel/core@7.29.0)
|
||||||
|
'@babel/plugin-transform-private-methods': 7.28.6(@babel/core@7.29.0)
|
||||||
|
'@babel/plugin-transform-private-property-in-object': 7.28.6(@babel/core@7.29.0)
|
||||||
|
'@babel/plugin-transform-runtime': 7.29.0(@babel/core@7.29.0)
|
||||||
|
'@babel/preset-react': 7.28.5(@babel/core@7.29.0)
|
||||||
|
'@babel/preset-typescript': 7.28.5(@babel/core@7.29.0)
|
||||||
|
'@react-native/babel-preset': 0.81.5(@babel/core@7.29.0)
|
||||||
|
babel-plugin-react-compiler: 1.0.0
|
||||||
|
babel-plugin-react-native-web: 0.21.2
|
||||||
|
babel-plugin-syntax-hermes-parser: 0.29.1
|
||||||
|
babel-plugin-transform-flow-enums: 0.0.2(@babel/core@7.29.0)
|
||||||
|
debug: 4.4.3
|
||||||
|
react-refresh: 0.18.0
|
||||||
|
resolve-from: 5.0.0
|
||||||
|
optionalDependencies:
|
||||||
|
'@babel/runtime': 7.28.6
|
||||||
|
expo: 54.0.34(@babel/core@7.29.0)(@expo/metro-runtime@6.1.2)(expo-router@6.0.23)(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)(typescript@5.9.3)
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- '@babel/core'
|
||||||
|
- supports-color
|
||||||
|
|
||||||
babel-preset-jest@29.6.3(@babel/core@7.29.0):
|
babel-preset-jest@29.6.3(@babel/core@7.29.0):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/core': 7.29.0
|
'@babel/core': 7.29.0
|
||||||
@@ -9386,6 +9419,12 @@ snapshots:
|
|||||||
react: 19.1.0
|
react: 19.1.0
|
||||||
react-native: 0.81.5(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0)
|
react-native: 0.81.5(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0)
|
||||||
|
|
||||||
|
expo-clipboard@8.0.8(expo@54.0.34)(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0):
|
||||||
|
dependencies:
|
||||||
|
expo: 54.0.34(@babel/core@7.29.0)(@expo/metro-runtime@6.1.2)(expo-router@6.0.23)(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)(typescript@5.9.3)
|
||||||
|
react: 19.1.0
|
||||||
|
react-native: 0.81.5(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0)
|
||||||
|
|
||||||
expo-constants@18.0.13(expo@54.0.34)(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0)):
|
expo-constants@18.0.13(expo@54.0.34)(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0)):
|
||||||
dependencies:
|
dependencies:
|
||||||
'@expo/config': 12.0.13
|
'@expo/config': 12.0.13
|
||||||
@@ -9569,12 +9608,6 @@ snapshots:
|
|||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
|
|
||||||
expo-task-manager@14.0.9(expo@54.0.34)(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0)):
|
|
||||||
dependencies:
|
|
||||||
expo: 54.0.34(@babel/core@7.29.0)(@expo/metro-runtime@6.1.2)(expo-router@6.0.23)(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)(typescript@5.9.3)
|
|
||||||
react-native: 0.81.5(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0)
|
|
||||||
unimodules-app-loader: 6.0.8
|
|
||||||
|
|
||||||
expo-web-browser@15.0.11(expo@54.0.34)(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0)):
|
expo-web-browser@15.0.11(expo@54.0.34)(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0)):
|
||||||
dependencies:
|
dependencies:
|
||||||
expo: 54.0.34(@babel/core@7.29.0)(@expo/metro-runtime@6.1.2)(expo-router@6.0.23)(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)(typescript@5.9.3)
|
expo: 54.0.34(@babel/core@7.29.0)(@expo/metro-runtime@6.1.2)(expo-router@6.0.23)(react-native@0.81.5(@babel/core@7.29.0)(@types/react@19.1.17)(react@19.1.0))(react@19.1.0)(typescript@5.9.3)
|
||||||
@@ -11918,8 +11951,6 @@ snapshots:
|
|||||||
|
|
||||||
unicorn-magic@0.4.0: {}
|
unicorn-magic@0.4.0: {}
|
||||||
|
|
||||||
unimodules-app-loader@6.0.8: {}
|
|
||||||
|
|
||||||
universalify@2.0.1: {}
|
universalify@2.0.1: {}
|
||||||
|
|
||||||
unpipe@1.0.0: {}
|
unpipe@1.0.0: {}
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
# Workspace
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
|
|
||||||
pnpm workspace monorepo using TypeScript. Each package manages its own dependencies.
|
|
||||||
|
|
||||||
## Stack
|
|
||||||
|
|
||||||
- **Monorepo tool**: pnpm workspaces
|
|
||||||
- **Node.js version**: 24
|
|
||||||
- **Package manager**: pnpm
|
|
||||||
- **TypeScript version**: 5.9
|
|
||||||
- **API framework**: Express 5
|
|
||||||
- **Database**: PostgreSQL + Drizzle ORM
|
|
||||||
- **Validation**: Zod (`zod/v4`), `drizzle-zod`
|
|
||||||
- **API codegen**: Orval (from OpenAPI spec)
|
|
||||||
- **Build**: esbuild (CJS bundle)
|
|
||||||
|
|
||||||
## Artifacts
|
|
||||||
|
|
||||||
### PostizMobile (`artifacts/postiz-mobile`)
|
|
||||||
Expo (React Native) mobile client for a self-hosted Postiz instance.
|
|
||||||
|
|
||||||
- **Preview path**: `/`
|
|
||||||
- **Theme**: Dark-only (`userInterfaceStyle: dark`)
|
|
||||||
- **Auth**: API key stored in `expo-secure-store`, passed as `Authorization` header
|
|
||||||
|
|
||||||
#### Screens / Tabs
|
|
||||||
1. **Calendar** (`app/(tabs)/index.tsx`) — Monthly calendar with post dots, tap day to see posts
|
|
||||||
2. **Posts** (`app/(tabs)/posts.tsx`) — Filterable list of posts with status badges, swipe to delete
|
|
||||||
3. **Compose** (`app/(tabs)/compose.tsx`) — Text editor, channel picker, date/time picker, image upload
|
|
||||||
4. **Settings** (`app/(tabs)/settings.tsx`) — API key + base URL, validation, SecureStore persistence
|
|
||||||
|
|
||||||
#### Key Files
|
|
||||||
- `context/PostizContext.tsx` — Axios client wired with API key/base URL; loaded from SecureStore on boot
|
|
||||||
- `components/PostCard.tsx` — Swipeable post card with delete action
|
|
||||||
- `components/StatusBadge.tsx` — QUEUE / PUBLISHED / ERROR / DRAFT badges
|
|
||||||
- `components/ChannelChip.tsx` — Integration channel selector chip
|
|
||||||
|
|
||||||
#### External API
|
|
||||||
- Base URL: `https://postiz.gyozamancave.fr/public/v1` (configurable)
|
|
||||||
- `GET /integrations` — List channels
|
|
||||||
- `GET /posts?startDate&endDate` — List posts
|
|
||||||
- `POST /posts` — Create/schedule post
|
|
||||||
- `DELETE /posts/:id` — Delete post
|
|
||||||
- `POST /upload` — Upload media
|
|
||||||
|
|
||||||
#### Packages Added
|
|
||||||
- `axios` — HTTP client
|
|
||||||
- `expo-secure-store` — Secure API key storage
|
|
||||||
- `react-native-calendars` — Calendar UI
|
|
||||||
- `@react-native-community/datetimepicker` — Date/time picker for compose
|
|
||||||
|
|
||||||
### API Server (`artifacts/api-server`)
|
|
||||||
Express 5 backend. Currently serves `/api/healthz`. Extend for server-side features.
|
|
||||||
|
|
||||||
## Key Commands
|
|
||||||
|
|
||||||
- `pnpm run typecheck` — full typecheck across all packages
|
|
||||||
- `pnpm run build` — typecheck + build all packages
|
|
||||||
- `pnpm --filter @workspace/api-spec run codegen` — regenerate API hooks and Zod schemas from OpenAPI spec
|
|
||||||
- `pnpm --filter @workspace/db run push` — push DB schema changes (dev only)
|
|
||||||
|
|
||||||
See the `pnpm-workspace` skill for workspace structure, TypeScript setup, and package details.
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
GITEA_HOST="homegit.gyozamancave.fr"
|
|
||||||
GITEA_USER="billisdead"
|
|
||||||
GITEA_REPO="Postiz-android"
|
|
||||||
GITEA_REMOTE_NAME="gitea"
|
|
||||||
GITEA_REMOTE_URL="https://${GITEA_HOST}/${GITEA_USER}/${GITEA_REPO}.git"
|
|
||||||
|
|
||||||
if [ -z "${GITEA_SSH_KEY:-}" ]; then
|
|
||||||
echo "Error: GITEA_SSH_KEY environment variable is not set. Add the Gitea API token as a Replit secret named GITEA_SSH_KEY." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if git remote get-url "$GITEA_REMOTE_NAME" &>/dev/null; then
|
|
||||||
git remote set-url "$GITEA_REMOTE_NAME" "$GITEA_REMOTE_URL"
|
|
||||||
else
|
|
||||||
git remote add "$GITEA_REMOTE_NAME" "$GITEA_REMOTE_URL"
|
|
||||||
echo "Added remote '$GITEA_REMOTE_NAME'."
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Pushing main branch to Gitea..."
|
|
||||||
git -c "http.extraHeader=Authorization: token ${GITEA_SSH_KEY}" \
|
|
||||||
push --force "$GITEA_REMOTE_NAME" main
|
|
||||||
echo "Push to Gitea complete."
|
|
||||||
Reference in New Issue
Block a user