Skip to content

Feat: fix delete and add image in timeline#97

Merged
destucr merged 4 commits intodevelopmentfrom
feat/timeline-merge
Nov 30, 2025
Merged

Feat: fix delete and add image in timeline#97
destucr merged 4 commits intodevelopmentfrom
feat/timeline-merge

Conversation

@destucr
Copy link
Contributor

@destucr destucr commented Nov 30, 2025

🎯 Summary

This PR introduces support for saving, syncing, and managing "Moments" (image-based records) alongside existing heartbeat recordings. It adds a new data model for moments, updates the audio manager to handle both heartbeats and moments, and ensures both types of data can be synced with Firebase and managed locally. Additionally, it enhances the heartbeat model with a custom display name and pregnancy week tracking, and adds robust deletion logic for both heartbeats and moments.

✨ Features/Changes

  • Added SavedMoment model for storing image-based moments with Firebase sync support and pregnancy week tracking
  • Enhanced SavedHeartbeat model with custom displayName property and automatic pregnancy week calculation
  • Implemented comprehensive moment management (load, save, delete) with local and Firebase synchronization
  • Added deleteRecording and deleteMoment methods for robust deletion of heartbeats and moments with disk cleanup
  • Updated SwiftData container to register both SavedHeartbeat and SavedMoment models
  • Improved serialization/deserialization logic for heartbeat data to support custom names
  • Fixed potential bug in Firebase URL parsing

📁 Files Changed

  • Tiny/Core/Models/SavedMomentModel.swift - New model for image moments with Firebase sync, pregnancy week, and metadata fields
  • Tiny/Core/Models/SavedHeartbeatModel.swift - Added displayName property and updated initializer and serialization logic
  • Tiny/App/tinyApp.swift - Updated SwiftData container to register both SavedHeartbeat and SavedMoment models
  • Tiny/Core/Services/Audio/HeartbeatSoundManager.swift - Added moment management, deletion methods, pregnancy week calculation, and savedMoments array with Firebase sync
  • Tiny/Core/Services/Storage/FirebaseStorageService.swift - Fixed unused variable in Firebase URL parsing

🔧 Usage Examples (if applicable)

// Save a moment with image
let moment = SavedMoment(
    imageData: imageData,
    pregnancyWeek: 24,
    isSyncedWithFirebase: false
)
audioManager.saveMoment(moment)

// Save a heartbeat with custom display name
let heartbeat = SavedHeartbeat(
    displayName: "Baby's First Heartbeat",
    pregnancyWeek: 12,
    audioData: recordingData
)

// Delete a recording
audioManager.deleteRecording(heartbeat)

// Delete a moment
audioManager.deleteMoment(moment)

@destucr destucr merged commit 41ccc9a into development Nov 30, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants