APP-iOS3rd / PJ3T2_Mymory

멋쟁이사자처럼 iOS 앱스쿨 3기 팀 프로젝트
10 stars 3 forks source link

[Feat/pagenation] : 페이지네이션(무한스크롤)을 구현했습니다. #131

Closed Seobe95 closed 7 months ago

Seobe95 commented 7 months ago

PR 가이드라인

PR Checklist

PR 날릴 때 체크 리스트

PR Type

어떤 종류의 PR인가요?

연관되는 issue 정보를 알려주세요

Issue Number: #130

PR 설명하기

페이지네이션을 구현했습니다!

어떻게 작동하나요? code 기반으로 설명해주세요

func pagenate(query: Query, limit: Int, lastDocument: QueryDocumentSnapshot?) async -> QuerySnapshot {
        do {
            var query: Query = query.order(by: "memoCreatedAt", descending: true)
                                    .limit(to: limit)

            if let lastDocument = lastDocument {
                query = query.start(afterDocument: lastDocument)
            }

            let querySnapshot = try await query.getDocuments()

            return querySnapshot
        } catch {
            fatalError("ERROR: querysnapshot \(error)")
        }
    }
    func pagenate(userID: String) async {
        let fetchedMemos = await self.memoService.fetchMyMemos(userID: userID, lastDocument: self.lastDocument) { last in
            self.lastDocument = last
        }

        await MainActor.run {
            self.memoList += fetchedMemos
        }
    }

가능하다면 추가해주세요

변경 사항 스크린샷 혹은 화면 녹화

스크린샷

https://github.com/APP-iOS3rd/PJ3T2_Mymory/assets/79817557/a6897e8c-cb1f-47e8-b068-31a9d97eebc9

Test 여부

Test 정보

//예시
let testDatas: [TestData] = [.init(...),...]

기타 언급해야 할 사항들

xohxe commented 7 months ago

무한스크롤 기능 여기저기 요긴하게 사용할 수 있겠네요! 고생하셨습니다 :)