Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: only show local timeline #7

Merged
merged 27 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e15c020
feat: basic login
lcandy2 Jan 5, 2025
2fdbc6c
feat: successful login
lcandy2 Jan 5, 2025
5e06293
feat: save credentials with keychain-swift
lcandy2 Jan 5, 2025
0f58dea
feat: adjust log
lcandy2 Jan 5, 2025
4e3fbc8
feat: switch instances
lcandy2 Jan 5, 2025
288e9ae
feat: lowercase server address
lcandy2 Jan 5, 2025
5b99ee1
fix: non-neodb.social instance cannot login
lcandy2 Jan 5, 2025
284c37d
feat: user api
lcandy2 Jan 5, 2025
313e684
feat: make llm knows keychain-swift is already added
lcandy2 Jan 5, 2025
b306a05
feat: custom ContentUnavailableView
lcandy2 Jan 5, 2025
7ba7b56
feat: profile view
lcandy2 Jan 5, 2025
29cfdb7
feat: feat inject
lcandy2 Jan 5, 2025
c27f704
feat: new profile view design
lcandy2 Jan 5, 2025
b0cbfb6
feat: injection
lcandy2 Jan 5, 2025
bcc9f22
feat: new profile design
lcandy2 Jan 5, 2025
cb5c8b9
feat: injection next
lcandy2 Jan 5, 2025
33f4dec
feat: redesigned profile
lcandy2 Jan 5, 2025
872d5c4
refactor: replace @StateObject with @EnvironmentObject for AuthServic…
lcandy2 Jan 5, 2025
0ee94fa
feat: implement user caching and refresh functionality in UserService…
lcandy2 Jan 5, 2025
08d51ed
refactor: enhance ProfileView layout and loading state handling
lcandy2 Jan 5, 2025
1288f3d
chore: remove outdated Project Structure documentation and update log…
lcandy2 Jan 5, 2025
8c84af3
refactor: update ContentView to use HomeView and remove unused code
lcandy2 Jan 5, 2025
c9c0996
refactor: update Status model and TimelineService for improved data h…
lcandy2 Jan 5, 2025
5eb1e1f
Merge branch 'main' into feat/timeline
lcandy2 Jan 5, 2025
3ad1e1f
Merge branch 'main' into feat/timeline
lcandy2 Jan 5, 2025
dae17b6
refactor: update TimelineService to local only
lcandy2 Jan 8, 2025
3fce553
Merge branch 'main' into feat/timeline
lcandy2 Jan 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion NeoDB/NeoDB/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ struct ContentView: View {
}
}
.tint(.accentColor)
.enableInjection()
}

#if DEBUG
Expand Down
26 changes: 26 additions & 0 deletions NeoDB/NeoDB/References/Cursor/timeline_local.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Timeline Local-Only Implementation

## Overview
Modified TimelineService to show only local statuses from the instance.

## API Reference
From Mastodon API documentation:
- Endpoint: GET `/api/v1/timelines/public`
- Parameter: `local=true` to show only local statuses
- Default: Shows both local and remote statuses (local=false)

## Implementation Details
1. Added local parameter to URL query
2. Set local=true by default to show only local statuses
3. Improved error logging for better debugging

## Design Rationale
- Local-only timeline provides more relevant content for NeoDB users
- Reduces noise from remote instances
- Improves performance by reducing data load
- Better content moderation as all content is from the same instance

## Code Changes
- Modified getTimeline method in TimelineService
- Added local parameter to URLComponents
- Updated documentation
7 changes: 5 additions & 2 deletions NeoDB/NeoDB/Services/Network/TimelineService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TimelineService {
}
}

func getTimeline(maxId: String? = nil, sinceId: String? = nil, minId: String? = nil, limit: Int = 20) async throws -> [Status] {
func getTimeline(maxId: String? = nil, sinceId: String? = nil, minId: String? = nil, limit: Int = 20, local: Bool = true) async throws -> [Status] {
guard let accessToken = authService.accessToken else {
logger.error("No access token available")
throw AuthError.unauthorized
Expand All @@ -41,6 +41,9 @@ class TimelineService {
var components = URLComponents(string: "\(baseURL)/api/v1/timelines/public")!

var queryItems = [URLQueryItem]()
// Always add local=true to show only local statuses
queryItems.append(URLQueryItem(name: "local", value: String(local)))

if let maxId = maxId {
queryItems.append(URLQueryItem(name: "max_id", value: maxId))
}
Expand Down Expand Up @@ -88,7 +91,7 @@ class TimelineService {

do {
let statuses = try decoder.decode([Status].self, from: data)
logger.debug("Successfully decoded \(statuses.count) statuses")
logger.debug("Successfully decoded \(statuses.count) local statuses")
return statuses
} catch {
logger.error("Decoding error: \(error.localizedDescription)")
Expand Down