Commit 69f0af17 by Pragati Upadhyay

change branch

parent 1b29ea7b
var getUserDetails = null var getUserDetails = null
!function () { !function () {
var origin = "https://begenieus.online" var origin = "http://localhost:3003"
var tutorShotId = null var tutorShotId = null
var imageNumber = 0; var imageNumber = 0;
var recording = false; var recording = false;
...@@ -37,22 +37,22 @@ var getUserDetails = null ...@@ -37,22 +37,22 @@ var getUserDetails = null
}) })
} }
getData('userDetails', async (data)=>{ getData('userDetails', async (data) => {
if (data){ if (data) {
let tso = await getData('tutorShotId') let tso = await getData('tutorShotId')
tutorShotId = tso?tso:null tutorShotId = tso ? tso : null
let imgNum = await getData('imageNumber') let imgNum = await getData('imageNumber')
imageNumber = imgNum?imgNum:0 imageNumber = imgNum ? imgNum : 0
let rec = await getData('recording') let rec = await getData('recording')
recording = rec?rec:false recording = rec ? rec : false
userDetails = data userDetails = data
loggedIn = (userDetails.email || userDetails.uid)?true:false; loggedIn = (userDetails.email || userDetails.uid) ? true : false;
} }
}) })
function getStatus(){ function getStatus() {
return tutorShotId ? (recording ? "recording" : "paused"):"stopped" return tutorShotId ? (recording ? "recording" : "paused") : "stopped"
} }
...@@ -261,6 +261,18 @@ var getUserDetails = null ...@@ -261,6 +261,18 @@ var getUserDetails = null
if (loggedIn && request.action === 'stopRecording') { if (loggedIn && request.action === 'stopRecording') {
recording = false; recording = false;
let generatingOid = tutorShotId let generatingOid = tutorShotId
if (imageNumber < 1) {
let { data } = await api.delete("tutor-shot", {
params: { _id: tutorShotId },
headers: { userid: userDetails.uid }
})
tutorShotId = null
sendMessageToActiveTab("showRestartProcess")
setData("recording", false)
setData("tutorShotId", null)
return
}
else {
tutorShotId = null tutorShotId = null
sendResponse({ sendResponse({
userDetails, userDetails,
...@@ -276,6 +288,7 @@ var getUserDetails = null ...@@ -276,6 +288,7 @@ var getUserDetails = null
imageNumber = 0; imageNumber = 0;
return return
} }
}
if (request.action === 'logout') { if (request.action === 'logout') {
loggedIn = false; loggedIn = false;
recording = false; recording = false;
...@@ -369,9 +382,9 @@ var getUserDetails = null ...@@ -369,9 +382,9 @@ var getUserDetails = null
status: getStatus(), status: getStatus(),
message: messageObj message: messageObj
} }
try{ try {
chrome.tabs.sendMessage(activeTab?.id, message); chrome.tabs.sendMessage(activeTab?.id, message);
}catch(err){ } catch (err) {
console.log('error while sending data', activeTab, message) console.log('error while sending data', activeTab, message)
console.log(err) console.log(err)
} }
......
...@@ -6,7 +6,7 @@ var floatingBar = null; ...@@ -6,7 +6,7 @@ var floatingBar = null;
var startingOverlay = null; var startingOverlay = null;
var finalizingOverlay = null; var finalizingOverlay = null;
var overlayInterval = null; var overlayInterval = null;
const origin = "https://begenieus.online" const origin = "http://localhost:3003"
var userDetails = {}; var userDetails = {};
var btn = {}; var btn = {};
var tutorShotOid = null; var tutorShotOid = null;
...@@ -335,7 +335,6 @@ window.addEventListener('mousedown', async function (e) { ...@@ -335,7 +335,6 @@ window.addEventListener('mousedown', async function (e) {
} }
let newLineBreakIndex = captureInfo.text.search('\n') let newLineBreakIndex = captureInfo.text.search('\n')
if (newLineBreakIndex != -1) captureInfo.text = captureInfo.text.slice(0, newLineBreakIndex) if (newLineBreakIndex != -1) captureInfo.text = captureInfo.text.slice(0, newLineBreakIndex)
// console.log('sending capture info', captureInfo)
chrome.runtime.sendMessage({ action: "captureSS", captureInfo }) chrome.runtime.sendMessage({ action: "captureSS", captureInfo })
let data = await getCaptureData() let data = await getCaptureData()
reRenderFloatingBar(data) reRenderFloatingBar(data)
...@@ -382,6 +381,27 @@ chrome.runtime.onMessage.addListener(async function (message, sender, sendRespon ...@@ -382,6 +381,27 @@ chrome.runtime.onMessage.addListener(async function (message, sender, sendRespon
} }
} }
else if (message.message == 'showRestartProcess') {
finalizingOverlay = document.createElement('div')
finalizingOverlay.setAttribute('class', 'tutor-shot-overlay')
finalizingOverlay.setAttribute('style', `all: unset; position: fixed; top: 0px; bottom: 0px; left: 0px; right: 0px; background-color: #000000a0; pointer-events: inherit; z-index: 101; display: flex; color: white; justify-content: center; align-items: center; font-size: 28px;`)
document.body.append(finalizingOverlay)
finalizingOverlay.innerHTML = `
<div>
No Image found.
</div>
`
setTimeout(() => {
finalizingOverlay.remove()
if (window.location.href == `${origin}/tutor-shot-list`) {
window.location.reload()
} else {
window.open(`${origin}/tutor-shot-list`)
}
reRenderFloatingBar(data)
}, 2000)
reRenderFloatingBar(data)
}
else if (message.message == 'generatingVideo') { else if (message.message == 'generatingVideo') {
finalizingOverlay = document.createElement('div') finalizingOverlay = document.createElement('div')
finalizingOverlay.setAttribute('class', 'tutor-shot-overlay') finalizingOverlay.setAttribute('class', 'tutor-shot-overlay')
...@@ -411,10 +431,13 @@ chrome.runtime.onMessage.addListener(async function (message, sender, sendRespon ...@@ -411,10 +431,13 @@ chrome.runtime.onMessage.addListener(async function (message, sender, sendRespon
async function startRecording() { async function startRecording() {
try { try {
await getCaptureData(); await getCaptureData();
if(imageNumber>=1){
let { data } = await api.post('/tutor-shot', { title: "No Title" }, { headers: { userId: userDetails.uid } }) let { data } = await api.post('/tutor-shot', { title: "No Title" }, { headers: { userId: userDetails.uid } })
if (data.success) { if (data.success) {
await chrome.runtime.sendMessage({ action: "startRecording", tutorShotId: data.tutorShot._id }) await chrome.runtime.sendMessage({ action: "startRecording", tutorShotId: data.tutorShot._id })
} }
}
else return
} catch (err) { } catch (err) {
console.log('error while starting to record', err) console.log('error while starting to record', err)
inProgress = false inProgress = false
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"manifest_version": 3, "manifest_version": 3,
"name": "Tutor Shot", "name": "Tutor Shot",
"version": "1.10", "version": "1.10",
"description": "Capture web-page screenshots instantly with a single click. They're saved to your account at https://begenieus.online.", "description": "Capture web-page screenshots instantly with a single click. They're saved to your account at http://localhost:3003.",
"permissions": [ "permissions": [
"activeTab", "activeTab",
"storage" "storage"
......
!function () { !function () {
const origin = "https://begenieus.online" const origin = "http://localhost:3003"
const api = axios.create({ const api = axios.create({
baseURL: `${origin}/api`, // the base URL for nodeserver is okay but NGINX is giving error baseURL: `${origin}/api`, // the base URL for nodeserver is okay but NGINX is giving error
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment