load stream/day on cold start

This commit is contained in:
Ben Floyd 2025-12-08 10:26:25 -07:00
parent 7f64d394a8
commit 766c71fbdb
4 changed files with 33 additions and 2 deletions

View file

@ -229,8 +229,26 @@ export class ComponentLifecycleManager {
// Check if component already exists
const existingComponent = this.getComponentForLeaf(leaf);
if (existingComponent) {
// Do NOT force update to streamToUse (which might be default)
// Let the component handle its own context via updateStreamContext
// For CreateFileView, we force an update if we have fresh state
// This handles the case where view state is restored after component creation
if (viewType === configurationService.getViewConfig().CREATE_FILE_VIEW_TYPE) {
const view = leaf.view as any;
if (view.getState) {
const state = view.getState();
if (state) {
if (state.stream) {
existingComponent.updateActiveStream(state.stream);
}
if (state.date) {
const date = new Date(state.date);
if (!isNaN(date.getTime())) {
const dateString = date.toISOString().split('T')[0];
existingComponent.setCurrentViewedDate(dateString);
}
}
}
}
}
return;
}

View file

@ -89,6 +89,13 @@ export class EventHandlerService {
}
});
// Listen for create file view updated
eventBus.subscribe('create-file-view-updated', (event) => {
if (event.data) {
this.handleViewOpened(event.data);
}
});
// Listen for install meld view opened
eventBus.subscribe('install-meld-view-opened', (event) => {
if (event.data) {

View file

@ -124,6 +124,8 @@ export class StreamSelector extends Component {
* Select a stream and navigate to it
*/
private async selectStream(stream: Stream): Promise<void> {
this.hide();
// Update the plugin's active stream - REMOVED
// if (this.plugin) {
// await this.plugin.setActiveStream(stream.id, true, true);

View file

@ -6,6 +6,7 @@ import { FileCreationService } from './FileCreationService';
import { EmptyStateObserver } from './EmptyStateObserver';
import { StreamManager } from '../../shared/interfaces';
import { MeldDetectionService } from '../../slices/meld-integration';
import { eventBus } from '../../shared/EventBus';
// Interface for accessing app.plugins
interface AppWithPlugins extends App {
@ -125,6 +126,9 @@ export class CreateFileView extends ItemView {
this.contentEl.addClass('streams-create-file-container');
this.createFileViewContent(this.contentEl);
}
// Emit update event to sync components (like StreamsBarComponent)
eventBus.emit('create-file-view-updated', this.leaf);
}
} catch (error) {
centralizedLogger.error(`Error in CreateFileView setState:`, error);