TashDLInterface = {}


function TashDLInterface:ShowNPCHistory(NPCName)
    TashDLInterface.mainWindow:Toggle()
    TashDLInterface.mainWindow.conversationsList:SetAuthor(NPCName)
end


function TashDLInterface:OnNPCHistoryButtonClicked()
    local name = GetUnitName("interact")
    TashDLInterface:ShowNPCHistory(name)
end


function TashDLInterface:OnPhraseAdded()
    if not self.mainWindow.control:IsHidden() then
        self.mainWindow.conversationsList:RefreshData()
    end
end


function TashDLInterface:ModifyInteractionWindow()
    local w = TashDialogueLog.ctrl.WindowTopBG
    local DialogueHistoryButton = WINDOW_MANAGER:CreateControl("NPCHistoryButton", w, CT_TEXTURE)
    DialogueHistoryButton:SetMouseEnabled(true)
    DialogueHistoryButton:SetDimensions(50, 50)
    DialogueHistoryButton:SetAnchor(TOPLEFT, w, 0, 0)
    DialogueHistoryButton:SetTexture("/esoui/art/chatwindow/chat_notification_down.dds")
    DialogueHistoryButton:SetHandler("OnMouseUp", TashDLInterface.OnNPCHistoryButtonClicked)
end


function TashDLInterface:Initialize()
    -- TashDialogueLogMainWindowController.window:SetHidden(false)
    TashDLInterface.mainWindow = TashDLMainWindow
    TashDLInterface.mainWindow:Initialize()
    TashDLInterface:ModifyInteractionWindow()
end