rename start -> begin

This commit is contained in:
Steve Ruiz 2021-06-23 09:50:51 +01:00
parent 5b514e07f9
commit 22a97d1374
2 changed files with 15 additions and 22 deletions

View file

@ -18,12 +18,12 @@ class SessionManager {
return this
}
start(session: BaseSession) {
begin(session: BaseSession) {
this._current = session
return this
}
compplete<T extends BaseSession>(...args: Parameters<T['complete']>) {
complete<T extends BaseSession>(...args: Parameters<T['complete']>) {
this._current.complete.call(null, ...args)
return this
}
@ -32,10 +32,6 @@ class SessionManager {
this._current.cancel.call(null, ...args)
return this
}
get current() {
return this._current
}
}
const session = new SessionManager()

View file

@ -986,24 +986,21 @@ const state = createState({
// Shared
breakSession(data) {
session.current?.cancel(data)
session.clear()
session.cancel(data).clear()
history.disable()
commands.deleteSelected(data)
history.enable()
},
cancelSession(data) {
session.current?.cancel(data)
session.clear()
session.cancel(data).clear()
},
completeSession(data) {
session.current?.complete(data)
session.clear()
session.complete(data).clear()
},
// Editing
startEditSession(data) {
session.start(new Sessions.EditSession(data))
session.begin(new Sessions.EditSession(data))
},
updateEditSession(data, payload: { change: Partial<Shape> }) {
session.update<Sessions.EditSession>(data, payload.change)
@ -1011,7 +1008,7 @@ const state = createState({
// Brushing
startBrushSession(data, payload: PointerInfo) {
session.start(
session.begin(
new Sessions.BrushSession(data, screenToWorld(payload.point, data))
)
},
@ -1024,7 +1021,7 @@ const state = createState({
// Rotating
startRotateSession(data, payload: PointerInfo) {
session.start(
session.begin(
new Sessions.RotateSession(data, screenToWorld(payload.point, data))
)
},
@ -1045,7 +1042,7 @@ const state = createState({
// Dragging / Translating
startTranslateSession(data) {
session.start(
session.begin(
new Sessions.TranslateSession(
data,
screenToWorld(inputs.pointer.origin, data)
@ -1083,7 +1080,7 @@ const state = createState({
const shapeId = Array.from(getSelectedIds(data).values())[0]
const handleId = payload.target
session.start(
session.begin(
new Sessions.HandleSession(
data,
shapeId,
@ -1116,14 +1113,14 @@ const state = createState({
payload: PointerInfo & { target: Corner | Edge }
) {
const point = screenToWorld(inputs.pointer.origin, data)
session.start(
session.begin(
getSelectedIds(data).size === 1
? new Sessions.TransformSingleSession(data, payload.target, point)
: new Sessions.TransformSession(data, payload.target, point)
)
},
startDrawTransformSession(data, payload: PointerInfo) {
session.start(
session.begin(
new Sessions.TransformSingleSession(
data,
Corner.BottomRight,
@ -1149,7 +1146,7 @@ const state = createState({
// Direction
startDirectionSession(data) {
session.start(
session.begin(
new Sessions.DirectionSession(
data,
screenToWorld(inputs.pointer.origin, data)
@ -1166,7 +1163,7 @@ const state = createState({
// Drawing
startDrawSession(data, payload: PointerInfo) {
const id = Array.from(getSelectedIds(data).values())[0]
session.start(
session.begin(
new Sessions.DrawSession(
data,
id,
@ -1196,7 +1193,7 @@ const state = createState({
startArrowSession(data, payload: PointerInfo) {
const id = Array.from(getSelectedIds(data).values())[0]
session.start(
session.begin(
new Sessions.ArrowSession(
data,
id,