gosora/common/menu_item_store.go
Azareal d0318191c9 Added the menu manager and menu item editor.
Refactored the menu system.
Updated the README and revamped it a tad to make it easier to understand. Also, added manual instructions for patching.
Revamped the update scripts, especially on Windows.
Merged the CSS and Tmpl phrase namespaces.
Added lastSchema to .gitignore
Added DropTable to the database adapters.
Implemented DbVersion in the PgSQL Adapter.
Swapped out the checkboxes for cleaner looking yes-no dropdowns.
Began revamping small bits of the user logic.

We now open to contributions, just open a pull request and sign the CLA.
Schema has been updated, run the patcher or update script.
2018-05-11 15:41:51 +10:00

31 lines
589 B
Go

package common
import "sync"
type DefaultMenuItemStore struct {
items map[int]MenuItem
itemLock sync.RWMutex
}
func NewDefaultMenuItemStore() *DefaultMenuItemStore {
return &DefaultMenuItemStore{
items: make(map[int]MenuItem),
}
}
func (store *DefaultMenuItemStore) Add(item MenuItem) {
store.itemLock.Lock()
defer store.itemLock.Unlock()
store.items[item.ID] = item
}
func (store *DefaultMenuItemStore) Get(id int) (MenuItem, error) {
store.itemLock.RLock()
item, ok := store.items[id]
store.itemLock.RUnlock()
if ok {
return item, nil
}
return item, ErrNoRows
}