Skip to content

Commit

Permalink
wtf
Browse files Browse the repository at this point in the history
  • Loading branch information
bhackett1024 committed Feb 12, 2025
1 parent c90b684 commit d9d4b5b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
3 changes: 2 additions & 1 deletion app/lib/persistence/useChatHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export interface ChatHistoryItem {

const persistenceEnabled = !import.meta.env.VITE_DISABLE_PERSISTENCE;

export const db = persistenceEnabled ? await openDatabase() : undefined;
// FIXME
export const db = undefined; // persistenceEnabled ? openDatabase() : undefined;

export const chatId = atom<string | undefined>(undefined);
export const description = atom<string | undefined>(undefined);
Expand Down
18 changes: 14 additions & 4 deletions app/lib/stores/previews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,22 @@ const PREVIEW_CHANNEL = 'preview-updates';
export class PreviewsStore {
#availablePreviews = new Map<number, PreviewInfo>();
#webcontainer: Promise<WebContainer>;
#broadcastChannel: BroadcastChannel;
//#broadcastChannel: BroadcastChannel;
#lastUpdate = new Map<string, number>();
#watchedFiles = new Set<string>();
#refreshTimeouts = new Map<string, NodeJS.Timeout>();
#REFRESH_DELAY = 300;
#storageChannel: BroadcastChannel;
//#storageChannel: BroadcastChannel;

previews = atom<PreviewInfo[]>([]);

constructor(webcontainerPromise: Promise<WebContainer>) {
this.#webcontainer = webcontainerPromise;
this.#broadcastChannel = new BroadcastChannel(PREVIEW_CHANNEL);
this.#storageChannel = new BroadcastChannel('storage-sync-channel');
//this.#broadcastChannel = new BroadcastChannel(PREVIEW_CHANNEL);
//this.#storageChannel = new BroadcastChannel('storage-sync-channel');

// Listen for preview updates from other tabs
/*
this.#broadcastChannel.onmessage = (event) => {
const { type, previewId } = event.data;
Expand All @@ -57,6 +58,7 @@ export class PreviewsStore {
this._syncStorage(storage);
}
};
*/

// Override localStorage setItem to catch all changes
if (typeof window !== 'undefined') {
Expand Down Expand Up @@ -130,12 +132,14 @@ export class PreviewsStore {
}
}

/*
this.#storageChannel.postMessage({
type: 'storage-sync',
storage,
source: this._getTabId(),
timestamp: Date.now(),
});
*/
}
}

Expand Down Expand Up @@ -227,23 +231,27 @@ export class PreviewsStore {
const timestamp = Date.now();
this.#lastUpdate.set(previewId, timestamp);

/*
this.#broadcastChannel.postMessage({
type: 'state-change',
previewId,
timestamp,
});
*/
}

// Broadcast file change to all tabs
broadcastFileChange(previewId: string) {
const timestamp = Date.now();
this.#lastUpdate.set(previewId, timestamp);

/*
this.#broadcastChannel.postMessage({
type: 'file-change',
previewId,
timestamp,
});
*/
}

// Broadcast update to all tabs
Expand All @@ -254,11 +262,13 @@ export class PreviewsStore {
const timestamp = Date.now();
this.#lastUpdate.set(previewId, timestamp);

/*
this.#broadcastChannel.postMessage({
type: 'file-change',
previewId,
timestamp,
});
*/
}
}

Expand Down
2 changes: 1 addition & 1 deletion wrangler.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#:schema node_modules/wrangler/config-schema.json
name = "bolt"
compatibility_flags = ["nodejs_compat"]
compatibility_flags = ["nodejs_compat_v2"]
compatibility_date = "2024-07-01"
pages_build_output_dir = "./build/client"
send_metrics = false

0 comments on commit d9d4b5b

Please sign in to comment.