AOSSIE-Org / AOSSIE-Org/Resonate

Refactor ApiService to improve robustness and eliminate duplicated execution logic

Open
#766 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
344
Forks
350
PR merge metrics
No merged PRs in 30d

Description

### 🐛 Describe the bug

A clear and concise description of what the bug is.

The current ApiService implementation repeats the same function execution logic across multiple methods (createRoom, joinRoom, deleteRoom, createLiveChapterRoom, etc.).

Each method individually:
- Calls an Appwrite function
- Checks for HTTP 200 status
- Decodes the JSON response
- Returns Map

This results in duplicated logic and assumes that:
- The response body is always valid JSON
- The decoded value is always a JSON object (Map)
- The function call will always return without hanging

If the response format changes or returns malformed JSON, jsonDecode may throw a runtime error. Additionally, the current implementation has no timeout protection, meaning a hanging function call could block indefinitely.

This is not currently causing a visible bug, but it introduces unnecessary risk and maintenance overhead.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.