Skip to content

Commit

Permalink
refactor: clean up redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
canstand committed Sep 14, 2024
1 parent d3cd12b commit 67e0dc8
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import (
"errors"
"fmt"
"os"
"sync"
"time"

mapset "github.com/deckarep/golang-set/v2"
)

type frameImpl struct {
channelOwner
sync.RWMutex
detached bool
page *pageImpl
name string
Expand All @@ -30,23 +28,23 @@ func newFrame(parent *channelOwner, objectType string, guid string, initializer
} else {
loadStates = mapset.NewSet[string]()
}
bt := &frameImpl{
f := &frameImpl{
name: initializer["name"].(string),
url: initializer["url"].(string),
loadStates: loadStates,
childFrames: make([]Frame, 0),
}
bt.createChannelOwner(bt, parent, objectType, guid, initializer)
f.createChannelOwner(f, parent, objectType, guid, initializer)

channelOwner := fromNullableChannel(initializer["parentFrame"])
if channelOwner != nil {
bt.parentFrame = channelOwner.(*frameImpl)
bt.parentFrame.(*frameImpl).childFrames = append(bt.parentFrame.(*frameImpl).childFrames, bt)
f.parentFrame = channelOwner.(*frameImpl)
f.parentFrame.(*frameImpl).childFrames = append(f.parentFrame.(*frameImpl).childFrames, f)
}

bt.channel.On("navigated", bt.onFrameNavigated)
bt.channel.On("loadstate", bt.onLoadState)
return bt
f.channel.On("navigated", f.onFrameNavigated)
f.channel.On("loadstate", f.onLoadState)
return f
}

func (f *frameImpl) URL() string {
Expand Down

0 comments on commit 67e0dc8

Please sign in to comment.