MCPcopy Create free account
hub / github.com/OpenAnonymity/oa-chat / showUpdatePrompt

Method showUpdatePrompt

chat/components/ShareModals.js:763–799  ·  view source on GitHub ↗

* Show prompt asking user if they want to view their local copy or fetch latest

(existingSession)

Source from the content-addressed store, hash-verified

761 <h3 class="text-lg font-semibold text-foreground mb-2">Updates Available</h3>
762 <p class="text-sm text-muted-foreground mb-4">
763 The shared chat "<strong>${escapeHtml(existingSession.title)}</strong>" has been updated since you imported it.
764 </p>
765 <div class="flex flex-col gap-2">
766 <button id="fetch-latest-btn" class="w-full px-4 py-2 text-sm font-medium rounded-lg bg-primary text-primary-foreground hover:bg-primary/90 transition-colors">
767 Fetch Latest Version <span class="opacity-60 ml-1">(Enter)</span>
768 </button>
769 <button id="use-local-btn" class="w-full px-4 py-2 text-sm font-medium rounded-lg border border-border text-foreground hover:bg-muted transition-colors">
770 Use My Local Copy <span class="opacity-60 ml-1">(Esc)</span>
771 </button>
772 </div>
773 </div>
774 `;
775
776 const handleKeydown = (e) => {
777 if (e.key === 'Enter') { e.preventDefault(); finish(true); }
778 else if (e.key === 'Escape') { e.preventDefault(); finish(false); }
779 };
780
781 const finish = (result) => {
782 document.removeEventListener('keydown', handleKeydown);
783 this.cleanup();
784 resolve(result);
785 };
786
787 document.addEventListener('keydown', handleKeydown);
788 modal.querySelector('#fetch-latest-btn').onclick = () => finish(true);
789 modal.querySelector('#use-local-btn').onclick = () => finish(false);
790 modal.onclick = (e) => { if (e.target === modal) finish(false); };
791 });
792 }
793
794 /**
795 * Show prompt when shared API key verification fails
796 */
797 showSharedKeyVerificationFailedPrompt({ error, stationId, isBanned, banReason }) {
798 return new Promise((resolve) => {
799 const modal = this.createModalContainer();
800
801 const title = isBanned ? 'Shared Key From Banned Station' : 'Shared Key Verification Failed';
802 const description = isBanned

Callers 1

Calls 2

createModalContainerMethod · 0.95
escapeHtmlFunction · 0.70

Tested by

no test coverage detected