Skip to content

Commit ac8ab48

Browse files
committed
fix: removed UpdateLivePreviewContent call in ProcessRequest
1 parent 446bf01 commit ac8ab48

File tree

6 files changed

+32
-27
lines changed

6 files changed

+32
-27
lines changed

Contentstack.AspNetCore/Contentstack.AspNetCore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@
3131
<PackageReference Include="NuGet.Build.Packaging" Version="0.2.2"><PrivateAssets>all</PrivateAssets>
3232
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3333
</PackageReference>
34-
<PackageReference Include="contentstack.csharp" Version="2.17.0" />
34+
<PackageReference Include="contentstack.csharp" Version="2.18.0" />
3535
</ItemGroup>
3636
</Project>

Contentstack.Core.Tests/Contentstack.Core.Tests.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
12-
<PackageReference Include="xunit" Version="2.7.0" />
13-
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7"><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
11+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
12+
<PackageReference Include="xunit" Version="2.9.2" />
13+
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2"><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1414
<PrivateAssets>all</PrivateAssets>
1515
</PackageReference>
16-
<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.0" />
17-
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" />
16+
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.0" />
17+
<PackageReference Include="Microsoft.Extensions.Options" Version="9.0.0" />
1818
<PackageReference Include="coverlet.collector" Version="6.0.2">
1919
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2020
<PrivateAssets>all</PrivateAssets>

Contentstack.Core/Configuration/Config.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ internal string getLivePreviewUrl(LivePreviewConfig livePreviewConfig)
9999

100100
internal string getBaseUrl (LivePreviewConfig livePreviewConfig, string contentTypeUID)
101101
{
102-
if (livePreviewConfig != null && livePreviewConfig.Enable && livePreviewConfig.ContentTypeUID == contentTypeUID)
102+
if (livePreviewConfig != null
103+
&& livePreviewConfig.Enable
104+
&& livePreviewConfig.LivePreview != "init"
105+
&& livePreviewConfig.ContentTypeUID == contentTypeUID)
103106
{
104107
return getLivePreviewUrl(livePreviewConfig);
105108
}

Contentstack.Core/ContentstackClient.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,8 @@ public async Task LivePreviewQueryAsync(Dictionary<string, string> query)
572572
string hash = null;
573573
query.TryGetValue("live_preview", out hash);
574574
this.LivePreviewConfig.LivePreview = hash;
575+
} else {
576+
this.LivePreviewConfig.LivePreview = "init";
575577
}
576578
this.LivePreviewConfig.PreviewResponse = await GetLivePreviewData();
577579
}

Contentstack.Core/Internals/HttpRequestHandler.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,6 @@ public async Task<string> ProcessRequest(string Url, Dictionary<string, object>
9090
{
9191
responseString = await plugin.OnResponse(client, request, response, responseString);
9292
}
93-
94-
if (isLivePreview == false && this.client.LivePreviewConfig.Enable == true)
95-
{
96-
JObject data = JsonConvert.DeserializeObject<JObject>(responseString.Replace("\r\n", ""), this.client.SerializerSettings);
97-
updateLivePreviewContent(data);
98-
responseString = JsonConvert.SerializeObject(data);
99-
}
10093
return responseString;
10194
} else {
10295
return null;

Contentstack.Core/Models/Query.cs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,19 +1830,6 @@ private async Task<JObject> Exec()
18301830
Dictionary<string, object> headerAll = new Dictionary<string, object>();
18311831
Dictionary<string, object> mainJson = new Dictionary<string, object>();
18321832

1833-
if (headers != null && headers.Count() > 0)
1834-
{
1835-
foreach (var header in headers)
1836-
{
1837-
if (this.ContentTypeInstance.StackInstance.LivePreviewConfig.Enable == true
1838-
&& this.ContentTypeInstance.StackInstance.LivePreviewConfig.ContentTypeUID == this.ContentTypeInstance.ContentTypeId
1839-
&& header.Key == "access_token")
1840-
{
1841-
continue;
1842-
}
1843-
headerAll.Add(header.Key, (string)header.Value);
1844-
}
1845-
}
18461833
bool isLivePreview = false;
18471834
if (this.ContentTypeInstance.StackInstance.LivePreviewConfig.Enable == true
18481835
&& this.ContentTypeInstance.StackInstance.LivePreviewConfig.ContentTypeUID == this.ContentTypeInstance.ContentTypeId)
@@ -1859,7 +1846,27 @@ private async Task<JObject> Exec()
18591846

18601847
isLivePreview = true;
18611848
}
1849+
1850+
if (headers != null && headers.Count() > 0)
1851+
{
1852+
foreach (var header in headers)
1853+
{
1854+
if (this.ContentTypeInstance.StackInstance.LivePreviewConfig.Enable == true
1855+
&& this.ContentTypeInstance.StackInstance.LivePreviewConfig.ContentTypeUID == this.ContentTypeInstance.ContentTypeId
1856+
&& header.Key == "access_token"
1857+
&& isLivePreview)
1858+
{
1859+
continue;
1860+
}
1861+
headerAll.Add(header.Key, (string)header.Value);
1862+
}
1863+
}
18621864

1865+
if (!isLivePreview && headerAll.ContainsKey("preview_token"))
1866+
{
1867+
headerAll.Remove("preview_token");
1868+
}
1869+
18631870
mainJson.Add("environment", this.ContentTypeInstance.StackInstance.Config.Environment);
18641871
if (QueryValueJson != null && QueryValueJson.Count > 0)
18651872
mainJson.Add("query", QueryValueJson);

0 commit comments

Comments
 (0)