package io.xpipe.app.hub.action.impl;

import io.xpipe.app.action.*;
import io.xpipe.app.ext.DataStore;
import io.xpipe.app.ext.SingletonSessionStore;
import io.xpipe.app.hub.action.StoreAction;

import lombok.experimental.SuperBuilder;
import lombok.extern.jackson.Jacksonized;

public class RefreshActionProvider implements ActionProvider {

    @Override
    public String getId() {
        return "refreshStore";
    }

    @Jacksonized
    @SuperBuilder
    public static class Action extends StoreAction<DataStore> {
        @Override
        public void executeImpl() throws Exception {
            if (ref.getStore() instanceof SingletonSessionStore<?> sss) {
                sss.stopSessionIfNeeded();
            }
            ref.get().validate();
        }
    }
}
