<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <!--
        Inject chatter preferences into localStorage BEFORE the asset bundle loads.
        This runs as an inline script right after the Odoo bootstrap script,
        guaranteeing the values are available before our IIFE in the bundle executes.
    -->
    <template id="chatter_prefs_inject" inherit_id="web.layout" name="Chatter Preferences Early Inject">
        <xpath expr="//script[@id='web.layout.odooscript']" position="after">
            <t t-if="request.session.uid">
                <script type="text/javascript">
                    (function(){
                        try {
                            localStorage.setItem('fce_chatter_position', '<t t-esc="request.env.user.chatter_position or 'side'"/>');
                            localStorage.setItem('fce_chatter_hidden', '<t t-esc="'1' if request.env.user.chatter_hidden else '0'"/>');
                        } catch(e){}
                    })();
                </script>
            </t>
        </xpath>
    </template>
</odoo>
