-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
Preview.service.js
'use strict';
angular.module('skimmableVideosApp')
.service('Preview', function($http, $state, $timeout) {
// need to save to server to allow the user to retrieve preview in a new tab
// since Angular is a SPA, the new tab doesn't have all the data. local storage doesn't work either
this.create = function(skim) {
$http.post('/api/previews', skim)
.success(function(preview) {
var url = $state.href('preview', {previewId: preview._id});
window.open(url, '_blank');
})
.error(function() {
console.error('Unable to create preview.');
});
};
this.get = function(previewId) {
$timeout(function() {
$http.delete('/api/previews/'+previewId);
}, 10000);
return $http.get('/api/previews/'+previewId)
};
});
Right now I'm deleting the Preview from the server 10 seconds after the user goes to the preview page. This could lead to problems if the user refreshes the page after 10 seconds (because it'll then try to retrieve the preview from the server, and not be able to do so).
I'm not sure how else to do it though. Delete all previews once a day or something?
Reactions are currently unavailable