@@ -13,6 +13,8 @@ import java.time.{Duration, Instant}
1313enum SignatureFilter derives CanEqual :
1414 case All , Wormhole , Combat , Indy , Hacking , Unscanned
1515
16+ val StaleSignatureInterval : Duration = Duration .ofDays(1 )
17+
1618enum ConnectionTarget derives CanEqual :
1719 def idOpt : Option [ConnectionId ] =
1820 this match
@@ -124,16 +126,10 @@ private inline def sigView(
124126 .combineWith(currentFilter.signal)
125127 .map((sigs, filter) => s " ${sigs.count(isVisibleWithFilter(filter, _))}/ ${sigs.length}" )
126128 ),
127- // TODO not sure this is necessary!
128- // button(
129- // idAttr := "sig-select-all",
130- // typ := "button",
131- // cls := "ti",
132- // cls := "ti-select-all"
133- // ),
134129 button(
135130 idAttr := " sig-paste-signatures" ,
136131 typ := " button" ,
132+ title := " Paste signatures" ,
137133 cls := " ti" ,
138134 cls := " ti-clipboard-plus" ,
139135 disabled <-- canEdit.map(! _),
@@ -158,6 +154,7 @@ private inline def sigView(
158154 button(
159155 idAttr := " sig-add-signature" ,
160156 typ := " button" ,
157+ title := " Add a signature" ,
161158 cls := " ti" ,
162159 cls := " ti-plus" ,
163160 disabled <-- canEdit.map(! _),
@@ -181,6 +178,7 @@ private inline def sigView(
181178 button(
182179 idAttr := " sig-edit-signature" ,
183180 typ := " button" ,
181+ title := " Edit signature" ,
184182 disabled <-- canEdit.combineWith(selected.signal).map(! _ || _.size != 1 ),
185183 cls := " ti" ,
186184 cls := " ti-pencil" ,
@@ -204,9 +202,34 @@ private inline def sigView(
204202 )
205203 )
206204 ),
205+ button(
206+ idAttr := " sig-remove-stale" ,
207+ typ := " button" ,
208+ title := " Remove stale signatures" ,
209+ cls := " sig-destructive" ,
210+ cls := " ti" ,
211+ cls := " ti-hours-24" ,
212+ disabled <-- canEdit.map(! _),
213+ onClick.stopPropagation.mapToUnit.compose(
214+ _.withCurrentValueOf(time, signatures, solarSystem)
215+ ) --> ((now : Instant , signatures : List [MapSystemSignature ], solarSystem) =>
216+ val staleAt = now.minus(StaleSignatureInterval )
217+ val stale = signatures.filter(_.updatedAt.isBefore(staleAt))
218+
219+ if (stale.nonEmpty)
220+ Modal .showConfirmation(
221+ s " Remove ${stale.size} signatures? " ,
222+ s " Confirm removal of signatures in ${solarSystem.name}? " ,
223+ Observer (_ => actions.onNext(MapAction .RemoveSignatures (solarSystem.id, stale.map(_.id).toSet))),
224+ true ,
225+ selected.clearUpdater
226+ )
227+ )
228+ ),
207229 button(
208230 idAttr := " sig-remove-selected" ,
209231 typ := " button" ,
232+ title := " Remove selected signatures" ,
210233 disabled <-- canEdit.combineWith(selected.signal).map(! _ || _.isEmpty),
211234 cls := " sig-destructive" ,
212235 cls := " ti" ,
@@ -225,6 +248,7 @@ private inline def sigView(
225248 button(
226249 idAttr := " sig-remove-all-signatures" ,
227250 typ := " button" ,
251+ title := " Remove all signatures" ,
228252 cls := " sig-destructive" ,
229253 cls := " ti" ,
230254 cls := " ti-clear-all" ,
0 commit comments