Skip to content

Commit f819dcf

Browse files
committed
Fixed the Timeline Preview
1 parent 6e2db71 commit f819dcf

4 files changed

Lines changed: 10 additions & 15 deletions

File tree

Contentstack.Core/ContentstackClient.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ private async Task<JObject> GetLivePreviewData()
360360
headerAll.Add(header.Key, (String)header.Value);
361361
}
362362
}
363-
mainJson.Add("live_preview", this.LivePreviewConfig.LivePreview ?? "init");
363+
mainJson.Add("live_preview", string.IsNullOrEmpty(this.LivePreviewConfig.LivePreview) ? "init": this.LivePreviewConfig.LivePreview);
364364

365365
if (!string.IsNullOrEmpty(this.LivePreviewConfig.ManagementToken))
366366
{
@@ -402,7 +402,7 @@ public void SetEntryUid(string entryUid)
402402
{
403403
if (!string.IsNullOrEmpty(entryUid))
404404
{
405-
lastEntryUid = entryUid;
405+
this.lastEntryUid = entryUid;
406406
}
407407
}
408408
/// <summary>
@@ -420,7 +420,7 @@ public ContentType ContentType(String contentTypeName)
420420
{
421421
if (!string.IsNullOrEmpty(contentTypeName))
422422
{
423-
lastContentTypeUid = contentTypeName;
423+
this.lastContentTypeUid = contentTypeName;
424424
}
425425
ContentType contentType = new ContentType(contentTypeName);
426426
contentType.SetStackInstance(this);
@@ -610,18 +610,16 @@ public void SetHeader(string key, string value)
610610
public async Task LivePreviewQueryAsync(Dictionary<string, string> query)
611611
{
612612
this.LivePreviewConfig.LivePreview = null;
613-
this.LivePreviewConfig.ContentTypeUID = null;
614-
this.LivePreviewConfig.EntryUID = null;
615613

616614
if (query.Keys.Contains("content_type_uid"))
617615
{
618616
string contentTypeUID = null;
619617
query.TryGetValue("content_type_uid", out contentTypeUID);
620618
this.LivePreviewConfig.ContentTypeUID = contentTypeUID;
621619
}
622-
else if (lastContentTypeUid != null)
620+
else if (!string.IsNullOrEmpty(this.lastContentTypeUid))
623621
{
624-
this.LivePreviewConfig.ContentTypeUID = lastContentTypeUid;
622+
this.LivePreviewConfig.ContentTypeUID = this.lastContentTypeUid;
625623
}
626624

627625

@@ -631,9 +629,9 @@ public async Task LivePreviewQueryAsync(Dictionary<string, string> query)
631629
query.TryGetValue("entry_uid", out entryUID);
632630
this.LivePreviewConfig.EntryUID = entryUID;
633631
}
634-
else if (lastEntryUid != null)
632+
else if (!string.IsNullOrEmpty(this.lastEntryUid))
635633
{
636-
this.LivePreviewConfig.EntryUID = lastEntryUid;
634+
this.LivePreviewConfig.EntryUID = this.lastEntryUid;
637635
}
638636

639637

Contentstack.Core/Models/ContentType.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,11 @@ public void RemoveHeader(string key)
236236
/// </example>
237237
public Entry Entry(String entryUid)
238238
{
239-
if(!String.IsNullOrEmpty(entryUid))
240-
{
241-
this.StackInstance.SetEntryUid(entryUid);
242-
}
243239
Entry entry = new Entry(ContentTypeId);
244240
entry._FormHeaders = GetHeader(_Headers);
245241
entry.SetContentTypeInstance(this);
246242
entry.SetUid(entryUid);
243+
this.StackInstance.SetEntryUid(entryUid);
247244
return entry;
248245
}
249246

Contentstack.Core/Models/Entry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,7 @@ public async Task<T> Fetch<T>()
13981398
bool isLivePreview = false;
13991399
if (this.ContentTypeInstance.StackInstance.LivePreviewConfig.Enable == true && this.ContentTypeInstance.StackInstance.LivePreviewConfig.ContentTypeUID == this.ContentTypeInstance.ContentTypeId)
14001400
{
1401-
mainJson.Add("live_preview", this.ContentTypeInstance.StackInstance.LivePreviewConfig.LivePreview ?? "init");
1401+
mainJson.Add("live_preview", string.IsNullOrEmpty(this.ContentTypeInstance.StackInstance.LivePreviewConfig.LivePreview)? "init" : this.ContentTypeInstance.StackInstance.LivePreviewConfig.LivePreview);
14021402

14031403
if (!string.IsNullOrEmpty(this.ContentTypeInstance.StackInstance.LivePreviewConfig.ManagementToken)) {
14041404
headerAll["authorization"] = this.ContentTypeInstance.StackInstance.LivePreviewConfig.ManagementToken;

Contentstack.Core/Models/Query.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1857,7 +1857,7 @@ private async Task<JObject> Exec()
18571857
if (this.ContentTypeInstance!=null && this.ContentTypeInstance.StackInstance.LivePreviewConfig.Enable == true
18581858
&& this.ContentTypeInstance.StackInstance?.LivePreviewConfig.ContentTypeUID == this.ContentTypeInstance.ContentTypeId)
18591859
{
1860-
mainJson.Add("live_preview", this.ContentTypeInstance.StackInstance.LivePreviewConfig.LivePreview ?? "init");
1860+
mainJson.Add("live_preview", string.IsNullOrEmpty(this.ContentTypeInstance.StackInstance.LivePreviewConfig.LivePreview) ? "init" : this.ContentTypeInstance.StackInstance.LivePreviewConfig.LivePreview);
18611861

18621862
if (!string.IsNullOrEmpty(this.ContentTypeInstance.StackInstance.LivePreviewConfig.ManagementToken)) {
18631863
headerAll["authorization"] = this.ContentTypeInstance.StackInstance.LivePreviewConfig.ManagementToken;

0 commit comments

Comments
 (0)