Skip to content

Commit ba3f606

Browse files
committed
Increase default timeout and retry determining properties if they time out
1 parent e5ad4e8 commit ba3f606

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

interfaces/src/main/kotlin/com/noxcrew/interfaces/interfaces/InterfaceProperties.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public open class InterfaceProperties<P : Pane> {
3030
public var exceptionHandler: InterfacesExceptionHandler = StandardInterfacesExceptionHandler()
3131

3232
/** The timeout to apply to all coroutines for this menu. */
33-
public var defaultTimeout: Duration = 2.5.seconds
33+
public var defaultTimeout: Duration = 5.seconds
3434

3535
/** Enables debug logs for time spent on various actions. */
3636
public var debugRenderingTime: Boolean = false

interfaces/src/main/kotlin/com/noxcrew/interfaces/properties/LazyProperty.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public abstract class LazyProperty<T : Any>(
2222
/** The player this property is for. */
2323
public val player: Player,
2424
/** The maximum time an update can take. */
25-
private val updateTimeout: Duration = 2.5.seconds,
25+
private val updateTimeout: Duration = 5.seconds,
2626
private val exceptionHandler: InterfacesExceptionHandler = StandardInterfacesExceptionHandler(),
2727
) : DelegateTrigger() {
2828
private var updateJob: Deferred<Unit>? = null
@@ -33,7 +33,7 @@ public abstract class LazyProperty<T : Any>(
3333
/** A simple lazy property backed by [block]. */
3434
public class Simple<T : Any>(
3535
player: Player,
36-
updateTimeout: Duration = 2.5.seconds,
36+
updateTimeout: Duration = 5.seconds,
3737
exceptionHandler: StandardInterfacesExceptionHandler,
3838
private val block: suspend (Boolean) -> T,
3939
) : LazyProperty<T>(player, updateTimeout, exceptionHandler) {
@@ -98,9 +98,11 @@ public abstract class LazyProperty<T : Any>(
9898
trigger()
9999
triggeringUpdate = false
100100
}
101+
102+
// Only mark initialization done after we finish an update!
103+
initialized = true
101104
}
102105
}
103-
initialized = true
104106
lastRefresh = Instant.now()
105107
updateJob = null
106108
}

interfaces/src/main/kotlin/com/noxcrew/interfaces/properties/StateProperty.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public abstract class StateProperty(
2929
/** The player this property is for. */
3030
public val player: Player,
3131
/** The maximum time an update can take. */
32-
private val updateTimeout: Duration = 2.5.seconds,
32+
private val updateTimeout: Duration = 5.seconds,
3333
private val exceptionHandler: InterfacesExceptionHandler = StandardInterfacesExceptionHandler(),
3434
private val delegate: DelegateTrigger = DelegateTrigger(),
3535
) : Trigger by delegate {
@@ -69,11 +69,13 @@ public abstract class StateProperty(
6969
) {
7070
withTimeout(updateTimeout) {
7171
update()
72+
73+
// Only mark initialization done after we finish an update!
74+
initialized = true
7275
}
7376
}
7477

7578
// Start the timeout after we finish!
76-
initialized = true
7779
lastRefresh = Instant.now()
7880
updateJob = null
7981
}

interfaces/src/main/kotlin/com/noxcrew/interfaces/view/AbstractInterfaceView.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, T : Interfa
277277
}
278278

279279
override fun redrawComplete() {
280-
applyTransforms(builder.transforms.filter { it.refresh != RefreshMode.TRIGGER_ONLY }, initial = true, renderIfEmpty = true)
280+
applyTransforms(builder.transforms.filter { it.refresh != RefreshMode.TRIGGER_ONLY && (it.refresh != RefreshMode.RELOAD || reloadRefresh) }, initial = true, renderIfEmpty = true)
281281
}
282282

283283
override suspend fun reopen(newParent: InterfaceView?, reload: Boolean): Boolean {

0 commit comments

Comments
 (0)