Skip to content

Commit 336809f

Browse files
committed
clear history from the server
1 parent 88b00ba commit 336809f

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/Inertia.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* @method static void setRootView(string $name)
99
* @method static void share(string|array|\Illuminate\Contracts\Support\Arrayable $key, mixed $value = null)
1010
* @method static mixed getShared(string|null $key = null, mixed $default = null)
11+
* @method static void clearHistory()
1112
* @method static void flushShared()
1213
* @method static void version(\Closure|string|null $version)
1314
* @method static string getVersion()

src/Response.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,20 @@ class Response implements Responsable
2929

3030
protected $version;
3131

32+
protected $clearHistory;
33+
3234
protected $viewData = [];
3335

3436
/**
3537
* @param array|Arrayable $props
3638
*/
37-
public function __construct(string $component, array $props, string $rootView = 'app', string $version = '')
39+
public function __construct(string $component, array $props, string $rootView = 'app', string $version = '', bool $clearHistory = false)
3840
{
3941
$this->component = $component;
4042
$this->props = $props instanceof Arrayable ? $props->toArray() : $props;
4143
$this->rootView = $rootView;
4244
$this->version = $version;
45+
$this->clearHistory = $clearHistory;
4346
}
4447

4548
/**
@@ -247,6 +250,7 @@ public function resolveMeta(Request $request): array
247250
{
248251
$meta = [
249252
'assetVersion' => $this->version,
253+
'clearHistory' => $this->clearHistory,
250254
];
251255

252256
if ($this->isPartial($request)) {

src/ResponseFactory.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class ResponseFactory
2727
/** @var Closure|string|null */
2828
protected $version;
2929

30+
protected $clearHistory = false;
31+
3032
public function setRootView(string $name): void
3133
{
3234
$this->rootView = $name;
@@ -82,6 +84,11 @@ public function getVersion(): string
8284
return (string) $version;
8385
}
8486

87+
public function clearHistory(): void
88+
{
89+
$this->clearHistory = true;
90+
}
91+
8592
/**
8693
* @deprecated Use `optional` instead.
8794
*/
@@ -121,7 +128,8 @@ public function render(string $component, $props = []): Response
121128
$component,
122129
array_merge($this->sharedProps, $props),
123130
$this->rootView,
124-
$this->getVersion()
131+
$this->getVersion(),
132+
$this->clearHistory
125133
);
126134
}
127135

0 commit comments

Comments
 (0)