Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
18b0b763
authored
Jul 25, 2026
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: rename channel priority update to channel field update
parent
a0d0e504
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
82 deletions
+92
-82
web/src/features/channels/components/channels-columns.tsx
+72
-64
web/src/features/channels/components/numeric-spinner-input.tsx
+4
-2
web/src/features/channels/lib/__tests__/channel-field-update.test.ts
+9
-9
web/src/features/channels/lib/channel-field-update.ts
+6
-6
web/src/features/channels/lib/index.ts
+1
-1
No files found.
web/src/features/channels/components/channels-columns.tsx
View file @
18b0b763
...
...
@@ -71,7 +71,7 @@ import {
handleUpdateChannelField
,
handleUpdateTagField
,
handleUpdateChannelBalance
,
createChannel
Priority
UpdateScheduler
,
createChannel
Field
UpdateScheduler
,
isTagAggregateRow
,
type
TagRow
,
}
from
'../lib'
...
...
@@ -177,7 +177,14 @@ function PriorityCell({ channel }: { channel: Channel }) {
return
<
TagPriorityCell
channel=
{
channel
}
/>
}
return
<
ChannelPriorityCell
channel=
{
channel
}
/>
return
(
<
ChannelFieldCell
channelId=
{
channel
.
id
}
value=
{
channel
.
priority
}
field=
'priority'
min=
{
-
999
}
/>
)
}
function
TagPriorityCell
({
channel
}:
{
channel
:
TagRow
})
{
...
...
@@ -219,32 +226,34 @@ function TagPriorityCell({ channel }: { channel: TagRow }) {
)
}
function
ChannelPriorityCell
({
channel
}:
{
channel
:
Channel
})
{
function
ChannelFieldCell
({
channelId
,
value
,
field
,
min
,
}:
{
channelId
:
number
value
:
number
|
null
|
undefined
field
:
'priority'
|
'weight'
min
:
number
})
{
const
queryClient
=
useQueryClient
()
const
priority
UpdateScheduler
=
useMemo
(
const
field
UpdateScheduler
=
useMemo
(
()
=>
createChannelPriorityUpdateScheduler
((
value
)
=>
{
void
handleUpdateChannelField
(
channel
.
id
,
'priority'
,
value
,
queryClient
)
createChannelFieldUpdateScheduler
((
nextValue
)
=>
{
void
handleUpdateChannelField
(
channelId
,
field
,
nextValue
,
queryClient
)
}),
[
channel
.
i
d
,
queryClient
]
[
channel
Id
,
fiel
d
,
queryClient
]
)
useEffect
(
()
=>
()
=>
priorityUpdateScheduler
.
flush
(),
[
priorityUpdateScheduler
]
)
useEffect
(()
=>
()
=>
fieldUpdateScheduler
.
flush
(),
[
fieldUpdateScheduler
])
return
(
<
NumericSpinnerInput
value=
{
channel
.
priority
??
0
}
onChange=
{
priority
UpdateScheduler
.
schedule
}
onCommit=
{
priority
UpdateScheduler
.
flush
}
min=
{
-
999
}
value=
{
value
??
0
}
onChange=
{
field
UpdateScheduler
.
schedule
}
onCommit=
{
field
UpdateScheduler
.
flush
}
min=
{
min
}
/>
)
}
...
...
@@ -253,57 +262,56 @@ function ChannelPriorityCell({ channel }: { channel: Channel }) {
* Weight cell component with inline editing
*/
function
WeightCell
({
channel
}:
{
channel
:
Channel
})
{
if
(
isTagAggregateRow
(
channel
))
{
return
<
TagWeightCell
channel=
{
channel
}
/>
}
return
(
<
ChannelFieldCell
channelId=
{
channel
.
id
}
value=
{
channel
.
weight
}
field=
'weight'
min=
{
0
}
/>
)
}
function
TagWeightCell
({
channel
}:
{
channel
:
TagRow
})
{
const
{
t
}
=
useTranslation
()
const
queryClient
=
useQueryClient
()
const
isTagRow
=
isTagAggregateRow
(
channel
)
const
weight
=
channel
.
weight
const
[
confirmOpen
,
setConfirmOpen
]
=
useState
(
false
)
const
[
pendingValue
,
setPendingValue
]
=
useState
<
number
|
null
>
(
null
)
const
tag
=
channel
.
tag
||
''
const
channelCount
=
channel
.
children
?.
length
||
0
// Tag row - editable with confirmation for all tag channels
if
(
isTagRow
)
{
const
tag
=
channel
.
tag
||
''
const
channelCount
=
channel
.
children
?.
length
||
0
return
(
<>
<
NumericSpinnerInput
value=
{
weight
??
0
}
onChange=
{
(
value
)
=>
{
setPendingValue
(
value
)
setConfirmOpen
(
true
)
}
}
min=
{
0
}
/>
<
ConfirmDialog
open=
{
confirmOpen
}
onOpenChange=
{
setConfirmOpen
}
title=
{
t
(
'Confirm Batch Update'
)
}
desc=
{
t
(
'
This
will
update
the
weight
to
{{
value
}}
for
all
{{
count
}}
channel
(
s
)
with
tag
"
{{
tag
}}
"
.
Continue
?
'
,
{
value
:
pendingValue
,
count
:
channelCount
,
tag
}
)
}
confirmText=
{
t
(
'Update'
)
}
handleConfirm=
{
()
=>
{
if
(
pendingValue
!==
null
)
{
handleUpdateTagField
(
tag
,
'weight'
,
pendingValue
,
queryClient
)
}
setConfirmOpen
(
false
)
}
}
/>
</>
)
}
// Regular channel row - editable
return
(
<
NumericSpinnerInput
value=
{
weight
??
0
}
onChange=
{
(
value
)
=>
{
handleUpdateChannelField
(
channel
.
id
,
'weight'
,
value
,
queryClient
)
}
}
min=
{
0
}
/>
<>
<
NumericSpinnerInput
value=
{
weight
??
0
}
onChange=
{
(
value
)
=>
{
setPendingValue
(
value
)
setConfirmOpen
(
true
)
}
}
min=
{
0
}
/>
<
ConfirmDialog
open=
{
confirmOpen
}
onOpenChange=
{
setConfirmOpen
}
title=
{
t
(
'Confirm Batch Update'
)
}
desc=
{
t
(
'
This
will
update
the
weight
to
{{
value
}}
for
all
{{
count
}}
channel
(
s
)
with
tag
"
{{
tag
}}
"
.
Continue
?
'
,
{
value
:
pendingValue
,
count
:
channelCount
,
tag
}
)
}
confirmText=
{
t
(
'Update'
)
}
handleConfirm=
{
()
=>
{
if
(
pendingValue
!==
null
)
{
handleUpdateTagField
(
tag
,
'weight'
,
pendingValue
,
queryClient
)
}
setConfirmOpen
(
false
)
}
}
/>
</>
)
}
...
...
web/src/features/channels/components/numeric-spinner-input.tsx
View file @
18b0b763
...
...
@@ -122,8 +122,10 @@ export function NumericSpinnerInput({
const
handleKeyDown
=
(
e
:
React
.
KeyboardEvent
)
=>
{
if
(
e
.
key
===
'Enter'
)
{
e
.
preventDefault
()
commitValue
()
onCommit
?.()
// Blurring routes Enter through the same focusout path as clicking
// away (input onBlur -> commitValue, container onBlur -> onCommit),
// so commit and onCommit each fire exactly once.
inputRef
.
current
?.
blur
()
}
else
if
(
e
.
key
===
'Escape'
)
{
setEditing
(
false
)
setLocalValue
(
String
(
value
??
0
))
...
...
web/src/features/channels/lib/
channel-priority
-update.test.ts
→
web/src/features/channels/lib/
__tests__/channel-field
-update.test.ts
View file @
18b0b763
...
...
@@ -20,9 +20,9 @@ import assert from 'node:assert/strict'
import
{
describe
,
test
}
from
'node:test'
import
{
CHANNEL_
PRIORITY
_UPDATE_DELAY_MS
,
createChannel
Priority
UpdateScheduler
,
}
from
'.
/channel-priority
-update'
CHANNEL_
FIELD
_UPDATE_DELAY_MS
,
createChannel
Field
UpdateScheduler
,
}
from
'.
./channel-field
-update'
function
createFakeTimers
()
{
const
pending
=
new
Map
<
number
,
()
=>
void
>
()
...
...
@@ -31,7 +31,7 @@ function createFakeTimers() {
return
{
timers
:
{
setTimeout
:
(
callback
:
()
=>
void
,
delay
:
number
)
=>
{
assert
.
equal
(
delay
,
CHANNEL_
PRIORITY
_UPDATE_DELAY_MS
)
assert
.
equal
(
delay
,
CHANNEL_
FIELD
_UPDATE_DELAY_MS
)
const
id
=
nextId
++
pending
.
set
(
id
,
callback
)
return
id
...
...
@@ -51,11 +51,11 @@ function createFakeTimers() {
}
}
describe
(
'channel
priority
update scheduler'
,
()
=>
{
describe
(
'channel
field
update scheduler'
,
()
=>
{
test
(
'coalesces rapid schedules into one update with the latest value'
,
()
=>
{
const
fake
=
createFakeTimers
()
const
updates
:
number
[]
=
[]
const
scheduler
=
createChannel
Priority
UpdateScheduler
(
const
scheduler
=
createChannel
Field
UpdateScheduler
(
(
value
)
=>
updates
.
push
(
value
),
fake
.
timers
)
...
...
@@ -73,7 +73,7 @@ describe('channel priority update scheduler', () => {
test
(
'flush commits the pending value immediately and cancels the timer'
,
()
=>
{
const
fake
=
createFakeTimers
()
const
updates
:
number
[]
=
[]
const
scheduler
=
createChannel
Priority
UpdateScheduler
(
const
scheduler
=
createChannel
Field
UpdateScheduler
(
(
value
)
=>
updates
.
push
(
value
),
fake
.
timers
)
...
...
@@ -90,7 +90,7 @@ describe('channel priority update scheduler', () => {
test
(
'flush without a pending value does nothing'
,
()
=>
{
const
fake
=
createFakeTimers
()
const
updates
:
number
[]
=
[]
const
scheduler
=
createChannel
Priority
UpdateScheduler
(
const
scheduler
=
createChannel
Field
UpdateScheduler
(
(
value
)
=>
updates
.
push
(
value
),
fake
.
timers
)
...
...
@@ -105,7 +105,7 @@ describe('channel priority update scheduler', () => {
test
(
'preserves a pending value of 0'
,
()
=>
{
const
fake
=
createFakeTimers
()
const
updates
:
number
[]
=
[]
const
scheduler
=
createChannel
Priority
UpdateScheduler
(
const
scheduler
=
createChannel
Field
UpdateScheduler
(
(
value
)
=>
updates
.
push
(
value
),
fake
.
timers
)
...
...
web/src/features/channels/lib/channel-
priority
-update.ts
→
web/src/features/channels/lib/channel-
field
-update.ts
View file @
18b0b763
...
...
@@ -17,21 +17,21 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
export
const
CHANNEL_
PRIORITY
_UPDATE_DELAY_MS
=
800
export
const
CHANNEL_
FIELD
_UPDATE_DELAY_MS
=
800
interface
Channel
Priority
UpdateTimers
{
interface
Channel
Field
UpdateTimers
{
setTimeout
:
(
callback
:
()
=>
void
,
delay
:
number
)
=>
number
clearTimeout
:
(
id
:
number
)
=>
void
}
const
browserTimers
:
Channel
Priority
UpdateTimers
=
{
const
browserTimers
:
Channel
Field
UpdateTimers
=
{
setTimeout
:
(
callback
,
delay
)
=>
window
.
setTimeout
(
callback
,
delay
),
clearTimeout
:
(
id
)
=>
window
.
clearTimeout
(
id
),
}
export
function
createChannel
Priority
UpdateScheduler
(
export
function
createChannel
Field
UpdateScheduler
(
onUpdate
:
(
value
:
number
)
=>
void
,
timers
:
Channel
Priority
UpdateTimers
=
browserTimers
timers
:
Channel
Field
UpdateTimers
=
browserTimers
)
{
let
timeoutId
:
number
|
undefined
let
pendingValue
:
number
|
undefined
...
...
@@ -57,7 +57,7 @@ export function createChannelPriorityUpdateScheduler(
pendingValue
=
value
timeoutId
=
timers
.
setTimeout
(
commitPendingValue
,
CHANNEL_
PRIORITY
_UPDATE_DELAY_MS
CHANNEL_
FIELD
_UPDATE_DELAY_MS
)
},
flush
:
commitPendingValue
,
...
...
web/src/features/channels/lib/index.ts
View file @
18b0b763
...
...
@@ -18,7 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
*/
// Re-export all library functions
export
*
from
'./channel-actions'
export
*
from
'./channel-
priority
-update'
export
*
from
'./channel-
field
-update'
export
*
from
'./advanced-custom'
export
*
from
'./channel-form-errors'
export
*
from
'./channel-form'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment