@@ -58,11 +58,39 @@ extension AppBskyLexicon.Feed.FeedViewPostDefinition: Identifiable {
5858 return self . post. uri
5959 }
6060
61- public func refresh( with sessionConfiguration: SessionConfiguration ) async throws -> AppBskyLexicon . Feed . FeedViewPostDefinition {
62- let atProto = await ATProtoKit ( sessionConfiguration: sessionConfiguration, canUseBlueskyRecords: false )
63- let record = try await atProto. getFeed ( by: self . post. uri)
61+ /// Refreshes the record view with updated information.
62+ ///
63+ /// You need to pass in the instance of ``SessionConfiguration`` in order to establish
64+ /// a connection. Once that happens, use the appropriate method to get the record view.
65+ /// For example, for ``AppBskyLexicon/Feed/PostViewDefinition``, you can use
66+ /// ``ATProtoKit/ATProtoKit/getPosts(_:)``, which returns that object.
67+ ///
68+ ///
69+ ///
70+ /// - Parameters:
71+ /// - atProtoKitConfiguration: An instance of ``ATProtoKit/ATProtoKit``.
72+ /// - array: The array of the
73+ /// - index: The index number
74+ /// - feedURI: The URI of the feed.
75+ /// - Returns: An updated version of the feed's array.
76+ ///
77+ /// - Throws: An ``ATProtoError``-conforming error type, depending on the issue. Go to
78+ /// ``ATAPIError`` and ``ATRequestPrepareError`` for more details.
79+ public func refresh(
80+ with atProtoKitConfiguration: ATProtoKit ,
81+ from array: [ AppBskyLexicon . Feed . FeedViewPostDefinition ] ,
82+ at index: Int ,
83+ feedURI: String
84+ ) async throws -> [ AppBskyLexicon . Feed . FeedViewPostDefinition ] {
85+ let post = try await atProtoKitConfiguration. getFeed ( by: feedURI) . feed [ index]
86+
87+ if index > 99 {
88+ throw FeedViewPostDefinitionError . indexTooHigh ( index: index)
89+ }
6490
65- return record. feed [ 0 ]
91+ var newArray = array
92+ newArray [ index] = post
93+ return newArray
6694 }
6795}
6896
0 commit comments