Scanyonero/server-websocket-packets.go
David Vogel b5ecf95a7b Add split function
- Add ServerWebsocketPacketQueueSplit
- Add Split method to Queue
- Correct automatic separator insertion for newly ingested documents
- Rework UI so that entries have their own set of buttons
- Refactor occurrences of "document" to "queueEntry"
2025-05-19 12:03:40 +02:00

81 lines
3.3 KiB
Go

package main
// ServerWebsocketPacketQueueDeleteAt represents a delete operation on a document queue list.
// The range of the deleted indices is [IndexA; IndexB).
type ServerWebsocketPacketQueueDeleteAt struct {
IndexA int `json:"indexA"` // Starting index of the deletion range.
IndexB int `json:"indexB"` // End index of the deletion range. This index is not included in the range.
}
func (s *ServerWebsocketPacketQueueDeleteAt) Type() string { return "QueueDeleteAt" }
func init() { ServerWebsocketPacketRegister(&ServerWebsocketPacketQueueDeleteAt{}) }
// ServerWebsocketPacketQueueDelete represents a delete operation on a document queue list.
type ServerWebsocketPacketQueueDelete struct {
IDs []QueueEntryID `json:"ids"` // IDs of the documents.
}
func (s *ServerWebsocketPacketQueueDelete) Type() string { return "QueueDelete" }
func init() { ServerWebsocketPacketRegister(&ServerWebsocketPacketQueueDelete{}) }
// ServerWebsocketPacketQueueInsertAt represents an insert operation on a document queue list.
type ServerWebsocketPacketQueueInsertAt struct {
Index int `json:"index"`
Documents []QueueEntry `json:"documents"`
}
func (s *ServerWebsocketPacketQueueInsertAt) Type() string { return "QueueInsertAt" }
func init() { ServerWebsocketPacketRegister(&ServerWebsocketPacketQueueInsertAt{}) }
// ServerWebsocketPacketQueueReplace represents a replace operation on a document queue list.
type ServerWebsocketPacketQueueReplace struct {
Documents []QueueEntry `json:"documents"`
}
func (s *ServerWebsocketPacketQueueReplace) Type() string { return "QueueReplace" }
func init() { ServerWebsocketPacketRegister(&ServerWebsocketPacketQueueReplace{}) }
// ServerWebsocketPacketQueueShiftAt represents a shift operation on a document queue list.
type ServerWebsocketPacketQueueShiftAt struct {
Index int `json:"index"` // Index of the to be shifted element.
Offset int `json:"offset"` // Shift offset.
}
func (s *ServerWebsocketPacketQueueShiftAt) Type() string { return "QueueShiftAt" }
func init() { ServerWebsocketPacketRegister(&ServerWebsocketPacketQueueShiftAt{}) }
// ServerWebsocketPacketQueueShift represents a shift operation on a document queue list.
type ServerWebsocketPacketQueueShift struct {
IDs []QueueEntryID `json:"ids"` // IDs of the entries.
Offset int `json:"offset"` // Shift offset.
}
func (s *ServerWebsocketPacketQueueShift) Type() string { return "QueueShift" }
func init() { ServerWebsocketPacketRegister(&ServerWebsocketPacketQueueShift{}) }
// ServerWebsocketPacketQueueUpdate represents an update operation of entries in a queue list.
// The receiver should update any of the received entries in their local queue list.
type ServerWebsocketPacketQueueUpdate struct {
Documents []QueueEntry `json:"documents"`
}
func (s *ServerWebsocketPacketQueueUpdate) Type() string { return "QueueUpdate" }
func init() { ServerWebsocketPacketRegister(&ServerWebsocketPacketQueueUpdate{}) }
// ServerWebsocketPacketQueueSplit represents a "add separator" operation in a queue list.
// The split is added behind the given entry IDs.
type ServerWebsocketPacketQueueSplit struct {
IDs []QueueEntryID `json:"ids"` // IDs of the entries.
}
func (s *ServerWebsocketPacketQueueSplit) Type() string { return "QueueSplit" }
func init() { ServerWebsocketPacketRegister(&ServerWebsocketPacketQueueSplit{}) }