Closed Veeit closed 3 years ago
Hello @Veeit ,
You need to hold a strong reference to timelineFlatFeed
.
Try this:
Client.config = .init(apiKey: "apiKey-is-hidden",
appId: "97497", logsEnabled: true)
let timelineFlatFeed = Client.shared.flatFeed(feedId)
Client.shared.setupUser(token: "token-is-hidden", completion: { result in
guard result.error == nil else {
preconditionFailure("Cannot setup user: \(result.error!)")
}
if let feedId = FeedId(feedSlug: "site") {
let timelineFlatFeed = Client.shared.flatFeed(feedId)
print("time line: ==== \(timelineFlatFeed)")
let seconds = 4.0
DispatchQueue.main.asyncAfter(deadline: .now() + seconds) {
timelineFlatFeed.get(enrich: true, pagination: .limit(2)) { response in
if (result.error != nil) {
print("error")
} else {
print("result")
}
}
}
}
})
Hello @b-onc ,
same result. I tried this code now:
Client.config = .init(apiKey: "ztyjtywyeb28",
appId: "97497", logsEnabled: true)
Client.shared.setupUser(token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiLTEifQ.4ttgLiot0zNIy1YOqENZz3YfsCLU3oej9n7l-m5Vcrw", completion: { result in
guard result.error == nil else {
preconditionFailure("Cannot setup user: \(result.error!)")
}
})
let timelineFlatFeed = Client.shared.flatFeed(feedSlug: "site")!
print("time line: ==== \(timelineFlatFeed)")
timelineFlatFeed.get(pagination: .limit(2)) { response in
print("===========")
print("===========")
print("===========")
print("===========")
print("===========")
if (response.error != nil) {
print("error")
} else {
print("result")
}
print("===========")
print("===========")
print("===========")
print("===========")
print("===========")
}
and got his console log:
๐ฐ Stream Feed v.1.0
๐ ztyjtywyeb28
๐ https://api.stream-io-api.com/api/v1.0/
๐ด [03/11 19:05:07.612] ๐งน Disconnect. Reset Client User, Token, URLSession and WebSocket. Old user id: <Empty>.
๐ด [03/11 19:05:07.616] ๐งน Disconnect. Reset Client User, Token, URLSession and WebSocket. Old user id: -1.
๐ค User id: -1
๐๏ธ Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiLTEifQ.4ttgLiot0zNIy1YOqENZz3YfsCLU3oej9n7l-m5Vcrw
๐ด [03/11 19:05:07.617] โก๏ธ create(GetStream.User, true)
๐ด [03/11 19:05:07.617] ๐งพ Request Data:
{
"id" : "-1"
}
๐ด [03/11 19:05:07.617] ๐งพ URL parameters: ["get_or_create": true]
time line: ==== site:-1
๐ด [03/11 19:05:07.623] โก๏ธ get(site:-1, true, GetStream.Pagination.limit(2), "", GetStream.FeedMarkOption.none, GetStream.FeedReactionsOptions(rawValue: 0))
๐ด [03/11 19:05:07.623] ๐งพ Parameters: ["limit": 2]
2020-11-03 19:05:07.749395+0100 TheStream[2736:110703] [] nw_protocol_get_quic_image_block_invoke dlopen libquic failed
๐ด [03/11 19:05:08.353] โฌ
๏ธ Response 201: https://api.stream-io-api.com/api/v1.0/user/?api_key=ztyjtywyeb28&get_or_create=1
๐ด [03/11 19:05:08.353] โฟโโโ 144 bytes
{
"duration" : "0.84ms",
"id" : "-1",
"data" : {
"name" : "Unknown"
},
"updated_at" : "2020-10-25T15:09:07.295895Z",
"created_at" : "2020-10-25T15:09:07.295895Z"
}
๐ด [03/11 19:05:08.357] ๐ค The current user was setupped with id: -1
๐ด [03/11 19:05:08.364] โฌ
๏ธ Response 200: https://api.stream-io-api.com/api/v1.0/enrich/feed/site/-1/?api_key=ztyjtywyeb28&limit=2
๐ด [03/11 19:05:08.365] โฟโโโ 6368 bytes
{
"results" : [
{
"id" : "ab63aa9c-1dfe-11eb-8080-80017832bb19",
"to" : [
"user:6764",
"tasks:6764"
],
"verb" : "complete",
"time" : "2020-11-03T18:01:59.926646",
"object_type" : "task",
"object" : {
"collection" : "enrichment_store",
"id" : "projects-Task-313718",
"data" : {
"description" : null,
"comment_count" : 0,
"id" : 313718,
"video" : null,
"project_set" : [
{
"id" : 14937,
"private" : false,
"name" : "tindericebreakers",
"user" : 6764
}
],
"created_at" : "2020-11-03T18:01:59.926646Z",
"event" : null,
"due_at" : null,
"done" : true,
"in_progress" : false,
"product_set" : [
],
"og_image" : "https:\/\/ik.imagekit.io\/makerlog\/media\/uploads\/tasks\/2020\/11\/03\/bcf2c8b2-335b-4941-b71e-dbabe2ee3971.jpg",
"attachment" : null,
"praise" : 0,
"done_at" : "2020-11-03T18:01:59.921280Z",
"updated_at" : "2020-11-03T18:04:15.707341Z",
"user" : {
"github_handle" : "AndreiChiha",
"hardcore_mode" : false,
"private" : false,
"last_name" : "Chihalau",
"shipstreams_handle" : "",
"donor" : false,
"id" : 6764,
"instagram_handle" : "",
"week_tda" : 2,
"nomadlist_handle" : "",
"description" : "Front-End Intern at Kappa.London",
"gold" : false,
"email_notifications" : true,
"interests" : [
],
"website" : "",
"digest" : true,
"twitter_handle" : "AChihalau",
"maker_score" : 51,
"accent" : "#00a676",
"bmc_handle" : "",
"dark_mode" : false,
"date_joined" : "2020-10-12T15:18:39.515474Z",
"is_live" : false,
"status" : null,
"avatar" : "https:\/\/ik.imagekit.io\/makerlog\/media\/uploads\/avatars\/2020\/10\/27\/kappa_logo_2.png",
"username" : "AChihalau",
"weekends_off" : false,
"first_name" : "Andrei",
"streak" : 1,
"tester" : false,
"product_hunt_handle" : "@andrei_chihalau",
"is_staff" : false,
"og_image" : "https:\/\/ik.imagekit.io\/makerlog\/media\/uploads\/og\/2020\/11\/03\/ed5b965a-f94a-45a3-91a5-1cea859575a1.jpg",
"header" : null,
"telegram_handle" : "",
"verified" : false,
"timezone" : "Europe\/Bucharest"
},
"content" : "Test the \"Saved Messages\" functionality +minor desigh changes #tindericebreakers"
},
"foreign_id" : "enrichment_store:projects-Task-313718",
"updated_at" : "2020-11-03T18:04:16.266444Z",
"created_at" : "2020-11-03T18:02:00.958077Z"
},
"actor" : {
"collection" : "enrichment_store",
"id" : "accounts-User-6764",
"data" : {
"github_handle" : "AndreiChiha",
"hardcore_mode" : false,
"private" : false,
"last_name" : "Chihalau",
"shipstreams_handle" : "",
"donor" : false,
"id" : 6764,
"instagram_handle" : "",
"week_tda" : 2,
"nomadlist_handle" : "",
"description" : "Front-End Intern at Kappa.London",
"gold" : false,
"email_notifications" : true,
"interests" : [
],
"website" : "",
"digest" : true,
"twitter_handle" : "AChihalau",
"maker_score" : 51,
"accent" : "#00a676",
"bmc_handle" : "",
"dark_mode" : false,
"date_joined" : "2020-10-12T15:18:39.515474Z",
"is_live" : false,
"status" : null,
"avatar" : "https:\/\/ik.imagekit.io\/makerlog\/media\/uploads\/avatars\/2020\/10\/27\/kappa_logo_2.png",
"username" : "AChihalau",
"weekends_off" : false,
"first_name" : "Andrei",
"streak" : 1,
"tester" : false,
"product_hunt_handle" : "@andrei_chihalau",
"is_staff" : false,
"og_image" : "https:\/\/ik.imagekit.io\/makerlog\/media\/uploads\/og\/2020\/11\/03\/ed5b965a-f94a-45a3-91a5-1cea859575a1.jpg",
"header" : null,
"telegram_handle" : "",
"verified" : false,
"timezone" : "Europe\/Bucharest"
},
"foreign_id" : "enrichment_store:accounts-User-6764",
"updated_at" : "2020-11-03T18:04:16.209898Z",
"created_at" : "2020-10-29T07:35:30.837139Z"
},
"origin" : null,
"target" : "",
"actor_type" : "user",
"target_type" : null,
"foreign_id" : "projects.Task:313718"
},
{
"id" : "a5c8aae2-1dfe-11eb-8080-80000a76d4ff",
"to" : [
"user:6764",
"tasks:6764"
],
"verb" : "complete",
"time" : "2020-11-03T18:01:50.522237",
"object_type" : "task",
"object" : {
"collection" : "enrichment_store",
"id" : "projects-Task-313717",
"data" : {
"description" : null,
"comment_count" : 0,
"id" : 313717,
"video" : null,
"project_set" : [
{
"id" : 14937,
"private" : false,
"name" : "tindericebreakers",
"user" : 6764
}
],
"created_at" : "2020-11-03T18:01:50.522237Z",
"event" : null,
"due_at" : null,
"done" : true,
"in_progress" : false,
"product_set" : [
],
"og_image" : null,
"attachment" : null,
"praise" : 0,
"done_at" : "2020-11-03T18:01:50.514718Z",
"updated_at" : "2020-11-03T18:01:50.522259Z",
"user" : {
"github_handle" : "AndreiChiha",
"hardcore_mode" : false,
"private" : false,
"last_name" : "Chihalau",
"shipstreams_handle" : "",
"donor" : false,
"id" : 6764,
"instagram_handle" : "",
"week_tda" : 2,
"nomadlist_handle" : "",
"description" : "Front-End Intern at Kappa.London",
"gold" : false,
"email_notifications" : true,
"interests" : [
],
"website" : "",
"digest" : true,
"twitter_handle" : "AChihalau",
"maker_score" : 53,
"accent" : "#00a676",
"bmc_handle" : "",
"dark_mode" : false,
"date_joined" : "2020-10-12T15:18:39.515474Z",
"is_live" : false,
"status" : null,
"avatar" : "https:\/\/ik.imagekit.io\/makerlog\/media\/uploads\/avatars\/2020\/10\/27\/kappa_logo_2.png",
"username" : "AChihalau",
"weekends_off" : false,
"first_name" : "Andrei",
"streak" : 1,
"tester" : false,
"product_hunt_handle" : "@andrei_chihalau",
"is_staff" : false,
"og_image" : "https:\/\/ik.imagekit.io\/makerlog\/media\/uploads\/og\/2020\/11\/02\/b35cc84a-9c3e-4d6c-8d3a-7a57b2ec5dcb.jpg",
"header" : null,
"telegram_handle" : "",
"verified" : false,
"timezone" : "Europe\/Bucharest"
},
"content" : "Refactor \"Saved Messages\" storage functionality #tindericebreakers"
},
"foreign_id" : "enrichment_store:projects-Task-313717",
"updated_at" : "2020-11-03T18:01:51.202058Z",
"created_at" : "2020-11-03T18:01:51.202058Z"
},
"actor" : {
"collection" : "enrichment_store",
"id" : "accounts-User-6764",
"data" : {
"github_handle" : "AndreiChiha",
"hardcore_mode" : false,
"private" : false,
"last_name" : "Chihalau",
"shipstreams_handle" : "",
"donor" : false,
"id" : 6764,
"instagram_handle" : "",
"week_tda" : 2,
"nomadlist_handle" : "",
"description" : "Front-End Intern at Kappa.London",
"gold" : false,
"email_notifications" : true,
"interests" : [
],
"website" : "",
"digest" : true,
"twitter_handle" : "AChihalau",
"maker_score" : 51,
"accent" : "#00a676",
"bmc_handle" : "",
"dark_mode" : false,
"date_joined" : "2020-10-12T15:18:39.515474Z",
"is_live" : false,
"status" : null,
"avatar" : "https:\/\/ik.imagekit.io\/makerlog\/media\/uploads\/avatars\/2020\/10\/27\/kappa_logo_2.png",
"username" : "AChihalau",
"weekends_off" : false,
"first_name" : "Andrei",
"streak" : 1,
"tester" : false,
"product_hunt_handle" : "@andrei_chihalau",
"is_staff" : false,
"og_image" : "https:\/\/ik.imagekit.io\/makerlog\/media\/uploads\/og\/2020\/11\/03\/ed5b965a-f94a-45a3-91a5-1cea859575a1.jpg",
"header" : null,
"telegram_handle" : "",
"verified" : false,
"timezone" : "Europe\/Bucharest"
},
"foreign_id" : "enrichment_store:accounts-User-6764",
"updated_at" : "2020-11-03T18:04:16.209898Z",
"created_at" : "2020-10-29T07:35:30.837139Z"
},
"origin" : null,
"target" : "",
"actor_type" : "user",
"target_type" : null,
"foreign_id" : "projects.Task:313717"
}
],
"next" : "\/api\/v1.0\/enrich\/feed\/site\/-1\/?api_key=ztyjtywyeb28&id_lt=a5c8aae2-1dfe-11eb-8080-80000a76d4ff&limit=2",
"duration" : "13.18ms"
}
the completion handler of .get is still not working.
Facing this issue too. Any help?
Hello @Veeit @matteing ,
You need to hold a strong reference to the feed object for its completion to be called. If you're holding a strong reference but still seeing this issue, can you share a sample project?
Hello @Veeit Thanks for the sample project. There are a couple of issues with it:
scene(_,willConnectTo:)
setupUser
to call feed.get
timelineFlatFeed
is a local variable, which is deallocated after the lifetime of the closure its in (onAppear(perform:)
). You should hold a reference to the timelineFlatFeed
so it's not deallocated until get
s completion is ran.I've made these changes and I can see that get
completion runs as expected.
Closing due to inactivity
Hey Guys,
I'm currently trying to implement getStream with SwiftUI. But I'm experience a wired behaviour of feed.get(). The completion isn't running. But I get the response printed inside the console, with mean that I get the correct response from the backend.
My Code:
My console log: https://pastebin.com/E82PPWvR