From ecfd4c5a91d204ce4c001d19fa600cf42ac4cf43 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 9 Apr 2020 19:10:02 +0200 Subject: [PATCH] =?utf8?q?=E2=99=BB=EF=B8=8F=20Slightly=20improve=20messy?= =?utf8?q?=20expression?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../kotlin/net/pterodactylus/sone/web/FreenetSessionProvider.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/FreenetSessionProvider.kt b/src/main/kotlin/net/pterodactylus/sone/web/FreenetSessionProvider.kt index 80bacdf..8928f12 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/FreenetSessionProvider.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/FreenetSessionProvider.kt @@ -41,10 +41,13 @@ class FreenetSessionProvider @Inject constructor(private val soneProvider: SoneP sessionManager.useSession(toadletContext) ?.removeAttribute("Sone.CurrentSone") } else { - (sessionManager.useSession(toadletContext) - ?: sessionManager.createSession(UUID.randomUUID().toString(), toadletContext)) + sessionManager.getOrCreateSession(toadletContext) ?.setAttribute("Sone.CurrentSone", sone.id) } } + private fun SessionManager.getOrCreateSession(toadletContext: ToadletContext) = + useSession(toadletContext) + ?: createSession(UUID.randomUUID().toString(), toadletContext) + } -- 2.7.4